diff --git a/sdk/resourcemanager/synapse/armsynapse/CHANGELOG.md b/sdk/resourcemanager/synapse/armsynapse/CHANGELOG.md index 2f5481ba6447..c2b15170e332 100644 --- a/sdk/resourcemanager/synapse/armsynapse/CHANGELOG.md +++ b/sdk/resourcemanager/synapse/armsynapse/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 0.7.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 0.6.0 (2023-02-24) ### Breaking Changes diff --git a/sdk/resourcemanager/synapse/armsynapse/README.md b/sdk/resourcemanager/synapse/armsynapse/README.md index 1f73136c6f9b..09ab2a928923 100644 --- a/sdk/resourcemanager/synapse/armsynapse/README.md +++ b/sdk/resourcemanager/synapse/armsynapse/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 Synapse 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 Synapse 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 := armsynapse.NewKustoPoolDataConnectionsClient(, cred, nil) +clientFactory, err := armsynapse.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 := armsynapse.NewKustoPoolDataConnectionsClient(, cred, &options) +clientFactory, err := armsynapse.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.NewKustoPoolDataConnectionsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/synapse/armsynapse/autorest.md b/sdk/resourcemanager/synapse/armsynapse/autorest.md index 2aa56987b1a2..2fb81d6ec576 100644 --- a/sdk/resourcemanager/synapse/armsynapse/autorest.md +++ b/sdk/resourcemanager/synapse/armsynapse/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/630ec444f8dd7c09b9cdd5fa99951f8a0d1ad41f/specification/synapse/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/630ec444f8dd7c09b9cdd5fa99951f8a0d1ad41f/specification/synapse/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.6.0 +module-version: 0.7.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/synapse/armsynapse/azureadonlyauthentications_client.go b/sdk/resourcemanager/synapse/armsynapse/azureadonlyauthentications_client.go index f098539dda43..8bc9329903a6 100644 --- a/sdk/resourcemanager/synapse/armsynapse/azureadonlyauthentications_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/azureadonlyauthentications_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // AzureADOnlyAuthenticationsClient contains the methods for the AzureADOnlyAuthentications group. // Don't use this type directly, use NewAzureADOnlyAuthenticationsClient() instead. type AzureADOnlyAuthenticationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAzureADOnlyAuthenticationsClient creates a new instance of AzureADOnlyAuthenticationsClient with the specified values. @@ -36,21 +33,13 @@ type AzureADOnlyAuthenticationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewAzureADOnlyAuthenticationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AzureADOnlyAuthenticationsClient, 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+".AzureADOnlyAuthenticationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AzureADOnlyAuthenticationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,11 +60,11 @@ func (client *AzureADOnlyAuthenticationsClient) BeginCreate(ctx context.Context, if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AzureADOnlyAuthenticationsClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AzureADOnlyAuthenticationsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[AzureADOnlyAuthenticationsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AzureADOnlyAuthenticationsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -88,7 +77,7 @@ func (client *AzureADOnlyAuthenticationsClient) create(ctx context.Context, reso 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 +106,7 @@ func (client *AzureADOnlyAuthenticationsClient) createCreateRequest(ctx context. return nil, errors.New("parameter azureADOnlyAuthenticationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{azureADOnlyAuthenticationName}", url.PathEscape(string(azureADOnlyAuthenticationName))) - 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 } @@ -142,7 +131,7 @@ func (client *AzureADOnlyAuthenticationsClient) Get(ctx context.Context, resourc if err != nil { return AzureADOnlyAuthenticationsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AzureADOnlyAuthenticationsClientGetResponse{}, err } @@ -171,7 +160,7 @@ func (client *AzureADOnlyAuthenticationsClient) getCreateRequest(ctx context.Con return nil, errors.New("parameter azureADOnlyAuthenticationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{azureADOnlyAuthenticationName}", url.PathEscape(string(azureADOnlyAuthenticationName))) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -214,7 +203,7 @@ func (client *AzureADOnlyAuthenticationsClient) NewListPager(resourceGroupName s if err != nil { return AzureADOnlyAuthenticationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AzureADOnlyAuthenticationsClientListResponse{}, err } @@ -241,7 +230,7 @@ func (client *AzureADOnlyAuthenticationsClient) listCreateRequest(ctx context.Co return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/azureadonlyauthentications_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/azureadonlyauthentications_client_example_test.go index 285477b6e232..cbfa6afd6c08 100644 --- a/sdk/resourcemanager/synapse/armsynapse/azureadonlyauthentications_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/azureadonlyauthentications_client_example_test.go @@ -25,11 +25,11 @@ func ExampleAzureADOnlyAuthenticationsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewAzureADOnlyAuthenticationsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "workspace-6852", "workspace-2080", armsynapse.AzureADOnlyAuthenticationNameDefault, nil) + res, err := clientFactory.NewAzureADOnlyAuthenticationsClient().Get(ctx, "workspace-6852", "workspace-2080", armsynapse.AzureADOnlyAuthenticationNameDefault, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -55,11 +55,11 @@ func ExampleAzureADOnlyAuthenticationsClient_BeginCreate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewAzureADOnlyAuthenticationsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "workspace-6852", "workspace-2080", armsynapse.AzureADOnlyAuthenticationNameDefault, armsynapse.AzureADOnlyAuthentication{ + poller, err := clientFactory.NewAzureADOnlyAuthenticationsClient().BeginCreate(ctx, "workspace-6852", "workspace-2080", armsynapse.AzureADOnlyAuthenticationNameDefault, armsynapse.AzureADOnlyAuthentication{ Properties: &armsynapse.AzureADOnlyAuthenticationProperties{ AzureADOnlyAuthentication: to.Ptr(true), }, @@ -93,11 +93,11 @@ func ExampleAzureADOnlyAuthenticationsClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewAzureADOnlyAuthenticationsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("workspace-6852", "workspace-2080", nil) + pager := clientFactory.NewAzureADOnlyAuthenticationsClient().NewListPager("workspace-6852", "workspace-2080", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/bigdatapools_client.go b/sdk/resourcemanager/synapse/armsynapse/bigdatapools_client.go index 71dd86d492b0..6e968b35e0ee 100644 --- a/sdk/resourcemanager/synapse/armsynapse/bigdatapools_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/bigdatapools_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,9 +25,8 @@ import ( // BigDataPoolsClient contains the methods for the BigDataPools group. // Don't use this type directly, use NewBigDataPoolsClient() instead. type BigDataPoolsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewBigDataPoolsClient creates a new instance of BigDataPoolsClient with the specified values. @@ -37,21 +34,13 @@ type BigDataPoolsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewBigDataPoolsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BigDataPoolsClient, 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+".BigDataPoolsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &BigDataPoolsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -72,11 +61,11 @@ func (client *BigDataPoolsClient) BeginCreateOrUpdate(ctx context.Context, resou if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[BigDataPoolsClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BigDataPoolsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[BigDataPoolsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[BigDataPoolsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -89,7 +78,7 @@ func (client *BigDataPoolsClient) createOrUpdate(ctx context.Context, resourceGr 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 +107,7 @@ func (client *BigDataPoolsClient) createOrUpdateCreateRequest(ctx context.Contex return nil, errors.New("parameter bigDataPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{bigDataPoolName}", url.PathEscape(bigDataPoolName)) - 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 } @@ -147,11 +136,11 @@ func (client *BigDataPoolsClient) BeginDelete(ctx context.Context, resourceGroup if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[BigDataPoolsClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BigDataPoolsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[BigDataPoolsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[BigDataPoolsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -164,7 +153,7 @@ func (client *BigDataPoolsClient) deleteOperation(ctx context.Context, resourceG 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 } @@ -193,7 +182,7 @@ func (client *BigDataPoolsClient) deleteCreateRequest(ctx context.Context, resou return nil, errors.New("parameter bigDataPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{bigDataPoolName}", url.PathEscape(bigDataPoolName)) - 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 } @@ -217,7 +206,7 @@ func (client *BigDataPoolsClient) Get(ctx context.Context, resourceGroupName str if err != nil { return BigDataPoolsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BigDataPoolsClientGetResponse{}, err } @@ -246,7 +235,7 @@ func (client *BigDataPoolsClient) getCreateRequest(ctx context.Context, resource return nil, errors.New("parameter bigDataPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{bigDataPoolName}", url.PathEscape(bigDataPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -289,7 +278,7 @@ func (client *BigDataPoolsClient) NewListByWorkspacePager(resourceGroupName stri if err != nil { return BigDataPoolsClientListByWorkspaceResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BigDataPoolsClientListByWorkspaceResponse{}, err } @@ -316,7 +305,7 @@ func (client *BigDataPoolsClient) listByWorkspaceCreateRequest(ctx context.Conte return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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,7 +339,7 @@ func (client *BigDataPoolsClient) Update(ctx context.Context, resourceGroupName if err != nil { return BigDataPoolsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BigDataPoolsClientUpdateResponse{}, err } @@ -379,7 +368,7 @@ func (client *BigDataPoolsClient) updateCreateRequest(ctx context.Context, resou return nil, errors.New("parameter bigDataPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{bigDataPoolName}", url.PathEscape(bigDataPoolName)) - 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/synapse/armsynapse/bigdatapools_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/bigdatapools_client_example_test.go index bb98b73ab23e..03a7180e7976 100644 --- a/sdk/resourcemanager/synapse/armsynapse/bigdatapools_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/bigdatapools_client_example_test.go @@ -25,11 +25,11 @@ func ExampleBigDataPoolsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewBigDataPoolsClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExamplePool", nil) + res, err := clientFactory.NewBigDataPoolsClient().Get(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExamplePool", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -78,11 +78,11 @@ func ExampleBigDataPoolsClient_Update() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewBigDataPoolsClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExamplePool", armsynapse.BigDataPoolPatchInfo{ + res, err := clientFactory.NewBigDataPoolsClient().Update(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExamplePool", armsynapse.BigDataPoolPatchInfo{ Tags: map[string]*string{ "key": to.Ptr("value"), }, @@ -136,11 +136,11 @@ func ExampleBigDataPoolsClient_BeginCreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewBigDataPoolsClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExamplePool", armsynapse.BigDataPoolResourceInfo{ + poller, err := clientFactory.NewBigDataPoolsClient().BeginCreateOrUpdate(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExamplePool", armsynapse.BigDataPoolResourceInfo{ Location: to.Ptr("West US 2"), Tags: map[string]*string{ "key": to.Ptr("value"), @@ -222,11 +222,11 @@ func ExampleBigDataPoolsClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewBigDataPoolsClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExamplePool", nil) + poller, err := clientFactory.NewBigDataPoolsClient().BeginDelete(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExamplePool", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -279,11 +279,11 @@ func ExampleBigDataPoolsClient_NewListByWorkspacePager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewBigDataPoolsClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByWorkspacePager("ExampleResourceGroup", "ExampleWorkspace", nil) + pager := clientFactory.NewBigDataPoolsClient().NewListByWorkspacePager("ExampleResourceGroup", "ExampleWorkspace", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/client_factory.go b/sdk/resourcemanager/synapse/armsynapse/client_factory.go new file mode 100644 index 000000000000..949cfc23d2c6 --- /dev/null +++ b/sdk/resourcemanager/synapse/armsynapse/client_factory.go @@ -0,0 +1,414 @@ +//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 armsynapse + +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) NewAzureADOnlyAuthenticationsClient() *AzureADOnlyAuthenticationsClient { + subClient, _ := NewAzureADOnlyAuthenticationsClient(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) NewIPFirewallRulesClient() *IPFirewallRulesClient { + subClient, _ := NewIPFirewallRulesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewKeysClient() *KeysClient { + subClient, _ := NewKeysClient(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) NewPrivateLinkHubPrivateLinkResourcesClient() *PrivateLinkHubPrivateLinkResourcesClient { + subClient, _ := NewPrivateLinkHubPrivateLinkResourcesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPrivateLinkHubsClient() *PrivateLinkHubsClient { + subClient, _ := NewPrivateLinkHubsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPrivateEndpointConnectionsPrivateLinkHubClient() *PrivateEndpointConnectionsPrivateLinkHubClient { + subClient, _ := NewPrivateEndpointConnectionsPrivateLinkHubClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolsClient() *SQLPoolsClient { + subClient, _ := NewSQLPoolsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolMetadataSyncConfigsClient() *SQLPoolMetadataSyncConfigsClient { + subClient, _ := NewSQLPoolMetadataSyncConfigsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolOperationResultsClient() *SQLPoolOperationResultsClient { + subClient, _ := NewSQLPoolOperationResultsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolGeoBackupPoliciesClient() *SQLPoolGeoBackupPoliciesClient { + subClient, _ := NewSQLPoolGeoBackupPoliciesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolDataWarehouseUserActivitiesClient() *SQLPoolDataWarehouseUserActivitiesClient { + subClient, _ := NewSQLPoolDataWarehouseUserActivitiesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolRestorePointsClient() *SQLPoolRestorePointsClient { + subClient, _ := NewSQLPoolRestorePointsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolReplicationLinksClient() *SQLPoolReplicationLinksClient { + subClient, _ := NewSQLPoolReplicationLinksClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolMaintenanceWindowsClient() *SQLPoolMaintenanceWindowsClient { + subClient, _ := NewSQLPoolMaintenanceWindowsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolMaintenanceWindowOptionsClient() *SQLPoolMaintenanceWindowOptionsClient { + subClient, _ := NewSQLPoolMaintenanceWindowOptionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolTransparentDataEncryptionsClient() *SQLPoolTransparentDataEncryptionsClient { + subClient, _ := NewSQLPoolTransparentDataEncryptionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolBlobAuditingPoliciesClient() *SQLPoolBlobAuditingPoliciesClient { + subClient, _ := NewSQLPoolBlobAuditingPoliciesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolOperationsClient() *SQLPoolOperationsClient { + subClient, _ := NewSQLPoolOperationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolUsagesClient() *SQLPoolUsagesClient { + subClient, _ := NewSQLPoolUsagesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolSensitivityLabelsClient() *SQLPoolSensitivityLabelsClient { + subClient, _ := NewSQLPoolSensitivityLabelsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolRecommendedSensitivityLabelsClient() *SQLPoolRecommendedSensitivityLabelsClient { + subClient, _ := NewSQLPoolRecommendedSensitivityLabelsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolSchemasClient() *SQLPoolSchemasClient { + subClient, _ := NewSQLPoolSchemasClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolTablesClient() *SQLPoolTablesClient { + subClient, _ := NewSQLPoolTablesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolTableColumnsClient() *SQLPoolTableColumnsClient { + subClient, _ := NewSQLPoolTableColumnsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolConnectionPoliciesClient() *SQLPoolConnectionPoliciesClient { + subClient, _ := NewSQLPoolConnectionPoliciesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolVulnerabilityAssessmentsClient() *SQLPoolVulnerabilityAssessmentsClient { + subClient, _ := NewSQLPoolVulnerabilityAssessmentsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolVulnerabilityAssessmentScansClient() *SQLPoolVulnerabilityAssessmentScansClient { + subClient, _ := NewSQLPoolVulnerabilityAssessmentScansClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolSecurityAlertPoliciesClient() *SQLPoolSecurityAlertPoliciesClient { + subClient, _ := NewSQLPoolSecurityAlertPoliciesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolVulnerabilityAssessmentRuleBaselinesClient() *SQLPoolVulnerabilityAssessmentRuleBaselinesClient { + subClient, _ := NewSQLPoolVulnerabilityAssessmentRuleBaselinesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewExtendedSQLPoolBlobAuditingPoliciesClient() *ExtendedSQLPoolBlobAuditingPoliciesClient { + subClient, _ := NewExtendedSQLPoolBlobAuditingPoliciesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDataMaskingPoliciesClient() *DataMaskingPoliciesClient { + subClient, _ := NewDataMaskingPoliciesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDataMaskingRulesClient() *DataMaskingRulesClient { + subClient, _ := NewDataMaskingRulesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolColumnsClient() *SQLPoolColumnsClient { + subClient, _ := NewSQLPoolColumnsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolWorkloadGroupClient() *SQLPoolWorkloadGroupClient { + subClient, _ := NewSQLPoolWorkloadGroupClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSQLPoolWorkloadClassifierClient() *SQLPoolWorkloadClassifierClient { + subClient, _ := NewSQLPoolWorkloadClassifierClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewWorkspaceManagedSQLServerBlobAuditingPoliciesClient() *WorkspaceManagedSQLServerBlobAuditingPoliciesClient { + subClient, _ := NewWorkspaceManagedSQLServerBlobAuditingPoliciesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewWorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient() *WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient { + subClient, _ := NewWorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewWorkspaceManagedSQLServerSecurityAlertPolicyClient() *WorkspaceManagedSQLServerSecurityAlertPolicyClient { + subClient, _ := NewWorkspaceManagedSQLServerSecurityAlertPolicyClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewWorkspaceManagedSQLServerVulnerabilityAssessmentsClient() *WorkspaceManagedSQLServerVulnerabilityAssessmentsClient { + subClient, _ := NewWorkspaceManagedSQLServerVulnerabilityAssessmentsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewWorkspaceManagedSQLServerEncryptionProtectorClient() *WorkspaceManagedSQLServerEncryptionProtectorClient { + subClient, _ := NewWorkspaceManagedSQLServerEncryptionProtectorClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewWorkspaceManagedSQLServerUsagesClient() *WorkspaceManagedSQLServerUsagesClient { + subClient, _ := NewWorkspaceManagedSQLServerUsagesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewWorkspaceManagedSQLServerRecoverableSQLPoolsClient() *WorkspaceManagedSQLServerRecoverableSQLPoolsClient { + subClient, _ := NewWorkspaceManagedSQLServerRecoverableSQLPoolsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewWorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient() *WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient { + subClient, _ := NewWorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewWorkspacesClient() *WorkspacesClient { + subClient, _ := NewWorkspacesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewWorkspaceAADAdminsClient() *WorkspaceAADAdminsClient { + subClient, _ := NewWorkspaceAADAdminsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewWorkspaceSQLAADAdminsClient() *WorkspaceSQLAADAdminsClient { + subClient, _ := NewWorkspaceSQLAADAdminsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewWorkspaceManagedIdentitySQLControlSettingsClient() *WorkspaceManagedIdentitySQLControlSettingsClient { + subClient, _ := NewWorkspaceManagedIdentitySQLControlSettingsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewRestorableDroppedSQLPoolsClient() *RestorableDroppedSQLPoolsClient { + subClient, _ := NewRestorableDroppedSQLPoolsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewBigDataPoolsClient() *BigDataPoolsClient { + subClient, _ := NewBigDataPoolsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewLibraryClient() *LibraryClient { + subClient, _ := NewLibraryClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewLibrariesClient() *LibrariesClient { + subClient, _ := NewLibrariesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewIntegrationRuntimesClient() *IntegrationRuntimesClient { + subClient, _ := NewIntegrationRuntimesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewIntegrationRuntimeNodeIPAddressClient() *IntegrationRuntimeNodeIPAddressClient { + subClient, _ := NewIntegrationRuntimeNodeIPAddressClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewIntegrationRuntimeObjectMetadataClient() *IntegrationRuntimeObjectMetadataClient { + subClient, _ := NewIntegrationRuntimeObjectMetadataClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewIntegrationRuntimeNodesClient() *IntegrationRuntimeNodesClient { + subClient, _ := NewIntegrationRuntimeNodesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewIntegrationRuntimeCredentialsClient() *IntegrationRuntimeCredentialsClient { + subClient, _ := NewIntegrationRuntimeCredentialsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewIntegrationRuntimeConnectionInfosClient() *IntegrationRuntimeConnectionInfosClient { + subClient, _ := NewIntegrationRuntimeConnectionInfosClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewIntegrationRuntimeAuthKeysClient() *IntegrationRuntimeAuthKeysClient { + subClient, _ := NewIntegrationRuntimeAuthKeysClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewIntegrationRuntimeMonitoringDataClient() *IntegrationRuntimeMonitoringDataClient { + subClient, _ := NewIntegrationRuntimeMonitoringDataClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewIntegrationRuntimeStatusClient() *IntegrationRuntimeStatusClient { + subClient, _ := NewIntegrationRuntimeStatusClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewGetClient() *GetClient { + subClient, _ := NewGetClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSparkConfigurationClient() *SparkConfigurationClient { + subClient, _ := NewSparkConfigurationClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSparkConfigurationsClient() *SparkConfigurationsClient { + subClient, _ := NewSparkConfigurationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewKustoOperationsClient() *KustoOperationsClient { + subClient, _ := NewKustoOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewKustoPoolsClient() *KustoPoolsClient { + subClient, _ := NewKustoPoolsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewKustoPoolChildResourceClient() *KustoPoolChildResourceClient { + subClient, _ := NewKustoPoolChildResourceClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewKustoPoolAttachedDatabaseConfigurationsClient() *KustoPoolAttachedDatabaseConfigurationsClient { + subClient, _ := NewKustoPoolAttachedDatabaseConfigurationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewKustoPoolDatabasesClient() *KustoPoolDatabasesClient { + subClient, _ := NewKustoPoolDatabasesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewKustoPoolDataConnectionsClient() *KustoPoolDataConnectionsClient { + subClient, _ := NewKustoPoolDataConnectionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewKustoPoolPrincipalAssignmentsClient() *KustoPoolPrincipalAssignmentsClient { + subClient, _ := NewKustoPoolPrincipalAssignmentsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewKustoPoolDatabasePrincipalAssignmentsClient() *KustoPoolDatabasePrincipalAssignmentsClient { + subClient, _ := NewKustoPoolDatabasePrincipalAssignmentsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewKustoPoolPrivateLinkResourcesClient() *KustoPoolPrivateLinkResourcesClient { + subClient, _ := NewKustoPoolPrivateLinkResourcesClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/synapse/armsynapse/constants.go b/sdk/resourcemanager/synapse/armsynapse/constants.go index a682eb46f4c4..d837127ca6ee 100644 --- a/sdk/resourcemanager/synapse/armsynapse/constants.go +++ b/sdk/resourcemanager/synapse/armsynapse/constants.go @@ -11,7 +11,7 @@ package armsynapse const ( moduleName = "armsynapse" - moduleVersion = "v0.6.0" + moduleVersion = "v0.7.0" ) // ActualState - Actual state diff --git a/sdk/resourcemanager/synapse/armsynapse/datamaskingpolicies_client.go b/sdk/resourcemanager/synapse/armsynapse/datamaskingpolicies_client.go index 7d824debc7f6..356ca14012b7 100644 --- a/sdk/resourcemanager/synapse/armsynapse/datamaskingpolicies_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/datamaskingpolicies_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // DataMaskingPoliciesClient contains the methods for the DataMaskingPolicies group. // Don't use this type directly, use NewDataMaskingPoliciesClient() instead. type DataMaskingPoliciesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDataMaskingPoliciesClient creates a new instance of DataMaskingPoliciesClient with the specified values. @@ -36,21 +33,13 @@ type DataMaskingPoliciesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewDataMaskingPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DataMaskingPoliciesClient, 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+".DataMaskingPoliciesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DataMaskingPoliciesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,7 +59,7 @@ func (client *DataMaskingPoliciesClient) CreateOrUpdate(ctx context.Context, res if err != nil { return DataMaskingPoliciesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DataMaskingPoliciesClientCreateOrUpdateResponse{}, err } @@ -100,7 +89,7 @@ func (client *DataMaskingPoliciesClient) createOrUpdateCreateRequest(ctx context } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) urlPath = strings.ReplaceAll(urlPath, "{dataMaskingPolicyName}", url.PathEscape("Default")) - 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,7 +122,7 @@ func (client *DataMaskingPoliciesClient) Get(ctx context.Context, resourceGroupN if err != nil { return DataMaskingPoliciesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DataMaskingPoliciesClientGetResponse{}, err } @@ -163,7 +152,7 @@ func (client *DataMaskingPoliciesClient) getCreateRequest(ctx context.Context, r } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) urlPath = strings.ReplaceAll(urlPath, "{dataMaskingPolicyName}", url.PathEscape("Default")) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/datamaskingpolicies_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/datamaskingpolicies_client_example_test.go index 0b2404d4f389..93a268766503 100644 --- a/sdk/resourcemanager/synapse/armsynapse/datamaskingpolicies_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/datamaskingpolicies_client_example_test.go @@ -25,11 +25,11 @@ func ExampleDataMaskingPoliciesClient_CreateOrUpdate_createOrUpdateDataMaskingPo log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewDataMaskingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", armsynapse.DataMaskingPolicy{ + res, err := clientFactory.NewDataMaskingPoliciesClient().CreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", armsynapse.DataMaskingPolicy{ Properties: &armsynapse.DataMaskingPolicyProperties{ DataMaskingState: to.Ptr(armsynapse.DataMaskingStateEnabled), ExemptPrincipals: to.Ptr("testuser;"), @@ -63,11 +63,11 @@ func ExampleDataMaskingPoliciesClient_CreateOrUpdate_createOrUpdateDataMaskingPo log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewDataMaskingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", armsynapse.DataMaskingPolicy{ + res, err := clientFactory.NewDataMaskingPoliciesClient().CreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", armsynapse.DataMaskingPolicy{ Properties: &armsynapse.DataMaskingPolicyProperties{ DataMaskingState: to.Ptr(armsynapse.DataMaskingStateEnabled), }, @@ -100,11 +100,11 @@ func ExampleDataMaskingPoliciesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewDataMaskingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", nil) + res, err := clientFactory.NewDataMaskingPoliciesClient().Get(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/datamaskingrules_client.go b/sdk/resourcemanager/synapse/armsynapse/datamaskingrules_client.go index bd5da7329dd4..8b4bd5606a15 100644 --- a/sdk/resourcemanager/synapse/armsynapse/datamaskingrules_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/datamaskingrules_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // DataMaskingRulesClient contains the methods for the DataMaskingRules group. // Don't use this type directly, use NewDataMaskingRulesClient() instead. type DataMaskingRulesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDataMaskingRulesClient creates a new instance of DataMaskingRulesClient with the specified values. @@ -36,21 +33,13 @@ type DataMaskingRulesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewDataMaskingRulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DataMaskingRulesClient, 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+".DataMaskingRulesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DataMaskingRulesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,7 +60,7 @@ func (client *DataMaskingRulesClient) CreateOrUpdate(ctx context.Context, resour if err != nil { return DataMaskingRulesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DataMaskingRulesClientCreateOrUpdateResponse{}, err } @@ -105,7 +94,7 @@ func (client *DataMaskingRulesClient) createOrUpdateCreateRequest(ctx context.Co return nil, errors.New("parameter dataMaskingRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dataMaskingRuleName}", url.PathEscape(dataMaskingRuleName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -139,7 +128,7 @@ func (client *DataMaskingRulesClient) Get(ctx context.Context, resourceGroupName if err != nil { return DataMaskingRulesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DataMaskingRulesClientGetResponse{}, err } @@ -173,7 +162,7 @@ func (client *DataMaskingRulesClient) getCreateRequest(ctx context.Context, reso return nil, errors.New("parameter dataMaskingRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dataMaskingRuleName}", url.PathEscape(dataMaskingRuleName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -211,7 +200,7 @@ func (client *DataMaskingRulesClient) NewListBySQLPoolPager(resourceGroupName st if err != nil { return DataMaskingRulesClientListBySQLPoolResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DataMaskingRulesClientListBySQLPoolResponse{}, err } @@ -243,7 +232,7 @@ func (client *DataMaskingRulesClient) listBySQLPoolCreateRequest(ctx context.Con } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) urlPath = strings.ReplaceAll(urlPath, "{dataMaskingPolicyName}", url.PathEscape("Default")) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/datamaskingrules_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/datamaskingrules_client_example_test.go index 215aee682338..f73c8ade3a5e 100644 --- a/sdk/resourcemanager/synapse/armsynapse/datamaskingrules_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/datamaskingrules_client_example_test.go @@ -25,11 +25,11 @@ func ExampleDataMaskingRulesClient_CreateOrUpdate_createUpdateDataMaskingRuleFor log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewDataMaskingRulesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", "rule1", armsynapse.DataMaskingRule{ + res, err := clientFactory.NewDataMaskingRulesClient().CreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", "rule1", armsynapse.DataMaskingRule{ Properties: &armsynapse.DataMaskingRuleProperties{ AliasName: to.Ptr("nickname"), ColumnName: to.Ptr("test1"), @@ -68,11 +68,11 @@ func ExampleDataMaskingRulesClient_CreateOrUpdate_createUpdateDataMaskingRuleFor log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewDataMaskingRulesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", "rule1", armsynapse.DataMaskingRule{ + res, err := clientFactory.NewDataMaskingRulesClient().CreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", "rule1", armsynapse.DataMaskingRule{ Properties: &armsynapse.DataMaskingRuleProperties{ ColumnName: to.Ptr("test1"), MaskingFunction: to.Ptr(armsynapse.DataMaskingFunctionDefault), @@ -108,11 +108,11 @@ func ExampleDataMaskingRulesClient_CreateOrUpdate_createUpdateDataMaskingRuleFor log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewDataMaskingRulesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", "rule1", armsynapse.DataMaskingRule{ + res, err := clientFactory.NewDataMaskingRulesClient().CreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", "rule1", armsynapse.DataMaskingRule{ Properties: &armsynapse.DataMaskingRuleProperties{ ColumnName: to.Ptr("test1"), MaskingFunction: to.Ptr(armsynapse.DataMaskingFunctionNumber), @@ -152,11 +152,11 @@ func ExampleDataMaskingRulesClient_CreateOrUpdate_createUpdateDataMaskingRuleFor log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewDataMaskingRulesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", "rule1", armsynapse.DataMaskingRule{ + res, err := clientFactory.NewDataMaskingRulesClient().CreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", "rule1", armsynapse.DataMaskingRule{ Properties: &armsynapse.DataMaskingRuleProperties{ ColumnName: to.Ptr("test1"), MaskingFunction: to.Ptr(armsynapse.DataMaskingFunctionText), @@ -198,11 +198,11 @@ func ExampleDataMaskingRulesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewDataMaskingRulesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", "rule1", nil) + res, err := clientFactory.NewDataMaskingRulesClient().Get(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", "rule1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -235,11 +235,11 @@ func ExampleDataMaskingRulesClient_NewListBySQLPoolPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewDataMaskingRulesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListBySQLPoolPager("sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", nil) + pager := clientFactory.NewDataMaskingRulesClient().NewListBySQLPoolPager("sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-331", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/extendedsqlpoolblobauditingpolicies_client.go b/sdk/resourcemanager/synapse/armsynapse/extendedsqlpoolblobauditingpolicies_client.go index 8242cfec6fb9..29bae3ba44af 100644 --- a/sdk/resourcemanager/synapse/armsynapse/extendedsqlpoolblobauditingpolicies_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/extendedsqlpoolblobauditingpolicies_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // ExtendedSQLPoolBlobAuditingPoliciesClient contains the methods for the ExtendedSQLPoolBlobAuditingPolicies group. // Don't use this type directly, use NewExtendedSQLPoolBlobAuditingPoliciesClient() instead. type ExtendedSQLPoolBlobAuditingPoliciesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewExtendedSQLPoolBlobAuditingPoliciesClient creates a new instance of ExtendedSQLPoolBlobAuditingPoliciesClient with the specified values. @@ -36,21 +33,13 @@ type ExtendedSQLPoolBlobAuditingPoliciesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewExtendedSQLPoolBlobAuditingPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExtendedSQLPoolBlobAuditingPoliciesClient, 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+".ExtendedSQLPoolBlobAuditingPoliciesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ExtendedSQLPoolBlobAuditingPoliciesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,7 +59,7 @@ func (client *ExtendedSQLPoolBlobAuditingPoliciesClient) CreateOrUpdate(ctx cont if err != nil { return ExtendedSQLPoolBlobAuditingPoliciesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExtendedSQLPoolBlobAuditingPoliciesClientCreateOrUpdateResponse{}, err } @@ -100,7 +89,7 @@ func (client *ExtendedSQLPoolBlobAuditingPoliciesClient) createOrUpdateCreateReq } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) urlPath = strings.ReplaceAll(urlPath, "{blobAuditingPolicyName}", url.PathEscape("default")) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -134,7 +123,7 @@ func (client *ExtendedSQLPoolBlobAuditingPoliciesClient) Get(ctx context.Context if err != nil { return ExtendedSQLPoolBlobAuditingPoliciesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExtendedSQLPoolBlobAuditingPoliciesClientGetResponse{}, err } @@ -164,7 +153,7 @@ func (client *ExtendedSQLPoolBlobAuditingPoliciesClient) getCreateRequest(ctx co } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) urlPath = strings.ReplaceAll(urlPath, "{blobAuditingPolicyName}", url.PathEscape("default")) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -208,7 +197,7 @@ func (client *ExtendedSQLPoolBlobAuditingPoliciesClient) NewListBySQLPoolPager(r if err != nil { return ExtendedSQLPoolBlobAuditingPoliciesClientListBySQLPoolResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExtendedSQLPoolBlobAuditingPoliciesClientListBySQLPoolResponse{}, err } @@ -239,7 +228,7 @@ func (client *ExtendedSQLPoolBlobAuditingPoliciesClient) listBySQLPoolCreateRequ return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/extendedsqlpoolblobauditingpolicies_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/extendedsqlpoolblobauditingpolicies_client_example_test.go index f1b32abc0f1d..beabfc9fd1b9 100644 --- a/sdk/resourcemanager/synapse/armsynapse/extendedsqlpoolblobauditingpolicies_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/extendedsqlpoolblobauditingpolicies_client_example_test.go @@ -25,11 +25,11 @@ func ExampleExtendedSQLPoolBlobAuditingPoliciesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewExtendedSQLPoolBlobAuditingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "blobauditingtest-6852", "blobauditingtest-2080", "testdb", nil) + res, err := clientFactory.NewExtendedSQLPoolBlobAuditingPoliciesClient().Get(ctx, "blobauditingtest-6852", "blobauditingtest-2080", "testdb", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -61,11 +61,11 @@ func ExampleExtendedSQLPoolBlobAuditingPoliciesClient_CreateOrUpdate_createOrUpd log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewExtendedSQLPoolBlobAuditingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "blobauditingtest-4799", "blobauditingtest-6440", "testdb", armsynapse.ExtendedSQLPoolBlobAuditingPolicy{ + res, err := clientFactory.NewExtendedSQLPoolBlobAuditingPoliciesClient().CreateOrUpdate(ctx, "blobauditingtest-4799", "blobauditingtest-6440", "testdb", armsynapse.ExtendedSQLPoolBlobAuditingPolicy{ Properties: &armsynapse.ExtendedSQLPoolBlobAuditingPolicyProperties{ IsAzureMonitorTargetEnabled: to.Ptr(true), State: to.Ptr(armsynapse.BlobAuditingPolicyStateEnabled), @@ -102,11 +102,11 @@ func ExampleExtendedSQLPoolBlobAuditingPoliciesClient_CreateOrUpdate_createOrUpd log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewExtendedSQLPoolBlobAuditingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "blobauditingtest-4799", "blobauditingtest-6440", "testdb", armsynapse.ExtendedSQLPoolBlobAuditingPolicy{ + res, err := clientFactory.NewExtendedSQLPoolBlobAuditingPoliciesClient().CreateOrUpdate(ctx, "blobauditingtest-4799", "blobauditingtest-6440", "testdb", armsynapse.ExtendedSQLPoolBlobAuditingPolicy{ Properties: &armsynapse.ExtendedSQLPoolBlobAuditingPolicyProperties{ AuditActionsAndGroups: []*string{ to.Ptr("DATABASE_LOGOUT_GROUP"), @@ -155,11 +155,11 @@ func ExampleExtendedSQLPoolBlobAuditingPoliciesClient_CreateOrUpdate_createOrUpd log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewExtendedSQLPoolBlobAuditingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "blobauditingtest-4799", "blobauditingtest-6440", "testdb", armsynapse.ExtendedSQLPoolBlobAuditingPolicy{ + res, err := clientFactory.NewExtendedSQLPoolBlobAuditingPoliciesClient().CreateOrUpdate(ctx, "blobauditingtest-4799", "blobauditingtest-6440", "testdb", armsynapse.ExtendedSQLPoolBlobAuditingPolicy{ Properties: &armsynapse.ExtendedSQLPoolBlobAuditingPolicyProperties{ State: to.Ptr(armsynapse.BlobAuditingPolicyStateEnabled), StorageAccountAccessKey: to.Ptr("sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD=="), @@ -198,11 +198,11 @@ func ExampleExtendedSQLPoolBlobAuditingPoliciesClient_NewListBySQLPoolPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewExtendedSQLPoolBlobAuditingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListBySQLPoolPager("blobauditingtest-6852", "blobauditingtest-2080", "testdb", nil) + pager := clientFactory.NewExtendedSQLPoolBlobAuditingPoliciesClient().NewListBySQLPoolPager("blobauditingtest-6852", "blobauditingtest-2080", "testdb", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/get_client.go b/sdk/resourcemanager/synapse/armsynapse/get_client.go index dd5a574245e1..d81fde4ecffa 100644 --- a/sdk/resourcemanager/synapse/armsynapse/get_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/get_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // GetClient contains the methods for the Get group. // Don't use this type directly, use NewGetClient() instead. type GetClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewGetClient creates a new instance of GetClient with the specified values. @@ -36,21 +33,13 @@ type GetClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewGetClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*GetClient, 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+".GetClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &GetClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,7 +59,7 @@ func (client *GetClient) IntegrationRuntimeEnableInteractivequery(ctx context.Co if err != nil { return GetClientIntegrationRuntimeEnableInteractivequeryResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GetClientIntegrationRuntimeEnableInteractivequeryResponse{}, err } @@ -103,7 +92,7 @@ func (client *GetClient) integrationRuntimeEnableInteractivequeryCreateRequest(c return nil, errors.New("parameter integrationRuntimeOperationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeOperationId}", url.PathEscape(integrationRuntimeOperationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -138,7 +127,7 @@ func (client *GetClient) IntegrationRuntimeStart(ctx context.Context, resourceGr if err != nil { return GetClientIntegrationRuntimeStartResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GetClientIntegrationRuntimeStartResponse{}, err } @@ -171,7 +160,7 @@ func (client *GetClient) integrationRuntimeStartCreateRequest(ctx context.Contex return nil, errors.New("parameter integrationRuntimeOperationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeOperationId}", url.PathEscape(integrationRuntimeOperationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -206,7 +195,7 @@ func (client *GetClient) IntegrationRuntimeStop(ctx context.Context, resourceGro if err != nil { return GetClientIntegrationRuntimeStopResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GetClientIntegrationRuntimeStopResponse{}, err } @@ -239,7 +228,7 @@ func (client *GetClient) integrationRuntimeStopCreateRequest(ctx context.Context return nil, errors.New("parameter integrationRuntimeOperationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeOperationId}", url.PathEscape(integrationRuntimeOperationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/get_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/get_client_example_test.go index 35b350c1efaa..8e5bbd7aafb5 100644 --- a/sdk/resourcemanager/synapse/armsynapse/get_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/get_client_example_test.go @@ -24,11 +24,11 @@ func ExampleGetClient_IntegrationRuntimeStart() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewGetClient("2d03866b-587b-4e1f-a2fe-0a55958c655e", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.IntegrationRuntimeStart(ctx, "drage-felles-prod-rg", "felles-prod-synapse-workspace", "SSIS-intergrationRuntime-Drage", "5752dcdf918e4aecb941245ddf6ebb83", nil) + res, err := clientFactory.NewGetClient().IntegrationRuntimeStart(ctx, "drage-felles-prod-rg", "felles-prod-synapse-workspace", "SSIS-intergrationRuntime-Drage", "5752dcdf918e4aecb941245ddf6ebb83", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -52,11 +52,11 @@ func ExampleGetClient_IntegrationRuntimeStop() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewGetClient("2d03866b-587b-4e1f-a2fe-0a55958c655e", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.IntegrationRuntimeStop(ctx, "drage-felles-prod-rg", "felles-prod-synapse-workspace", "SSIS-intergrationRuntime-Drage", "5752dcdf918e4aecb941245ddf6ebb83", nil) + res, err := clientFactory.NewGetClient().IntegrationRuntimeStop(ctx, "drage-felles-prod-rg", "felles-prod-synapse-workspace", "SSIS-intergrationRuntime-Drage", "5752dcdf918e4aecb941245ddf6ebb83", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -80,11 +80,11 @@ func ExampleGetClient_IntegrationRuntimeEnableInteractivequery() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewGetClient("2d03866b-587b-4e1f-a2fe-0a55958c655e", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.IntegrationRuntimeEnableInteractivequery(ctx, "drage-felles-prod-rg", "felles-prod-synapse-workspace", "SSIS-intergrationRuntime-Drage", "5752dcdf918e4aecb941245ddf6ebb83", nil) + res, err := clientFactory.NewGetClient().IntegrationRuntimeEnableInteractivequery(ctx, "drage-felles-prod-rg", "felles-prod-synapse-workspace", "SSIS-intergrationRuntime-Drage", "5752dcdf918e4aecb941245ddf6ebb83", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/go.mod b/sdk/resourcemanager/synapse/armsynapse/go.mod index b0b88fb2c10a..0d31c06234c1 100644 --- a/sdk/resourcemanager/synapse/armsynapse/go.mod +++ b/sdk/resourcemanager/synapse/armsynapse/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/synapse/armsynapse go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1 // indirect - github.com/golang-jwt/jwt/v4 v4.4.2 // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/synapse/armsynapse/go.sum b/sdk/resourcemanager/synapse/armsynapse/go.sum index 67cfef6bdf6e..8ba445a8c4da 100644 --- a/sdk/resourcemanager/synapse/armsynapse/go.sum +++ b/sdk/resourcemanager/synapse/armsynapse/go.sum @@ -1,30 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1 h1:T8quHYlUGyb/oqtSTwqlCr1ilJHrDv+ZtpSfo+hm1BU= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1/go.mod h1:gLa1CL2RNE4s7M3yopJ/p0iq5DdY6Yv5ZUt9MTRZOQM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1 h1:oPdPEZFSbl7oSPEAIPMPBMUmiL+mqgzBJwM/9qYcwNg= -github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1/go.mod h1:4qFor3D/HDsvBME35Xy9rwW9DecL+M2sNw1ybjPtwA0= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= -github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/synapse/armsynapse/integrationruntimeauthkeys_client.go b/sdk/resourcemanager/synapse/armsynapse/integrationruntimeauthkeys_client.go index 60bdba556da4..3429515a456c 100644 --- a/sdk/resourcemanager/synapse/armsynapse/integrationruntimeauthkeys_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/integrationruntimeauthkeys_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // IntegrationRuntimeAuthKeysClient contains the methods for the IntegrationRuntimeAuthKeys group. // Don't use this type directly, use NewIntegrationRuntimeAuthKeysClient() instead. type IntegrationRuntimeAuthKeysClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewIntegrationRuntimeAuthKeysClient creates a new instance of IntegrationRuntimeAuthKeysClient with the specified values. @@ -36,21 +33,13 @@ type IntegrationRuntimeAuthKeysClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationRuntimeAuthKeysClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationRuntimeAuthKeysClient, 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+".IntegrationRuntimeAuthKeysClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &IntegrationRuntimeAuthKeysClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -69,7 +58,7 @@ func (client *IntegrationRuntimeAuthKeysClient) List(ctx context.Context, resour if err != nil { return IntegrationRuntimeAuthKeysClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationRuntimeAuthKeysClientListResponse{}, err } @@ -98,7 +87,7 @@ func (client *IntegrationRuntimeAuthKeysClient) listCreateRequest(ctx context.Co return nil, errors.New("parameter integrationRuntimeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeName}", url.PathEscape(integrationRuntimeName)) - 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 } @@ -133,7 +122,7 @@ func (client *IntegrationRuntimeAuthKeysClient) Regenerate(ctx context.Context, if err != nil { return IntegrationRuntimeAuthKeysClientRegenerateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationRuntimeAuthKeysClientRegenerateResponse{}, err } @@ -162,7 +151,7 @@ func (client *IntegrationRuntimeAuthKeysClient) regenerateCreateRequest(ctx cont return nil, errors.New("parameter integrationRuntimeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeName}", url.PathEscape(integrationRuntimeName)) - 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/synapse/armsynapse/integrationruntimeauthkeys_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/integrationruntimeauthkeys_client_example_test.go index 6df4921c176d..68852fd59312 100644 --- a/sdk/resourcemanager/synapse/armsynapse/integrationruntimeauthkeys_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/integrationruntimeauthkeys_client_example_test.go @@ -25,11 +25,11 @@ func ExampleIntegrationRuntimeAuthKeysClient_Regenerate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimeAuthKeysClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Regenerate(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", armsynapse.IntegrationRuntimeRegenerateKeyParameters{ + res, err := clientFactory.NewIntegrationRuntimeAuthKeysClient().Regenerate(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", armsynapse.IntegrationRuntimeRegenerateKeyParameters{ KeyName: to.Ptr(armsynapse.IntegrationRuntimeAuthKeyNameAuthKey2), }, nil) if err != nil { @@ -50,11 +50,11 @@ func ExampleIntegrationRuntimeAuthKeysClient_List() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimeAuthKeysClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.List(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", nil) + res, err := clientFactory.NewIntegrationRuntimeAuthKeysClient().List(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/integrationruntimeconnectioninfos_client.go b/sdk/resourcemanager/synapse/armsynapse/integrationruntimeconnectioninfos_client.go index 7042efca91d9..be4729e733cb 100644 --- a/sdk/resourcemanager/synapse/armsynapse/integrationruntimeconnectioninfos_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/integrationruntimeconnectioninfos_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // IntegrationRuntimeConnectionInfosClient contains the methods for the IntegrationRuntimeConnectionInfos group. // Don't use this type directly, use NewIntegrationRuntimeConnectionInfosClient() instead. type IntegrationRuntimeConnectionInfosClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewIntegrationRuntimeConnectionInfosClient creates a new instance of IntegrationRuntimeConnectionInfosClient with the specified values. @@ -36,21 +33,13 @@ type IntegrationRuntimeConnectionInfosClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationRuntimeConnectionInfosClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationRuntimeConnectionInfosClient, 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+".IntegrationRuntimeConnectionInfosClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &IntegrationRuntimeConnectionInfosClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -69,7 +58,7 @@ func (client *IntegrationRuntimeConnectionInfosClient) Get(ctx context.Context, if err != nil { return IntegrationRuntimeConnectionInfosClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationRuntimeConnectionInfosClientGetResponse{}, err } @@ -98,7 +87,7 @@ func (client *IntegrationRuntimeConnectionInfosClient) getCreateRequest(ctx cont return nil, errors.New("parameter integrationRuntimeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeName}", url.PathEscape(integrationRuntimeName)) - 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/synapse/armsynapse/integrationruntimeconnectioninfos_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/integrationruntimeconnectioninfos_client_example_test.go index f2026c2e60d2..e0fe603c6888 100644 --- a/sdk/resourcemanager/synapse/armsynapse/integrationruntimeconnectioninfos_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/integrationruntimeconnectioninfos_client_example_test.go @@ -24,11 +24,11 @@ func ExampleIntegrationRuntimeConnectionInfosClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimeConnectionInfosClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", nil) + res, err := clientFactory.NewIntegrationRuntimeConnectionInfosClient().Get(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/integrationruntimecredentials_client.go b/sdk/resourcemanager/synapse/armsynapse/integrationruntimecredentials_client.go index 60128cf6f630..c186ef096f06 100644 --- a/sdk/resourcemanager/synapse/armsynapse/integrationruntimecredentials_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/integrationruntimecredentials_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // IntegrationRuntimeCredentialsClient contains the methods for the IntegrationRuntimeCredentials group. // Don't use this type directly, use NewIntegrationRuntimeCredentialsClient() instead. type IntegrationRuntimeCredentialsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewIntegrationRuntimeCredentialsClient creates a new instance of IntegrationRuntimeCredentialsClient with the specified values. @@ -36,21 +33,13 @@ type IntegrationRuntimeCredentialsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationRuntimeCredentialsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationRuntimeCredentialsClient, 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+".IntegrationRuntimeCredentialsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &IntegrationRuntimeCredentialsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -72,7 +61,7 @@ func (client *IntegrationRuntimeCredentialsClient) Sync(ctx context.Context, res if err != nil { return IntegrationRuntimeCredentialsClientSyncResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationRuntimeCredentialsClientSyncResponse{}, err } @@ -101,7 +90,7 @@ func (client *IntegrationRuntimeCredentialsClient) syncCreateRequest(ctx context return nil, errors.New("parameter integrationRuntimeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeName}", url.PathEscape(integrationRuntimeName)) - 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/synapse/armsynapse/integrationruntimecredentials_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/integrationruntimecredentials_client_example_test.go index 02fc34c01179..6afc4933f4da 100644 --- a/sdk/resourcemanager/synapse/armsynapse/integrationruntimecredentials_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/integrationruntimecredentials_client_example_test.go @@ -24,11 +24,11 @@ func ExampleIntegrationRuntimeCredentialsClient_Sync() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimeCredentialsClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Sync(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", nil) + _, err = clientFactory.NewIntegrationRuntimeCredentialsClient().Sync(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/integrationruntimemonitoringdata_client.go b/sdk/resourcemanager/synapse/armsynapse/integrationruntimemonitoringdata_client.go index 6ba67b5fb5b2..83ea9719bff6 100644 --- a/sdk/resourcemanager/synapse/armsynapse/integrationruntimemonitoringdata_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/integrationruntimemonitoringdata_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // IntegrationRuntimeMonitoringDataClient contains the methods for the IntegrationRuntimeMonitoringData group. // Don't use this type directly, use NewIntegrationRuntimeMonitoringDataClient() instead. type IntegrationRuntimeMonitoringDataClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewIntegrationRuntimeMonitoringDataClient creates a new instance of IntegrationRuntimeMonitoringDataClient with the specified values. @@ -36,21 +33,13 @@ type IntegrationRuntimeMonitoringDataClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationRuntimeMonitoringDataClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationRuntimeMonitoringDataClient, 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+".IntegrationRuntimeMonitoringDataClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &IntegrationRuntimeMonitoringDataClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -69,7 +58,7 @@ func (client *IntegrationRuntimeMonitoringDataClient) List(ctx context.Context, if err != nil { return IntegrationRuntimeMonitoringDataClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationRuntimeMonitoringDataClientListResponse{}, err } @@ -98,7 +87,7 @@ func (client *IntegrationRuntimeMonitoringDataClient) listCreateRequest(ctx cont return nil, errors.New("parameter integrationRuntimeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeName}", url.PathEscape(integrationRuntimeName)) - 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/synapse/armsynapse/integrationruntimemonitoringdata_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/integrationruntimemonitoringdata_client_example_test.go index b8cc86568e65..03b1eb33fa58 100644 --- a/sdk/resourcemanager/synapse/armsynapse/integrationruntimemonitoringdata_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/integrationruntimemonitoringdata_client_example_test.go @@ -24,11 +24,11 @@ func ExampleIntegrationRuntimeMonitoringDataClient_List() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimeMonitoringDataClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.List(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", nil) + res, err := clientFactory.NewIntegrationRuntimeMonitoringDataClient().List(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/integrationruntimenodeipaddress_client.go b/sdk/resourcemanager/synapse/armsynapse/integrationruntimenodeipaddress_client.go index 3e1b0814dfc7..ea400b5407d2 100644 --- a/sdk/resourcemanager/synapse/armsynapse/integrationruntimenodeipaddress_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/integrationruntimenodeipaddress_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // IntegrationRuntimeNodeIPAddressClient contains the methods for the IntegrationRuntimeNodeIPAddress group. // Don't use this type directly, use NewIntegrationRuntimeNodeIPAddressClient() instead. type IntegrationRuntimeNodeIPAddressClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewIntegrationRuntimeNodeIPAddressClient creates a new instance of IntegrationRuntimeNodeIPAddressClient with the specified values. @@ -36,21 +33,13 @@ type IntegrationRuntimeNodeIPAddressClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationRuntimeNodeIPAddressClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationRuntimeNodeIPAddressClient, 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+".IntegrationRuntimeNodeIPAddressClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &IntegrationRuntimeNodeIPAddressClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,7 +59,7 @@ func (client *IntegrationRuntimeNodeIPAddressClient) Get(ctx context.Context, re if err != nil { return IntegrationRuntimeNodeIPAddressClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationRuntimeNodeIPAddressClientGetResponse{}, err } @@ -103,7 +92,7 @@ func (client *IntegrationRuntimeNodeIPAddressClient) getCreateRequest(ctx contex return nil, errors.New("parameter nodeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{nodeName}", url.PathEscape(nodeName)) - 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/synapse/armsynapse/integrationruntimenodeipaddress_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/integrationruntimenodeipaddress_client_example_test.go index 00e1c4d7f12e..4443449f2ac0 100644 --- a/sdk/resourcemanager/synapse/armsynapse/integrationruntimenodeipaddress_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/integrationruntimenodeipaddress_client_example_test.go @@ -24,11 +24,11 @@ func ExampleIntegrationRuntimeNodeIPAddressClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimeNodeIPAddressClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", "Node_1", nil) + res, err := clientFactory.NewIntegrationRuntimeNodeIPAddressClient().Get(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", "Node_1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/integrationruntimenodes_client.go b/sdk/resourcemanager/synapse/armsynapse/integrationruntimenodes_client.go index 41c2f41749f0..97a2f94dfa99 100644 --- a/sdk/resourcemanager/synapse/armsynapse/integrationruntimenodes_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/integrationruntimenodes_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // IntegrationRuntimeNodesClient contains the methods for the IntegrationRuntimeNodes group. // Don't use this type directly, use NewIntegrationRuntimeNodesClient() instead. type IntegrationRuntimeNodesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewIntegrationRuntimeNodesClient creates a new instance of IntegrationRuntimeNodesClient with the specified values. @@ -36,21 +33,13 @@ type IntegrationRuntimeNodesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationRuntimeNodesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationRuntimeNodesClient, 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+".IntegrationRuntimeNodesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &IntegrationRuntimeNodesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,7 +59,7 @@ func (client *IntegrationRuntimeNodesClient) Delete(ctx context.Context, resourc if err != nil { return IntegrationRuntimeNodesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationRuntimeNodesClientDeleteResponse{}, err } @@ -103,7 +92,7 @@ func (client *IntegrationRuntimeNodesClient) deleteCreateRequest(ctx context.Con return nil, errors.New("parameter nodeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{nodeName}", url.PathEscape(nodeName)) - 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 } @@ -129,7 +118,7 @@ func (client *IntegrationRuntimeNodesClient) Get(ctx context.Context, resourceGr if err != nil { return IntegrationRuntimeNodesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationRuntimeNodesClientGetResponse{}, err } @@ -162,7 +151,7 @@ func (client *IntegrationRuntimeNodesClient) getCreateRequest(ctx context.Contex return nil, errors.New("parameter nodeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{nodeName}", url.PathEscape(nodeName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -198,7 +187,7 @@ func (client *IntegrationRuntimeNodesClient) Update(ctx context.Context, resourc if err != nil { return IntegrationRuntimeNodesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationRuntimeNodesClientUpdateResponse{}, err } @@ -231,7 +220,7 @@ func (client *IntegrationRuntimeNodesClient) updateCreateRequest(ctx context.Con return nil, errors.New("parameter nodeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{nodeName}", url.PathEscape(nodeName)) - 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/synapse/armsynapse/integrationruntimenodes_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/integrationruntimenodes_client_example_test.go index d67fc091f02d..f56c8b9c1d05 100644 --- a/sdk/resourcemanager/synapse/armsynapse/integrationruntimenodes_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/integrationruntimenodes_client_example_test.go @@ -25,11 +25,11 @@ func ExampleIntegrationRuntimeNodesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimeNodesClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", "Node_1", nil) + res, err := clientFactory.NewIntegrationRuntimeNodesClient().Get(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", "Node_1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -66,11 +66,11 @@ func ExampleIntegrationRuntimeNodesClient_Update() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimeNodesClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", "Node_1", armsynapse.UpdateIntegrationRuntimeNodeRequest{ + res, err := clientFactory.NewIntegrationRuntimeNodesClient().Update(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", "Node_1", armsynapse.UpdateIntegrationRuntimeNodeRequest{ ConcurrentJobsLimit: to.Ptr[int32](2), }, nil) if err != nil { @@ -110,11 +110,11 @@ func ExampleIntegrationRuntimeNodesClient_Delete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimeNodesClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", "Node_1", nil) + _, err = clientFactory.NewIntegrationRuntimeNodesClient().Delete(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", "Node_1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/integrationruntimeobjectmetadata_client.go b/sdk/resourcemanager/synapse/armsynapse/integrationruntimeobjectmetadata_client.go index 31582ffc50ec..f68171bfcad4 100644 --- a/sdk/resourcemanager/synapse/armsynapse/integrationruntimeobjectmetadata_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/integrationruntimeobjectmetadata_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // IntegrationRuntimeObjectMetadataClient contains the methods for the IntegrationRuntimeObjectMetadata group. // Don't use this type directly, use NewIntegrationRuntimeObjectMetadataClient() instead. type IntegrationRuntimeObjectMetadataClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewIntegrationRuntimeObjectMetadataClient creates a new instance of IntegrationRuntimeObjectMetadataClient with the specified values. @@ -36,21 +33,13 @@ type IntegrationRuntimeObjectMetadataClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationRuntimeObjectMetadataClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationRuntimeObjectMetadataClient, 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+".IntegrationRuntimeObjectMetadataClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &IntegrationRuntimeObjectMetadataClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -69,7 +58,7 @@ func (client *IntegrationRuntimeObjectMetadataClient) List(ctx context.Context, if err != nil { return IntegrationRuntimeObjectMetadataClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationRuntimeObjectMetadataClientListResponse{}, err } @@ -98,7 +87,7 @@ func (client *IntegrationRuntimeObjectMetadataClient) listCreateRequest(ctx cont return nil, errors.New("parameter integrationRuntimeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeName}", url.PathEscape(integrationRuntimeName)) - 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 } @@ -136,11 +125,11 @@ func (client *IntegrationRuntimeObjectMetadataClient) BeginRefresh(ctx context.C if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[IntegrationRuntimeObjectMetadataClientRefreshResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[IntegrationRuntimeObjectMetadataClientRefreshResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[IntegrationRuntimeObjectMetadataClientRefreshResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[IntegrationRuntimeObjectMetadataClientRefreshResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -153,7 +142,7 @@ func (client *IntegrationRuntimeObjectMetadataClient) refresh(ctx context.Contex 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 +171,7 @@ func (client *IntegrationRuntimeObjectMetadataClient) refreshCreateRequest(ctx c return nil, errors.New("parameter integrationRuntimeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeName}", url.PathEscape(integrationRuntimeName)) - 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/synapse/armsynapse/integrationruntimeobjectmetadata_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/integrationruntimeobjectmetadata_client_example_test.go index 05351b309794..2c71c9c49019 100644 --- a/sdk/resourcemanager/synapse/armsynapse/integrationruntimeobjectmetadata_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/integrationruntimeobjectmetadata_client_example_test.go @@ -25,11 +25,11 @@ func ExampleIntegrationRuntimeObjectMetadataClient_List() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimeObjectMetadataClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.List(ctx, "exampleResourceGroup", "exampleWorkspace", "testactivityv2", &armsynapse.IntegrationRuntimeObjectMetadataClientListOptions{GetMetadataRequest: &armsynapse.GetSsisObjectMetadataRequest{ + res, err := clientFactory.NewIntegrationRuntimeObjectMetadataClient().List(ctx, "exampleResourceGroup", "exampleWorkspace", "testactivityv2", &armsynapse.IntegrationRuntimeObjectMetadataClientListOptions{GetMetadataRequest: &armsynapse.GetSsisObjectMetadataRequest{ MetadataPath: to.Ptr("ssisFolders"), }, }) @@ -555,11 +555,11 @@ func ExampleIntegrationRuntimeObjectMetadataClient_BeginRefresh() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimeObjectMetadataClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginRefresh(ctx, "exampleResourceGroup", "exampleWorkspace", "testactivityv2", nil) + poller, err := clientFactory.NewIntegrationRuntimeObjectMetadataClient().BeginRefresh(ctx, "exampleResourceGroup", "exampleWorkspace", "testactivityv2", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/integrationruntimes_client.go b/sdk/resourcemanager/synapse/armsynapse/integrationruntimes_client.go index 9efb0ae03ae4..17648452017e 100644 --- a/sdk/resourcemanager/synapse/armsynapse/integrationruntimes_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/integrationruntimes_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // IntegrationRuntimesClient contains the methods for the IntegrationRuntimes group. // Don't use this type directly, use NewIntegrationRuntimesClient() instead. type IntegrationRuntimesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewIntegrationRuntimesClient creates a new instance of IntegrationRuntimesClient with the specified values. @@ -36,21 +33,13 @@ type IntegrationRuntimesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationRuntimesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationRuntimesClient, 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+".IntegrationRuntimesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &IntegrationRuntimesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,9 +60,9 @@ func (client *IntegrationRuntimesClient) BeginCreate(ctx context.Context, resour if err != nil { return nil, err } - return runtime.NewPoller[IntegrationRuntimesClientCreateResponse](resp, client.pl, nil) + return runtime.NewPoller[IntegrationRuntimesClientCreateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[IntegrationRuntimesClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[IntegrationRuntimesClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -86,7 +75,7 @@ func (client *IntegrationRuntimesClient) create(ctx context.Context, resourceGro 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 +104,7 @@ func (client *IntegrationRuntimesClient) createCreateRequest(ctx context.Context return nil, errors.New("parameter integrationRuntimeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeName}", url.PathEscape(integrationRuntimeName)) - 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 } @@ -144,9 +133,9 @@ func (client *IntegrationRuntimesClient) BeginDelete(ctx context.Context, resour if err != nil { return nil, err } - return runtime.NewPoller[IntegrationRuntimesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[IntegrationRuntimesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[IntegrationRuntimesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[IntegrationRuntimesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -159,7 +148,7 @@ func (client *IntegrationRuntimesClient) deleteOperation(ctx context.Context, re 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 +177,7 @@ func (client *IntegrationRuntimesClient) deleteCreateRequest(ctx context.Context return nil, errors.New("parameter integrationRuntimeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeName}", url.PathEscape(integrationRuntimeName)) - 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 } @@ -214,9 +203,9 @@ func (client *IntegrationRuntimesClient) BeginDisableInteractiveQuery(ctx contex if err != nil { return nil, err } - return runtime.NewPoller[IntegrationRuntimesClientDisableInteractiveQueryResponse](resp, client.pl, nil) + return runtime.NewPoller[IntegrationRuntimesClientDisableInteractiveQueryResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[IntegrationRuntimesClientDisableInteractiveQueryResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[IntegrationRuntimesClientDisableInteractiveQueryResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -229,7 +218,7 @@ func (client *IntegrationRuntimesClient) disableInteractiveQuery(ctx context.Con 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 +247,7 @@ func (client *IntegrationRuntimesClient) disableInteractiveQueryCreateRequest(ct return nil, errors.New("parameter integrationRuntimeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeName}", url.PathEscape(integrationRuntimeName)) - 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 } @@ -284,9 +273,9 @@ func (client *IntegrationRuntimesClient) BeginEnableInteractiveQuery(ctx context if err != nil { return nil, err } - return runtime.NewPoller[IntegrationRuntimesClientEnableInteractiveQueryResponse](resp, client.pl, nil) + return runtime.NewPoller[IntegrationRuntimesClientEnableInteractiveQueryResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[IntegrationRuntimesClientEnableInteractiveQueryResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[IntegrationRuntimesClientEnableInteractiveQueryResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -299,7 +288,7 @@ func (client *IntegrationRuntimesClient) enableInteractiveQuery(ctx context.Cont 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 } @@ -328,7 +317,7 @@ func (client *IntegrationRuntimesClient) enableInteractiveQueryCreateRequest(ctx return nil, errors.New("parameter integrationRuntimeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeName}", url.PathEscape(integrationRuntimeName)) - 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 } @@ -352,7 +341,7 @@ func (client *IntegrationRuntimesClient) Get(ctx context.Context, resourceGroupN if err != nil { return IntegrationRuntimesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationRuntimesClientGetResponse{}, err } @@ -381,7 +370,7 @@ func (client *IntegrationRuntimesClient) getCreateRequest(ctx context.Context, r return nil, errors.New("parameter integrationRuntimeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeName}", url.PathEscape(integrationRuntimeName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -427,7 +416,7 @@ func (client *IntegrationRuntimesClient) NewListByWorkspacePager(resourceGroupNa if err != nil { return IntegrationRuntimesClientListByWorkspaceResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationRuntimesClientListByWorkspaceResponse{}, err } @@ -454,7 +443,7 @@ func (client *IntegrationRuntimesClient) listByWorkspaceCreateRequest(ctx contex return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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,7 +478,7 @@ func (client *IntegrationRuntimesClient) ListOutboundNetworkDependenciesEndpoint if err != nil { return IntegrationRuntimesClientListOutboundNetworkDependenciesEndpointsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationRuntimesClientListOutboundNetworkDependenciesEndpointsResponse{}, err } @@ -518,7 +507,7 @@ func (client *IntegrationRuntimesClient) listOutboundNetworkDependenciesEndpoint return nil, errors.New("parameter integrationRuntimeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeName}", url.PathEscape(integrationRuntimeName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -553,11 +542,11 @@ func (client *IntegrationRuntimesClient) BeginStart(ctx context.Context, resourc if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[IntegrationRuntimesClientStartResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[IntegrationRuntimesClientStartResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[IntegrationRuntimesClientStartResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[IntegrationRuntimesClientStartResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -570,7 +559,7 @@ func (client *IntegrationRuntimesClient) start(ctx context.Context, resourceGrou 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 } @@ -599,7 +588,7 @@ func (client *IntegrationRuntimesClient) startCreateRequest(ctx context.Context, return nil, errors.New("parameter integrationRuntimeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeName}", url.PathEscape(integrationRuntimeName)) - 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 } @@ -625,9 +614,9 @@ func (client *IntegrationRuntimesClient) BeginStop(ctx context.Context, resource if err != nil { return nil, err } - return runtime.NewPoller[IntegrationRuntimesClientStopResponse](resp, client.pl, nil) + return runtime.NewPoller[IntegrationRuntimesClientStopResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[IntegrationRuntimesClientStopResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[IntegrationRuntimesClientStopResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -640,7 +629,7 @@ func (client *IntegrationRuntimesClient) stop(ctx context.Context, resourceGroup 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 } @@ -669,7 +658,7 @@ func (client *IntegrationRuntimesClient) stopCreateRequest(ctx context.Context, return nil, errors.New("parameter integrationRuntimeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeName}", url.PathEscape(integrationRuntimeName)) - 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 } @@ -695,7 +684,7 @@ func (client *IntegrationRuntimesClient) Update(ctx context.Context, resourceGro if err != nil { return IntegrationRuntimesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationRuntimesClientUpdateResponse{}, err } @@ -724,7 +713,7 @@ func (client *IntegrationRuntimesClient) updateCreateRequest(ctx context.Context return nil, errors.New("parameter integrationRuntimeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeName}", url.PathEscape(integrationRuntimeName)) - 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 } @@ -758,7 +747,7 @@ func (client *IntegrationRuntimesClient) Upgrade(ctx context.Context, resourceGr if err != nil { return IntegrationRuntimesClientUpgradeResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationRuntimesClientUpgradeResponse{}, err } @@ -787,7 +776,7 @@ func (client *IntegrationRuntimesClient) upgradeCreateRequest(ctx context.Contex return nil, errors.New("parameter integrationRuntimeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeName}", url.PathEscape(integrationRuntimeName)) - 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/synapse/armsynapse/integrationruntimes_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/integrationruntimes_client_example_test.go index aaad98d237ad..cca588403484 100644 --- a/sdk/resourcemanager/synapse/armsynapse/integrationruntimes_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/integrationruntimes_client_example_test.go @@ -25,11 +25,11 @@ func ExampleIntegrationRuntimesClient_Update() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimesClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", armsynapse.UpdateIntegrationRuntimeRequest{ + res, err := clientFactory.NewIntegrationRuntimesClient().Update(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", armsynapse.UpdateIntegrationRuntimeRequest{ AutoUpdate: to.Ptr(armsynapse.IntegrationRuntimeAutoUpdateOff), UpdateDelayOffset: to.Ptr("\"PT3H\""), }, nil) @@ -58,11 +58,11 @@ func ExampleIntegrationRuntimesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimesClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", &armsynapse.IntegrationRuntimesClientGetOptions{IfNoneMatch: nil}) + res, err := clientFactory.NewIntegrationRuntimesClient().Get(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", &armsynapse.IntegrationRuntimesClientGetOptions{IfNoneMatch: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -88,11 +88,11 @@ func ExampleIntegrationRuntimesClient_BeginCreate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimesClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", armsynapse.IntegrationRuntimeResource{ + poller, err := clientFactory.NewIntegrationRuntimesClient().BeginCreate(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", armsynapse.IntegrationRuntimeResource{ Properties: &armsynapse.SelfHostedIntegrationRuntime{ Type: to.Ptr(armsynapse.IntegrationRuntimeTypeSelfHosted), Description: to.Ptr("A selfhosted integration runtime"), @@ -127,11 +127,11 @@ func ExampleIntegrationRuntimesClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimesClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", nil) + poller, err := clientFactory.NewIntegrationRuntimesClient().BeginDelete(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -148,11 +148,11 @@ func ExampleIntegrationRuntimesClient_Upgrade() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimesClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Upgrade(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", nil) + _, err = clientFactory.NewIntegrationRuntimesClient().Upgrade(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -165,11 +165,11 @@ func ExampleIntegrationRuntimesClient_NewListByWorkspacePager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimesClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByWorkspacePager("exampleResourceGroup", "exampleWorkspace", nil) + pager := clientFactory.NewIntegrationRuntimesClient().NewListByWorkspacePager("exampleResourceGroup", "exampleWorkspace", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -203,11 +203,11 @@ func ExampleIntegrationRuntimesClient_BeginStart() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimesClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginStart(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleManagedIntegrationRuntime", nil) + poller, err := clientFactory.NewIntegrationRuntimesClient().BeginStart(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleManagedIntegrationRuntime", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -242,11 +242,11 @@ func ExampleIntegrationRuntimesClient_BeginStop() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimesClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginStop(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleManagedIntegrationRuntime", nil) + poller, err := clientFactory.NewIntegrationRuntimesClient().BeginStop(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleManagedIntegrationRuntime", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -263,11 +263,11 @@ func ExampleIntegrationRuntimesClient_ListOutboundNetworkDependenciesEndpoints() log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimesClient("ade9c2b6-c160-4305-9bb9-80342f6c1ae2", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.ListOutboundNetworkDependenciesEndpoints(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", nil) + res, err := clientFactory.NewIntegrationRuntimesClient().ListOutboundNetworkDependenciesEndpoints(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -351,11 +351,11 @@ func ExampleIntegrationRuntimesClient_BeginEnableInteractiveQuery() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimesClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginEnableInteractiveQuery(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleManagedIntegrationRuntime", nil) + poller, err := clientFactory.NewIntegrationRuntimesClient().BeginEnableInteractiveQuery(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleManagedIntegrationRuntime", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -372,11 +372,11 @@ func ExampleIntegrationRuntimesClient_BeginDisableInteractiveQuery() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimesClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDisableInteractiveQuery(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleManagedIntegrationRuntime", nil) + poller, err := clientFactory.NewIntegrationRuntimesClient().BeginDisableInteractiveQuery(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleManagedIntegrationRuntime", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/integrationruntimestatus_client.go b/sdk/resourcemanager/synapse/armsynapse/integrationruntimestatus_client.go index 490c73ab48d9..18accfc1c2bb 100644 --- a/sdk/resourcemanager/synapse/armsynapse/integrationruntimestatus_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/integrationruntimestatus_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // IntegrationRuntimeStatusClient contains the methods for the IntegrationRuntimeStatus group. // Don't use this type directly, use NewIntegrationRuntimeStatusClient() instead. type IntegrationRuntimeStatusClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewIntegrationRuntimeStatusClient creates a new instance of IntegrationRuntimeStatusClient with the specified values. @@ -36,21 +33,13 @@ type IntegrationRuntimeStatusClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationRuntimeStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationRuntimeStatusClient, 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+".IntegrationRuntimeStatusClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &IntegrationRuntimeStatusClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -69,7 +58,7 @@ func (client *IntegrationRuntimeStatusClient) Get(ctx context.Context, resourceG if err != nil { return IntegrationRuntimeStatusClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationRuntimeStatusClientGetResponse{}, err } @@ -98,7 +87,7 @@ func (client *IntegrationRuntimeStatusClient) getCreateRequest(ctx context.Conte return nil, errors.New("parameter integrationRuntimeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{integrationRuntimeName}", url.PathEscape(integrationRuntimeName)) - 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/synapse/armsynapse/integrationruntimestatus_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/integrationruntimestatus_client_example_test.go index 9a48bf015f39..2aafabe2cacc 100644 --- a/sdk/resourcemanager/synapse/armsynapse/integrationruntimestatus_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/integrationruntimestatus_client_example_test.go @@ -24,11 +24,11 @@ func ExampleIntegrationRuntimeStatusClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIntegrationRuntimeStatusClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", nil) + res, err := clientFactory.NewIntegrationRuntimeStatusClient().Get(ctx, "exampleResourceGroup", "exampleWorkspace", "exampleIntegrationRuntime", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/ipfirewallrules_client.go b/sdk/resourcemanager/synapse/armsynapse/ipfirewallrules_client.go index 1a7af54158a9..6640432251d0 100644 --- a/sdk/resourcemanager/synapse/armsynapse/ipfirewallrules_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/ipfirewallrules_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // IPFirewallRulesClient contains the methods for the IPFirewallRules group. // Don't use this type directly, use NewIPFirewallRulesClient() instead. type IPFirewallRulesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewIPFirewallRulesClient creates a new instance of IPFirewallRulesClient with the specified values. @@ -36,21 +33,13 @@ type IPFirewallRulesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIPFirewallRulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IPFirewallRulesClient, 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+".IPFirewallRulesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &IPFirewallRulesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,11 +60,11 @@ func (client *IPFirewallRulesClient) BeginCreateOrUpdate(ctx context.Context, re if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[IPFirewallRulesClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[IPFirewallRulesClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[IPFirewallRulesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[IPFirewallRulesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -88,7 +77,7 @@ func (client *IPFirewallRulesClient) createOrUpdate(ctx context.Context, resourc 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 +106,7 @@ func (client *IPFirewallRulesClient) createOrUpdateCreateRequest(ctx context.Con return nil, errors.New("parameter ruleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) - 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 } @@ -143,11 +132,11 @@ func (client *IPFirewallRulesClient) BeginDelete(ctx context.Context, resourceGr if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[IPFirewallRulesClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[IPFirewallRulesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[IPFirewallRulesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[IPFirewallRulesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -160,7 +149,7 @@ func (client *IPFirewallRulesClient) deleteOperation(ctx context.Context, resour 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 +178,7 @@ func (client *IPFirewallRulesClient) deleteCreateRequest(ctx context.Context, re return nil, errors.New("parameter ruleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) - 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 } @@ -213,7 +202,7 @@ func (client *IPFirewallRulesClient) Get(ctx context.Context, resourceGroupName if err != nil { return IPFirewallRulesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IPFirewallRulesClientGetResponse{}, err } @@ -242,7 +231,7 @@ func (client *IPFirewallRulesClient) getCreateRequest(ctx context.Context, resou return nil, errors.New("parameter ruleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -285,7 +274,7 @@ func (client *IPFirewallRulesClient) NewListByWorkspacePager(resourceGroupName s if err != nil { return IPFirewallRulesClientListByWorkspaceResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return IPFirewallRulesClientListByWorkspaceResponse{}, err } @@ -312,7 +301,7 @@ func (client *IPFirewallRulesClient) listByWorkspaceCreateRequest(ctx context.Co return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -347,11 +336,11 @@ func (client *IPFirewallRulesClient) BeginReplaceAll(ctx context.Context, resour if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[IPFirewallRulesClientReplaceAllResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[IPFirewallRulesClientReplaceAllResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[IPFirewallRulesClientReplaceAllResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[IPFirewallRulesClientReplaceAllResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -364,7 +353,7 @@ func (client *IPFirewallRulesClient) replaceAll(ctx context.Context, resourceGro 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 } @@ -389,7 +378,7 @@ func (client *IPFirewallRulesClient) replaceAllCreateRequest(ctx context.Context return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - 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/synapse/armsynapse/ipfirewallrules_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/ipfirewallrules_client_example_test.go index 75758143e47d..f8c13e2d311b 100644 --- a/sdk/resourcemanager/synapse/armsynapse/ipfirewallrules_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/ipfirewallrules_client_example_test.go @@ -25,11 +25,11 @@ func ExampleIPFirewallRulesClient_NewListByWorkspacePager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIPFirewallRulesClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByWorkspacePager("ExampleResourceGroup", "ExampleWorkspace", nil) + pager := clientFactory.NewIPFirewallRulesClient().NewListByWorkspacePager("ExampleResourceGroup", "ExampleWorkspace", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -54,11 +54,11 @@ func ExampleIPFirewallRulesClient_BeginCreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIPFirewallRulesClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExampleIpFirewallRule", armsynapse.IPFirewallRuleInfo{ + poller, err := clientFactory.NewIPFirewallRulesClient().BeginCreateOrUpdate(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExampleIpFirewallRule", armsynapse.IPFirewallRuleInfo{ Properties: &armsynapse.IPFirewallRuleProperties{ EndIPAddress: to.Ptr("10.0.0.254"), StartIPAddress: to.Ptr("10.0.0.0"), @@ -93,11 +93,11 @@ func ExampleIPFirewallRulesClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIPFirewallRulesClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExampleIpFirewallRule", nil) + poller, err := clientFactory.NewIPFirewallRulesClient().BeginDelete(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExampleIpFirewallRule", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -127,11 +127,11 @@ func ExampleIPFirewallRulesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIPFirewallRulesClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExampleIpFirewallRule", nil) + res, err := clientFactory.NewIPFirewallRulesClient().Get(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExampleIpFirewallRule", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -157,11 +157,11 @@ func ExampleIPFirewallRulesClient_BeginReplaceAll() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewIPFirewallRulesClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginReplaceAll(ctx, "ExampleResourceGroup", "ExampleWorkspace", armsynapse.ReplaceAllIPFirewallRulesRequest{ + poller, err := clientFactory.NewIPFirewallRulesClient().BeginReplaceAll(ctx, "ExampleResourceGroup", "ExampleWorkspace", armsynapse.ReplaceAllIPFirewallRulesRequest{ IPFirewallRules: map[string]*armsynapse.IPFirewallRuleProperties{ "AnotherExampleFirewallRule": { EndIPAddress: to.Ptr("10.0.1.254"), diff --git a/sdk/resourcemanager/synapse/armsynapse/keys_client.go b/sdk/resourcemanager/synapse/armsynapse/keys_client.go index bc2dbd4dd2b8..6eddfa1d218d 100644 --- a/sdk/resourcemanager/synapse/armsynapse/keys_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/keys_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // KeysClient contains the methods for the Keys group. // Don't use this type directly, use NewKeysClient() instead. type KeysClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewKeysClient creates a new instance of KeysClient with the specified values. @@ -36,21 +33,13 @@ type KeysClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewKeysClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*KeysClient, 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+".KeysClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &KeysClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -69,7 +58,7 @@ func (client *KeysClient) CreateOrUpdate(ctx context.Context, resourceGroupName if err != nil { return KeysClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KeysClientCreateOrUpdateResponse{}, err } @@ -98,7 +87,7 @@ func (client *KeysClient) createOrUpdateCreateRequest(ctx context.Context, resou return nil, errors.New("parameter keyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{keyName}", url.PathEscape(keyName)) - 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,7 +120,7 @@ func (client *KeysClient) Delete(ctx context.Context, resourceGroupName string, if err != nil { return KeysClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KeysClientDeleteResponse{}, err } @@ -160,7 +149,7 @@ func (client *KeysClient) deleteCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter keyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{keyName}", url.PathEscape(keyName)) - 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,7 +182,7 @@ func (client *KeysClient) Get(ctx context.Context, resourceGroupName string, wor if err != nil { return KeysClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KeysClientGetResponse{}, err } @@ -222,7 +211,7 @@ func (client *KeysClient) getCreateRequest(ctx context.Context, resourceGroupNam return nil, errors.New("parameter keyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{keyName}", url.PathEscape(keyName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -265,7 +254,7 @@ func (client *KeysClient) NewListByWorkspacePager(resourceGroupName string, work if err != nil { return KeysClientListByWorkspaceResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KeysClientListByWorkspaceResponse{}, err } @@ -292,7 +281,7 @@ func (client *KeysClient) listByWorkspaceCreateRequest(ctx context.Context, reso return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/keys_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/keys_client_example_test.go index c86526122d8a..bb2358709b7e 100644 --- a/sdk/resourcemanager/synapse/armsynapse/keys_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/keys_client_example_test.go @@ -25,11 +25,11 @@ func ExampleKeysClient_NewListByWorkspacePager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKeysClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByWorkspacePager("ExampleResourceGroup", "ExampleWorkspace", nil) + pager := clientFactory.NewKeysClient().NewListByWorkspacePager("ExampleResourceGroup", "ExampleWorkspace", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -71,11 +71,11 @@ func ExampleKeysClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKeysClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "ExampleResourceGroup", "ExampleWorkspace", "somekey", nil) + res, err := clientFactory.NewKeysClient().Get(ctx, "ExampleResourceGroup", "ExampleWorkspace", "somekey", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -100,11 +100,11 @@ func ExampleKeysClient_CreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKeysClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "ExampleResourceGroup", "ExampleWorkspace", "somekey", armsynapse.Key{ + res, err := clientFactory.NewKeysClient().CreateOrUpdate(ctx, "ExampleResourceGroup", "ExampleWorkspace", "somekey", armsynapse.Key{ Properties: &armsynapse.KeyProperties{ IsActiveCMK: to.Ptr(true), KeyVaultURL: to.Ptr("https://vault.azure.net/keys/somesecret"), @@ -134,11 +134,11 @@ func ExampleKeysClient_Delete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKeysClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Delete(ctx, "ExampleResourceGroup", "ExampleWorkspace", "somekey", nil) + res, err := clientFactory.NewKeysClient().Delete(ctx, "ExampleResourceGroup", "ExampleWorkspace", "somekey", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/kustooperations_client.go b/sdk/resourcemanager/synapse/armsynapse/kustooperations_client.go index a3aeb29d6c0d..c66a178da3f0 100644 --- a/sdk/resourcemanager/synapse/armsynapse/kustooperations_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/kustooperations_client.go @@ -13,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -23,28 +21,19 @@ import ( // KustoOperationsClient contains the methods for the KustoOperations group. // Don't use this type directly, use NewKustoOperationsClient() instead. type KustoOperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewKustoOperationsClient creates a new instance of KustoOperationsClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewKustoOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*KustoOperationsClient, 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+".KustoOperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &KustoOperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,7 +59,7 @@ func (client *KustoOperationsClient) NewListPager(options *KustoOperationsClient if err != nil { return KustoOperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoOperationsClientListResponse{}, err } @@ -85,7 +74,7 @@ func (client *KustoOperationsClient) NewListPager(options *KustoOperationsClient // listCreateRequest creates the List request. func (client *KustoOperationsClient) listCreateRequest(ctx context.Context, options *KustoOperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Synapse/kustooperations" - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/kustooperations_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/kustooperations_client_example_test.go index fd45e8f7ce30..1aa98350523a 100644 --- a/sdk/resourcemanager/synapse/armsynapse/kustooperations_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/kustooperations_client_example_test.go @@ -24,11 +24,11 @@ func ExampleKustoOperationsClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoOperationsClient(cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewKustoOperationsClient().NewListPager(nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/kustopoolattacheddatabaseconfigurations_client.go b/sdk/resourcemanager/synapse/armsynapse/kustopoolattacheddatabaseconfigurations_client.go index 6423125fc7bf..f2e76f6c0451 100644 --- a/sdk/resourcemanager/synapse/armsynapse/kustopoolattacheddatabaseconfigurations_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/kustopoolattacheddatabaseconfigurations_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // KustoPoolAttachedDatabaseConfigurationsClient contains the methods for the KustoPoolAttachedDatabaseConfigurations group. // Don't use this type directly, use NewKustoPoolAttachedDatabaseConfigurationsClient() instead. type KustoPoolAttachedDatabaseConfigurationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewKustoPoolAttachedDatabaseConfigurationsClient creates a new instance of KustoPoolAttachedDatabaseConfigurationsClient with the specified values. @@ -36,21 +33,13 @@ type KustoPoolAttachedDatabaseConfigurationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewKustoPoolAttachedDatabaseConfigurationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*KustoPoolAttachedDatabaseConfigurationsClient, 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+".KustoPoolAttachedDatabaseConfigurationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &KustoPoolAttachedDatabaseConfigurationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -72,9 +61,9 @@ func (client *KustoPoolAttachedDatabaseConfigurationsClient) BeginCreateOrUpdate if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolAttachedDatabaseConfigurationsClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolAttachedDatabaseConfigurationsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolAttachedDatabaseConfigurationsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolAttachedDatabaseConfigurationsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -87,7 +76,7 @@ func (client *KustoPoolAttachedDatabaseConfigurationsClient) createOrUpdate(ctx 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 } @@ -120,7 +109,7 @@ func (client *KustoPoolAttachedDatabaseConfigurationsClient) createOrUpdateCreat 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 } @@ -147,9 +136,9 @@ func (client *KustoPoolAttachedDatabaseConfigurationsClient) BeginDelete(ctx con if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolAttachedDatabaseConfigurationsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolAttachedDatabaseConfigurationsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolAttachedDatabaseConfigurationsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolAttachedDatabaseConfigurationsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -162,7 +151,7 @@ func (client *KustoPoolAttachedDatabaseConfigurationsClient) deleteOperation(ctx 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 } @@ -195,7 +184,7 @@ func (client *KustoPoolAttachedDatabaseConfigurationsClient) deleteCreateRequest 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 } @@ -221,7 +210,7 @@ func (client *KustoPoolAttachedDatabaseConfigurationsClient) Get(ctx context.Con if err != nil { return KustoPoolAttachedDatabaseConfigurationsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolAttachedDatabaseConfigurationsClientGetResponse{}, err } @@ -254,7 +243,7 @@ func (client *KustoPoolAttachedDatabaseConfigurationsClient) getCreateRequest(ct return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -292,7 +281,7 @@ func (client *KustoPoolAttachedDatabaseConfigurationsClient) NewListByKustoPoolP if err != nil { return KustoPoolAttachedDatabaseConfigurationsClientListByKustoPoolResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolAttachedDatabaseConfigurationsClientListByKustoPoolResponse{}, err } @@ -323,7 +312,7 @@ func (client *KustoPoolAttachedDatabaseConfigurationsClient) listByKustoPoolCrea 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 } diff --git a/sdk/resourcemanager/synapse/armsynapse/kustopoolattacheddatabaseconfigurations_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/kustopoolattacheddatabaseconfigurations_client_example_test.go index d1f75d7ec57e..8461faedc62f 100644 --- a/sdk/resourcemanager/synapse/armsynapse/kustopoolattacheddatabaseconfigurations_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/kustopoolattacheddatabaseconfigurations_client_example_test.go @@ -25,11 +25,11 @@ func ExampleKustoPoolAttachedDatabaseConfigurationsClient_NewListByKustoPoolPage log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolAttachedDatabaseConfigurationsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByKustoPoolPager("kustorptest", "kustoclusterrptest4", "kustorptest", nil) + pager := clientFactory.NewKustoPoolAttachedDatabaseConfigurationsClient().NewListByKustoPoolPager("kustorptest", "kustoclusterrptest4", "kustorptest", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -91,11 +91,11 @@ func ExampleKustoPoolAttachedDatabaseConfigurationsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolAttachedDatabaseConfigurationsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "kustorptest", "kustoclusterrptest4", "attachedDatabaseConfigurations1", "kustorptest", nil) + res, err := clientFactory.NewKustoPoolAttachedDatabaseConfigurationsClient().Get(ctx, "kustorptest", "kustoclusterrptest4", "attachedDatabaseConfigurations1", "kustorptest", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -137,11 +137,11 @@ func ExampleKustoPoolAttachedDatabaseConfigurationsClient_BeginCreateOrUpdate() log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolAttachedDatabaseConfigurationsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "kustorptest", "kustoclusterrptest4", "attachedDatabaseConfigurations1", "kustorptest", armsynapse.AttachedDatabaseConfiguration{ + poller, err := clientFactory.NewKustoPoolAttachedDatabaseConfigurationsClient().BeginCreateOrUpdate(ctx, "kustorptest", "kustoclusterrptest4", "attachedDatabaseConfigurations1", "kustorptest", armsynapse.AttachedDatabaseConfiguration{ Location: to.Ptr("westus"), Properties: &armsynapse.AttachedDatabaseConfigurationProperties{ KustoPoolResourceID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Synapse/Workspaces/kustorptest/KustoPools/kustoclusterrptest4"), @@ -208,11 +208,11 @@ func ExampleKustoPoolAttachedDatabaseConfigurationsClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolAttachedDatabaseConfigurationsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "kustorptest", "kustoclusterrptest4", "attachedDatabaseConfigurations1", "kustorptest", nil) + poller, err := clientFactory.NewKustoPoolAttachedDatabaseConfigurationsClient().BeginDelete(ctx, "kustorptest", "kustoclusterrptest4", "attachedDatabaseConfigurations1", "kustorptest", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/kustopoolchildresource_client.go b/sdk/resourcemanager/synapse/armsynapse/kustopoolchildresource_client.go index 19ba511da99d..095b3a6cb698 100644 --- a/sdk/resourcemanager/synapse/armsynapse/kustopoolchildresource_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/kustopoolchildresource_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // KustoPoolChildResourceClient contains the methods for the KustoPoolChildResource group. // Don't use this type directly, use NewKustoPoolChildResourceClient() instead. type KustoPoolChildResourceClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewKustoPoolChildResourceClient creates a new instance of KustoPoolChildResourceClient with the specified values. @@ -36,21 +33,13 @@ type KustoPoolChildResourceClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewKustoPoolChildResourceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*KustoPoolChildResourceClient, 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+".KustoPoolChildResourceClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &KustoPoolChildResourceClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,7 +59,7 @@ func (client *KustoPoolChildResourceClient) CheckNameAvailability(ctx context.Co if err != nil { return KustoPoolChildResourceClientCheckNameAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolChildResourceClientCheckNameAvailabilityResponse{}, err } @@ -99,7 +88,7 @@ func (client *KustoPoolChildResourceClient) checkNameAvailabilityCreateRequest(c 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 } diff --git a/sdk/resourcemanager/synapse/armsynapse/kustopoolchildresource_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/kustopoolchildresource_client_example_test.go index 47eb9e2df157..0ed3e8be4fe5 100644 --- a/sdk/resourcemanager/synapse/armsynapse/kustopoolchildresource_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/kustopoolchildresource_client_example_test.go @@ -25,11 +25,11 @@ func ExampleKustoPoolChildResourceClient_CheckNameAvailability_kustoPoolAttached log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolChildResourceClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CheckNameAvailability(ctx, "kustorptest", "kustoclusterrptest4", "kustorptest", armsynapse.DatabaseCheckNameRequest{ + res, err := clientFactory.NewKustoPoolChildResourceClient().CheckNameAvailability(ctx, "kustorptest", "kustoclusterrptest4", "kustorptest", armsynapse.DatabaseCheckNameRequest{ Name: to.Ptr("adc1"), Type: to.Ptr(armsynapse.TypeMicrosoftSynapseWorkspacesKustoPoolsAttachedDatabaseConfigurations), }, nil) @@ -53,11 +53,11 @@ func ExampleKustoPoolChildResourceClient_CheckNameAvailability_kustoPoolDatabase log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolChildResourceClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CheckNameAvailability(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "kustorptest", armsynapse.DatabaseCheckNameRequest{ + res, err := clientFactory.NewKustoPoolChildResourceClient().CheckNameAvailability(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "kustorptest", armsynapse.DatabaseCheckNameRequest{ Name: to.Ptr("database1"), Type: to.Ptr(armsynapse.TypeMicrosoftSynapseWorkspacesKustoPoolsDatabases), }, nil) diff --git a/sdk/resourcemanager/synapse/armsynapse/kustopooldatabaseprincipalassignments_client.go b/sdk/resourcemanager/synapse/armsynapse/kustopooldatabaseprincipalassignments_client.go index 64822f61ec79..923a29c62a0f 100644 --- a/sdk/resourcemanager/synapse/armsynapse/kustopooldatabaseprincipalassignments_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/kustopooldatabaseprincipalassignments_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // KustoPoolDatabasePrincipalAssignmentsClient contains the methods for the KustoPoolDatabasePrincipalAssignments group. // Don't use this type directly, use NewKustoPoolDatabasePrincipalAssignmentsClient() instead. type KustoPoolDatabasePrincipalAssignmentsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewKustoPoolDatabasePrincipalAssignmentsClient creates a new instance of KustoPoolDatabasePrincipalAssignmentsClient with the specified values. @@ -36,21 +33,13 @@ type KustoPoolDatabasePrincipalAssignmentsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewKustoPoolDatabasePrincipalAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*KustoPoolDatabasePrincipalAssignmentsClient, 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+".KustoPoolDatabasePrincipalAssignmentsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &KustoPoolDatabasePrincipalAssignmentsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,7 +60,7 @@ func (client *KustoPoolDatabasePrincipalAssignmentsClient) CheckNameAvailability if err != nil { return KustoPoolDatabasePrincipalAssignmentsClientCheckNameAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolDatabasePrincipalAssignmentsClientCheckNameAvailabilityResponse{}, err } @@ -104,7 +93,7 @@ func (client *KustoPoolDatabasePrincipalAssignmentsClient) checkNameAvailability 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 } @@ -142,9 +131,9 @@ func (client *KustoPoolDatabasePrincipalAssignmentsClient) BeginCreateOrUpdate(c if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolDatabasePrincipalAssignmentsClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolDatabasePrincipalAssignmentsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolDatabasePrincipalAssignmentsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolDatabasePrincipalAssignmentsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -157,7 +146,7 @@ func (client *KustoPoolDatabasePrincipalAssignmentsClient) createOrUpdate(ctx co 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 } @@ -194,7 +183,7 @@ func (client *KustoPoolDatabasePrincipalAssignmentsClient) createOrUpdateCreateR 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 } @@ -222,9 +211,9 @@ func (client *KustoPoolDatabasePrincipalAssignmentsClient) BeginDelete(ctx conte if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolDatabasePrincipalAssignmentsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolDatabasePrincipalAssignmentsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolDatabasePrincipalAssignmentsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolDatabasePrincipalAssignmentsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -237,7 +226,7 @@ func (client *KustoPoolDatabasePrincipalAssignmentsClient) deleteOperation(ctx c 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 } @@ -274,7 +263,7 @@ func (client *KustoPoolDatabasePrincipalAssignmentsClient) deleteCreateRequest(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 } @@ -301,7 +290,7 @@ func (client *KustoPoolDatabasePrincipalAssignmentsClient) Get(ctx context.Conte if err != nil { return KustoPoolDatabasePrincipalAssignmentsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolDatabasePrincipalAssignmentsClientGetResponse{}, err } @@ -338,7 +327,7 @@ func (client *KustoPoolDatabasePrincipalAssignmentsClient) getCreateRequest(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 } @@ -377,7 +366,7 @@ func (client *KustoPoolDatabasePrincipalAssignmentsClient) NewListPager(workspac if err != nil { return KustoPoolDatabasePrincipalAssignmentsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolDatabasePrincipalAssignmentsClientListResponse{}, err } @@ -412,7 +401,7 @@ func (client *KustoPoolDatabasePrincipalAssignmentsClient) listCreateRequest(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 } diff --git a/sdk/resourcemanager/synapse/armsynapse/kustopooldatabaseprincipalassignments_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/kustopooldatabaseprincipalassignments_client_example_test.go index 7ea18f40b0d4..6d91029c2523 100644 --- a/sdk/resourcemanager/synapse/armsynapse/kustopooldatabaseprincipalassignments_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/kustopooldatabaseprincipalassignments_client_example_test.go @@ -25,11 +25,11 @@ func ExampleKustoPoolDatabasePrincipalAssignmentsClient_CheckNameAvailability() log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolDatabasePrincipalAssignmentsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CheckNameAvailability(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "Kustodatabase8", "kustorptest", armsynapse.DatabasePrincipalAssignmentCheckNameRequest{ + res, err := clientFactory.NewKustoPoolDatabasePrincipalAssignmentsClient().CheckNameAvailability(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "Kustodatabase8", "kustorptest", armsynapse.DatabasePrincipalAssignmentCheckNameRequest{ Name: to.Ptr("kustoprincipal1"), Type: to.Ptr("Microsoft.Synapse/workspaces/kustoPools/databases/principalAssignments"), }, nil) @@ -53,11 +53,11 @@ func ExampleKustoPoolDatabasePrincipalAssignmentsClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolDatabasePrincipalAssignmentsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("synapseWorkspaceName", "kustoclusterrptest4", "Kustodatabase8", "kustorptest", nil) + pager := clientFactory.NewKustoPoolDatabasePrincipalAssignmentsClient().NewListPager("synapseWorkspaceName", "kustoclusterrptest4", "Kustodatabase8", "kustorptest", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -111,11 +111,11 @@ func ExampleKustoPoolDatabasePrincipalAssignmentsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolDatabasePrincipalAssignmentsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "Kustodatabase8", "kustoprincipal1", "kustorptest", nil) + res, err := clientFactory.NewKustoPoolDatabasePrincipalAssignmentsClient().Get(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "Kustodatabase8", "kustoprincipal1", "kustorptest", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -146,11 +146,11 @@ func ExampleKustoPoolDatabasePrincipalAssignmentsClient_BeginCreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolDatabasePrincipalAssignmentsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "Kustodatabase8", "kustoprincipal1", "kustorptest", armsynapse.DatabasePrincipalAssignment{ + poller, err := clientFactory.NewKustoPoolDatabasePrincipalAssignmentsClient().BeginCreateOrUpdate(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "Kustodatabase8", "kustoprincipal1", "kustorptest", armsynapse.DatabasePrincipalAssignment{ Properties: &armsynapse.DatabasePrincipalProperties{ PrincipalID: to.Ptr("87654321-1234-1234-1234-123456789123"), PrincipalType: to.Ptr(armsynapse.PrincipalTypeApp), @@ -192,11 +192,11 @@ func ExampleKustoPoolDatabasePrincipalAssignmentsClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolDatabasePrincipalAssignmentsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "Kustodatabase8", "kustoprincipal1", "kustorptest", nil) + poller, err := clientFactory.NewKustoPoolDatabasePrincipalAssignmentsClient().BeginDelete(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "Kustodatabase8", "kustoprincipal1", "kustorptest", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/kustopooldatabases_client.go b/sdk/resourcemanager/synapse/armsynapse/kustopooldatabases_client.go index 3fa6b8dcffc7..bf3a12b8adb8 100644 --- a/sdk/resourcemanager/synapse/armsynapse/kustopooldatabases_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/kustopooldatabases_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // KustoPoolDatabasesClient contains the methods for the KustoPoolDatabases group. // Don't use this type directly, use NewKustoPoolDatabasesClient() instead. type KustoPoolDatabasesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewKustoPoolDatabasesClient creates a new instance of KustoPoolDatabasesClient with the specified values. @@ -36,21 +33,13 @@ type KustoPoolDatabasesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewKustoPoolDatabasesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*KustoPoolDatabasesClient, 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+".KustoPoolDatabasesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &KustoPoolDatabasesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -72,9 +61,9 @@ func (client *KustoPoolDatabasesClient) BeginCreateOrUpdate(ctx context.Context, if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolDatabasesClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolDatabasesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolDatabasesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolDatabasesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -87,7 +76,7 @@ func (client *KustoPoolDatabasesClient) createOrUpdate(ctx context.Context, reso 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 } @@ -120,7 +109,7 @@ func (client *KustoPoolDatabasesClient) createOrUpdateCreateRequest(ctx context. return nil, errors.New("parameter databaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -147,9 +136,9 @@ func (client *KustoPoolDatabasesClient) BeginDelete(ctx context.Context, resourc if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolDatabasesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolDatabasesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolDatabasesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolDatabasesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -162,7 +151,7 @@ func (client *KustoPoolDatabasesClient) deleteOperation(ctx context.Context, res 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 } @@ -195,7 +184,7 @@ func (client *KustoPoolDatabasesClient) deleteCreateRequest(ctx context.Context, return nil, errors.New("parameter databaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) - req, err := runtime.NewRequest(ctx, http.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 } @@ -220,7 +209,7 @@ func (client *KustoPoolDatabasesClient) Get(ctx context.Context, resourceGroupNa if err != nil { return KustoPoolDatabasesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolDatabasesClientGetResponse{}, err } @@ -253,7 +242,7 @@ func (client *KustoPoolDatabasesClient) getCreateRequest(ctx context.Context, re return nil, errors.New("parameter databaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -291,7 +280,7 @@ func (client *KustoPoolDatabasesClient) NewListByKustoPoolPager(resourceGroupNam if err != nil { return KustoPoolDatabasesClientListByKustoPoolResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolDatabasesClientListByKustoPoolResponse{}, err } @@ -322,7 +311,7 @@ func (client *KustoPoolDatabasesClient) listByKustoPoolCreateRequest(ctx context return nil, errors.New("parameter kustoPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{kustoPoolName}", url.PathEscape(kustoPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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,9 +348,9 @@ func (client *KustoPoolDatabasesClient) BeginUpdate(ctx context.Context, resourc if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolDatabasesClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolDatabasesClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolDatabasesClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolDatabasesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -374,7 +363,7 @@ func (client *KustoPoolDatabasesClient) update(ctx context.Context, resourceGrou 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 } @@ -407,7 +396,7 @@ func (client *KustoPoolDatabasesClient) updateCreateRequest(ctx context.Context, return nil, errors.New("parameter databaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) - req, err := runtime.NewRequest(ctx, http.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/synapse/armsynapse/kustopooldatabases_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/kustopooldatabases_client_example_test.go index 80b6abda3887..e5ad4ef83450 100644 --- a/sdk/resourcemanager/synapse/armsynapse/kustopooldatabases_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/kustopooldatabases_client_example_test.go @@ -25,11 +25,11 @@ func ExampleKustoPoolDatabasesClient_NewListByKustoPoolPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolDatabasesClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByKustoPoolPager("kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", nil) + pager := clientFactory.NewKustoPoolDatabasesClient().NewListByKustoPoolPager("kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -75,11 +75,11 @@ func ExampleKustoPoolDatabasesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolDatabasesClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "KustoDatabase8", nil) + res, err := clientFactory.NewKustoPoolDatabasesClient().Get(ctx, "kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "KustoDatabase8", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -108,11 +108,11 @@ func ExampleKustoPoolDatabasesClient_BeginCreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolDatabasesClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "KustoDatabase8", &armsynapse.ReadWriteDatabase{ + poller, err := clientFactory.NewKustoPoolDatabasesClient().BeginCreateOrUpdate(ctx, "kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "KustoDatabase8", &armsynapse.ReadWriteDatabase{ Kind: to.Ptr(armsynapse.KindReadWrite), Location: to.Ptr("westus"), Properties: &armsynapse.ReadWriteDatabaseProperties{ @@ -151,11 +151,11 @@ func ExampleKustoPoolDatabasesClient_BeginUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolDatabasesClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "KustoDatabase8", &armsynapse.ReadWriteDatabase{ + poller, err := clientFactory.NewKustoPoolDatabasesClient().BeginUpdate(ctx, "kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "KustoDatabase8", &armsynapse.ReadWriteDatabase{ Kind: to.Ptr(armsynapse.KindReadWrite), Properties: &armsynapse.ReadWriteDatabaseProperties{ SoftDeletePeriod: to.Ptr("P1D"), @@ -193,11 +193,11 @@ func ExampleKustoPoolDatabasesClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolDatabasesClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "KustoDatabase8", nil) + poller, err := clientFactory.NewKustoPoolDatabasesClient().BeginDelete(ctx, "kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "KustoDatabase8", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/kustopooldataconnections_client.go b/sdk/resourcemanager/synapse/armsynapse/kustopooldataconnections_client.go index e323c6c435d0..43a2b71e0717 100644 --- a/sdk/resourcemanager/synapse/armsynapse/kustopooldataconnections_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/kustopooldataconnections_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // KustoPoolDataConnectionsClient contains the methods for the KustoPoolDataConnections group. // Don't use this type directly, use NewKustoPoolDataConnectionsClient() instead. type KustoPoolDataConnectionsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewKustoPoolDataConnectionsClient creates a new instance of KustoPoolDataConnectionsClient with the specified values. @@ -36,21 +33,13 @@ type KustoPoolDataConnectionsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewKustoPoolDataConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*KustoPoolDataConnectionsClient, 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+".KustoPoolDataConnectionsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &KustoPoolDataConnectionsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,7 +60,7 @@ func (client *KustoPoolDataConnectionsClient) CheckNameAvailability(ctx context. if err != nil { return KustoPoolDataConnectionsClientCheckNameAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolDataConnectionsClientCheckNameAvailabilityResponse{}, err } @@ -104,7 +93,7 @@ func (client *KustoPoolDataConnectionsClient) checkNameAvailabilityCreateRequest return nil, errors.New("parameter databaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) - 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 } @@ -142,9 +131,9 @@ func (client *KustoPoolDataConnectionsClient) BeginCreateOrUpdate(ctx context.Co if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolDataConnectionsClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolDataConnectionsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolDataConnectionsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolDataConnectionsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -157,7 +146,7 @@ func (client *KustoPoolDataConnectionsClient) createOrUpdate(ctx context.Context 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 } @@ -194,7 +183,7 @@ func (client *KustoPoolDataConnectionsClient) createOrUpdateCreateRequest(ctx co return nil, errors.New("parameter dataConnectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dataConnectionName}", url.PathEscape(dataConnectionName)) - 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 } @@ -222,11 +211,11 @@ func (client *KustoPoolDataConnectionsClient) BeginDataConnectionValidation(ctx if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[KustoPoolDataConnectionsClientDataConnectionValidationResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[KustoPoolDataConnectionsClientDataConnectionValidationResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[KustoPoolDataConnectionsClientDataConnectionValidationResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolDataConnectionsClientDataConnectionValidationResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -239,7 +228,7 @@ func (client *KustoPoolDataConnectionsClient) dataConnectionValidation(ctx conte 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 } @@ -272,7 +261,7 @@ func (client *KustoPoolDataConnectionsClient) dataConnectionValidationCreateRequ return nil, errors.New("parameter databaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) - 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,9 +289,9 @@ func (client *KustoPoolDataConnectionsClient) BeginDelete(ctx context.Context, r if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolDataConnectionsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolDataConnectionsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolDataConnectionsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolDataConnectionsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -315,7 +304,7 @@ func (client *KustoPoolDataConnectionsClient) deleteOperation(ctx context.Contex 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 } @@ -352,7 +341,7 @@ func (client *KustoPoolDataConnectionsClient) deleteCreateRequest(ctx context.Co return nil, errors.New("parameter dataConnectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dataConnectionName}", url.PathEscape(dataConnectionName)) - 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 } @@ -379,7 +368,7 @@ func (client *KustoPoolDataConnectionsClient) Get(ctx context.Context, resourceG if err != nil { return KustoPoolDataConnectionsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolDataConnectionsClientGetResponse{}, err } @@ -416,7 +405,7 @@ func (client *KustoPoolDataConnectionsClient) getCreateRequest(ctx context.Conte return nil, errors.New("parameter dataConnectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dataConnectionName}", url.PathEscape(dataConnectionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -455,7 +444,7 @@ func (client *KustoPoolDataConnectionsClient) NewListByDatabasePager(resourceGro if err != nil { return KustoPoolDataConnectionsClientListByDatabaseResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolDataConnectionsClientListByDatabaseResponse{}, err } @@ -490,7 +479,7 @@ func (client *KustoPoolDataConnectionsClient) listByDatabaseCreateRequest(ctx co return nil, errors.New("parameter databaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -528,9 +517,9 @@ func (client *KustoPoolDataConnectionsClient) BeginUpdate(ctx context.Context, r if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolDataConnectionsClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolDataConnectionsClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolDataConnectionsClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolDataConnectionsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -543,7 +532,7 @@ func (client *KustoPoolDataConnectionsClient) update(ctx context.Context, resour if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -580,7 +569,7 @@ func (client *KustoPoolDataConnectionsClient) updateCreateRequest(ctx context.Co return nil, errors.New("parameter dataConnectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dataConnectionName}", url.PathEscape(dataConnectionName)) - 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/synapse/armsynapse/kustopooldataconnections_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/kustopooldataconnections_client_example_test.go index af50af1c6342..acea825cf337 100644 --- a/sdk/resourcemanager/synapse/armsynapse/kustopooldataconnections_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/kustopooldataconnections_client_example_test.go @@ -25,11 +25,11 @@ func ExampleKustoPoolDataConnectionsClient_CheckNameAvailability() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolDataConnectionsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CheckNameAvailability(ctx, "kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "Kustodatabase8", armsynapse.DataConnectionCheckNameRequest{ + res, err := clientFactory.NewKustoPoolDataConnectionsClient().CheckNameAvailability(ctx, "kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "Kustodatabase8", armsynapse.DataConnectionCheckNameRequest{ Name: to.Ptr("DataConnections8"), Type: to.Ptr("Microsoft.Synapse/workspaces/kustoPools/databases/dataConnections"), }, nil) @@ -54,11 +54,11 @@ func ExampleKustoPoolDataConnectionsClient_BeginDataConnectionValidation() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolDataConnectionsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDataConnectionValidation(ctx, "kustorptest", "kustorptest", "kustoclusterrptest4", "KustoDatabase8", armsynapse.DataConnectionValidation{ + poller, err := clientFactory.NewKustoPoolDataConnectionsClient().BeginDataConnectionValidation(ctx, "kustorptest", "kustorptest", "kustoclusterrptest4", "KustoDatabase8", armsynapse.DataConnectionValidation{ DataConnectionName: to.Ptr("DataConnections8"), Properties: &armsynapse.EventHubDataConnection{ Kind: to.Ptr(armsynapse.DataConnectionKindEventHub), @@ -92,11 +92,11 @@ func ExampleKustoPoolDataConnectionsClient_NewListByDatabasePager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolDataConnectionsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByDatabasePager("kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "KustoDatabase8", nil) + pager := clientFactory.NewKustoPoolDataConnectionsClient().NewListByDatabasePager("kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "KustoDatabase8", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -142,11 +142,11 @@ func ExampleKustoPoolDataConnectionsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolDataConnectionsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "KustoDatabase8", "DataConnections8", nil) + res, err := clientFactory.NewKustoPoolDataConnectionsClient().Get(ctx, "kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "KustoDatabase8", "DataConnections8", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -175,11 +175,11 @@ func ExampleKustoPoolDataConnectionsClient_BeginCreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolDataConnectionsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "KustoDatabase8", "DataConnections8", &armsynapse.EventHubDataConnection{ + poller, err := clientFactory.NewKustoPoolDataConnectionsClient().BeginCreateOrUpdate(ctx, "kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "KustoDatabase8", "DataConnections8", &armsynapse.EventHubDataConnection{ Kind: to.Ptr(armsynapse.DataConnectionKindEventHub), Location: to.Ptr("westus"), Properties: &armsynapse.EventHubConnectionProperties{ @@ -219,11 +219,11 @@ func ExampleKustoPoolDataConnectionsClient_BeginUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolDataConnectionsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "KustoDatabase8", "DataConnections8", &armsynapse.EventHubDataConnection{ + poller, err := clientFactory.NewKustoPoolDataConnectionsClient().BeginUpdate(ctx, "kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "KustoDatabase8", "DataConnections8", &armsynapse.EventHubDataConnection{ Kind: to.Ptr(armsynapse.DataConnectionKindEventHub), Location: to.Ptr("westus"), Properties: &armsynapse.EventHubConnectionProperties{ @@ -263,11 +263,11 @@ func ExampleKustoPoolDataConnectionsClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolDataConnectionsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "KustoDatabase8", "kustoeventhubconnection1", nil) + poller, err := clientFactory.NewKustoPoolDataConnectionsClient().BeginDelete(ctx, "kustorptest", "synapseWorkspaceName", "kustoclusterrptest4", "KustoDatabase8", "kustoeventhubconnection1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/kustopoolprincipalassignments_client.go b/sdk/resourcemanager/synapse/armsynapse/kustopoolprincipalassignments_client.go index 462d6079a10e..49a4ee3cb17f 100644 --- a/sdk/resourcemanager/synapse/armsynapse/kustopoolprincipalassignments_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/kustopoolprincipalassignments_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // KustoPoolPrincipalAssignmentsClient contains the methods for the KustoPoolPrincipalAssignments group. // Don't use this type directly, use NewKustoPoolPrincipalAssignmentsClient() instead. type KustoPoolPrincipalAssignmentsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewKustoPoolPrincipalAssignmentsClient creates a new instance of KustoPoolPrincipalAssignmentsClient with the specified values. @@ -36,21 +33,13 @@ type KustoPoolPrincipalAssignmentsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewKustoPoolPrincipalAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*KustoPoolPrincipalAssignmentsClient, 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+".KustoPoolPrincipalAssignmentsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &KustoPoolPrincipalAssignmentsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,7 +59,7 @@ func (client *KustoPoolPrincipalAssignmentsClient) CheckNameAvailability(ctx con if err != nil { return KustoPoolPrincipalAssignmentsClientCheckNameAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolPrincipalAssignmentsClientCheckNameAvailabilityResponse{}, err } @@ -99,7 +88,7 @@ func (client *KustoPoolPrincipalAssignmentsClient) checkNameAvailabilityCreateRe 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 } @@ -136,9 +125,9 @@ func (client *KustoPoolPrincipalAssignmentsClient) BeginCreateOrUpdate(ctx conte if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolPrincipalAssignmentsClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolPrincipalAssignmentsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolPrincipalAssignmentsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolPrincipalAssignmentsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -151,7 +140,7 @@ func (client *KustoPoolPrincipalAssignmentsClient) createOrUpdate(ctx context.Co 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 +173,7 @@ func (client *KustoPoolPrincipalAssignmentsClient) createOrUpdateCreateRequest(c 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 } @@ -211,9 +200,9 @@ func (client *KustoPoolPrincipalAssignmentsClient) BeginDelete(ctx context.Conte if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolPrincipalAssignmentsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolPrincipalAssignmentsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolPrincipalAssignmentsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolPrincipalAssignmentsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -226,7 +215,7 @@ func (client *KustoPoolPrincipalAssignmentsClient) deleteOperation(ctx context.C 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 } @@ -259,7 +248,7 @@ func (client *KustoPoolPrincipalAssignmentsClient) deleteCreateRequest(ctx conte 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 } @@ -285,7 +274,7 @@ func (client *KustoPoolPrincipalAssignmentsClient) Get(ctx context.Context, work if err != nil { return KustoPoolPrincipalAssignmentsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolPrincipalAssignmentsClientGetResponse{}, err } @@ -318,7 +307,7 @@ func (client *KustoPoolPrincipalAssignmentsClient) getCreateRequest(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 } @@ -356,7 +345,7 @@ func (client *KustoPoolPrincipalAssignmentsClient) NewListPager(workspaceName st if err != nil { return KustoPoolPrincipalAssignmentsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolPrincipalAssignmentsClientListResponse{}, err } @@ -387,7 +376,7 @@ func (client *KustoPoolPrincipalAssignmentsClient) listCreateRequest(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 } diff --git a/sdk/resourcemanager/synapse/armsynapse/kustopoolprincipalassignments_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/kustopoolprincipalassignments_client_example_test.go index 32bbed5c559c..9b232772cfca 100644 --- a/sdk/resourcemanager/synapse/armsynapse/kustopoolprincipalassignments_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/kustopoolprincipalassignments_client_example_test.go @@ -25,11 +25,11 @@ func ExampleKustoPoolPrincipalAssignmentsClient_CheckNameAvailability() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolPrincipalAssignmentsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CheckNameAvailability(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "kustorptest", armsynapse.ClusterPrincipalAssignmentCheckNameRequest{ + res, err := clientFactory.NewKustoPoolPrincipalAssignmentsClient().CheckNameAvailability(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "kustorptest", armsynapse.ClusterPrincipalAssignmentCheckNameRequest{ Name: to.Ptr("kustoprincipal1"), Type: to.Ptr("Microsoft.Synapse/workspaces/kustoPools/principalAssignments"), }, nil) @@ -53,11 +53,11 @@ func ExampleKustoPoolPrincipalAssignmentsClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolPrincipalAssignmentsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("synapseWorkspaceName", "kustoclusterrptest4", "kustorptest", nil) + pager := clientFactory.NewKustoPoolPrincipalAssignmentsClient().NewListPager("synapseWorkspaceName", "kustoclusterrptest4", "kustorptest", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -111,11 +111,11 @@ func ExampleKustoPoolPrincipalAssignmentsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolPrincipalAssignmentsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "kustoprincipal1", "kustorptest", nil) + res, err := clientFactory.NewKustoPoolPrincipalAssignmentsClient().Get(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "kustoprincipal1", "kustorptest", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -146,11 +146,11 @@ func ExampleKustoPoolPrincipalAssignmentsClient_BeginCreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolPrincipalAssignmentsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "kustoprincipal1", "kustorptest", armsynapse.ClusterPrincipalAssignment{ + poller, err := clientFactory.NewKustoPoolPrincipalAssignmentsClient().BeginCreateOrUpdate(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "kustoprincipal1", "kustorptest", armsynapse.ClusterPrincipalAssignment{ Properties: &armsynapse.ClusterPrincipalProperties{ PrincipalID: to.Ptr("87654321-1234-1234-1234-123456789123"), PrincipalType: to.Ptr(armsynapse.PrincipalTypeApp), @@ -192,11 +192,11 @@ func ExampleKustoPoolPrincipalAssignmentsClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolPrincipalAssignmentsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "kustoprincipal1", "kustorptest", nil) + poller, err := clientFactory.NewKustoPoolPrincipalAssignmentsClient().BeginDelete(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "kustoprincipal1", "kustorptest", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/kustopoolprivatelinkresources_client.go b/sdk/resourcemanager/synapse/armsynapse/kustopoolprivatelinkresources_client.go index d80086f0d7ee..4ef75f7bd516 100644 --- a/sdk/resourcemanager/synapse/armsynapse/kustopoolprivatelinkresources_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/kustopoolprivatelinkresources_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // KustoPoolPrivateLinkResourcesClient contains the methods for the KustoPoolPrivateLinkResources group. // Don't use this type directly, use NewKustoPoolPrivateLinkResourcesClient() instead. type KustoPoolPrivateLinkResourcesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewKustoPoolPrivateLinkResourcesClient creates a new instance of KustoPoolPrivateLinkResourcesClient with the specified values. @@ -36,21 +33,13 @@ type KustoPoolPrivateLinkResourcesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewKustoPoolPrivateLinkResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*KustoPoolPrivateLinkResourcesClient, 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+".KustoPoolPrivateLinkResourcesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &KustoPoolPrivateLinkResourcesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -73,7 +62,7 @@ func (client *KustoPoolPrivateLinkResourcesClient) NewListPager(resourceGroupNam if err != nil { return KustoPoolPrivateLinkResourcesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolPrivateLinkResourcesClientListResponse{}, err } @@ -104,7 +93,7 @@ func (client *KustoPoolPrivateLinkResourcesClient) listCreateRequest(ctx context return nil, errors.New("parameter kustoPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{kustoPoolName}", url.PathEscape(kustoPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/kustopoolprivatelinkresources_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/kustopoolprivatelinkresources_client_example_test.go index 1bef806e1412..d7ccbdabc647 100644 --- a/sdk/resourcemanager/synapse/armsynapse/kustopoolprivatelinkresources_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/kustopoolprivatelinkresources_client_example_test.go @@ -24,11 +24,11 @@ func ExampleKustoPoolPrivateLinkResourcesClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolPrivateLinkResourcesClient("7a587823-959d-4ad0-85bd-cf2a7cef436a", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("DP-900", "synapse-ws-ebi-data", "dataexplorerpool900", nil) + pager := clientFactory.NewKustoPoolPrivateLinkResourcesClient().NewListPager("DP-900", "synapse-ws-ebi-data", "dataexplorerpool900", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/kustopools_client.go b/sdk/resourcemanager/synapse/armsynapse/kustopools_client.go index e0c1c6892424..866dd12ab1ed 100644 --- a/sdk/resourcemanager/synapse/armsynapse/kustopools_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/kustopools_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // KustoPoolsClient contains the methods for the KustoPools group. // Don't use this type directly, use NewKustoPoolsClient() instead. type KustoPoolsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewKustoPoolsClient creates a new instance of KustoPoolsClient with the specified values. @@ -36,21 +33,13 @@ type KustoPoolsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewKustoPoolsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*KustoPoolsClient, 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+".KustoPoolsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &KustoPoolsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,9 +60,9 @@ func (client *KustoPoolsClient) BeginAddLanguageExtensions(ctx context.Context, if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolsClientAddLanguageExtensionsResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolsClientAddLanguageExtensionsResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolsClientAddLanguageExtensionsResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolsClientAddLanguageExtensionsResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -86,7 +75,7 @@ func (client *KustoPoolsClient) addLanguageExtensions(ctx context.Context, works 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 +104,7 @@ func (client *KustoPoolsClient) addLanguageExtensionsCreateRequest(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.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 } @@ -139,7 +128,7 @@ func (client *KustoPoolsClient) CheckNameAvailability(ctx context.Context, locat if err != nil { return KustoPoolsClientCheckNameAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolsClientCheckNameAvailabilityResponse{}, err } @@ -160,7 +149,7 @@ func (client *KustoPoolsClient) checkNameAvailabilityCreateRequest(ctx context.C 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 } @@ -196,9 +185,9 @@ func (client *KustoPoolsClient) BeginCreateOrUpdate(ctx context.Context, workspa if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolsClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -211,7 +200,7 @@ func (client *KustoPoolsClient) createOrUpdate(ctx context.Context, workspaceNam if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -240,7 +229,7 @@ func (client *KustoPoolsClient) 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 } @@ -271,9 +260,9 @@ func (client *KustoPoolsClient) BeginDelete(ctx context.Context, workspaceName s if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -286,7 +275,7 @@ func (client *KustoPoolsClient) deleteOperation(ctx context.Context, workspaceNa 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 } @@ -315,7 +304,7 @@ func (client *KustoPoolsClient) deleteCreateRequest(ctx context.Context, workspa 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 } @@ -342,9 +331,9 @@ func (client *KustoPoolsClient) BeginDetachFollowerDatabases(ctx context.Context if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolsClientDetachFollowerDatabasesResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolsClientDetachFollowerDatabasesResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolsClientDetachFollowerDatabasesResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolsClientDetachFollowerDatabasesResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -357,7 +346,7 @@ func (client *KustoPoolsClient) detachFollowerDatabases(ctx context.Context, wor 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 } @@ -386,7 +375,7 @@ func (client *KustoPoolsClient) detachFollowerDatabasesCreateRequest(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 } @@ -410,7 +399,7 @@ func (client *KustoPoolsClient) Get(ctx context.Context, workspaceName string, k if err != nil { return KustoPoolsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolsClientGetResponse{}, err } @@ -439,7 +428,7 @@ func (client *KustoPoolsClient) getCreateRequest(ctx context.Context, workspaceN 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 } @@ -472,7 +461,7 @@ func (client *KustoPoolsClient) ListByWorkspace(ctx context.Context, resourceGro if err != nil { return KustoPoolsClientListByWorkspaceResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolsClientListByWorkspaceResponse{}, err } @@ -497,7 +486,7 @@ func (client *KustoPoolsClient) listByWorkspaceCreateRequest(ctx context.Context return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -536,7 +525,7 @@ func (client *KustoPoolsClient) NewListFollowerDatabasesPager(workspaceName stri if err != nil { return KustoPoolsClientListFollowerDatabasesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolsClientListFollowerDatabasesResponse{}, err } @@ -567,7 +556,7 @@ func (client *KustoPoolsClient) listFollowerDatabasesCreateRequest(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.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 } @@ -605,7 +594,7 @@ func (client *KustoPoolsClient) NewListLanguageExtensionsPager(workspaceName str if err != nil { return KustoPoolsClientListLanguageExtensionsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolsClientListLanguageExtensionsResponse{}, err } @@ -636,7 +625,7 @@ func (client *KustoPoolsClient) listLanguageExtensionsCreateRequest(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 } @@ -670,7 +659,7 @@ func (client *KustoPoolsClient) NewListSKUsPager(options *KustoPoolsClientListSK if err != nil { return KustoPoolsClientListSKUsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolsClientListSKUsResponse{}, err } @@ -689,7 +678,7 @@ func (client *KustoPoolsClient) listSKUsCreateRequest(ctx context.Context, optio return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -727,7 +716,7 @@ func (client *KustoPoolsClient) NewListSKUsByResourcePager(workspaceName string, if err != nil { return KustoPoolsClientListSKUsByResourceResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return KustoPoolsClientListSKUsByResourceResponse{}, err } @@ -758,7 +747,7 @@ func (client *KustoPoolsClient) listSKUsByResourceCreateRequest(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 } @@ -794,9 +783,9 @@ func (client *KustoPoolsClient) BeginRemoveLanguageExtensions(ctx context.Contex if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolsClientRemoveLanguageExtensionsResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolsClientRemoveLanguageExtensionsResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolsClientRemoveLanguageExtensionsResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolsClientRemoveLanguageExtensionsResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -809,7 +798,7 @@ func (client *KustoPoolsClient) removeLanguageExtensions(ctx context.Context, wo 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 } @@ -838,7 +827,7 @@ func (client *KustoPoolsClient) removeLanguageExtensionsCreateRequest(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.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 } @@ -863,9 +852,9 @@ func (client *KustoPoolsClient) BeginStart(ctx context.Context, workspaceName st if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolsClientStartResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolsClientStartResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolsClientStartResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolsClientStartResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -878,7 +867,7 @@ func (client *KustoPoolsClient) start(ctx context.Context, workspaceName string, 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 } @@ -907,7 +896,7 @@ func (client *KustoPoolsClient) startCreateRequest(ctx context.Context, workspac 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 } @@ -932,9 +921,9 @@ func (client *KustoPoolsClient) BeginStop(ctx context.Context, workspaceName str if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolsClientStopResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolsClientStopResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolsClientStopResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolsClientStopResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -947,7 +936,7 @@ func (client *KustoPoolsClient) stop(ctx context.Context, workspaceName string, 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 } @@ -976,7 +965,7 @@ func (client *KustoPoolsClient) stopCreateRequest(ctx context.Context, workspace 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 } @@ -1002,9 +991,9 @@ func (client *KustoPoolsClient) BeginUpdate(ctx context.Context, workspaceName s if err != nil { return nil, err } - return runtime.NewPoller[KustoPoolsClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[KustoPoolsClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[KustoPoolsClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[KustoPoolsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -1017,7 +1006,7 @@ func (client *KustoPoolsClient) update(ctx context.Context, workspaceName string 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 } @@ -1046,7 +1035,7 @@ func (client *KustoPoolsClient) updateCreateRequest(ctx context.Context, workspa 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/synapse/armsynapse/kustopools_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/kustopools_client_example_test.go index f8aeb2a6ba8d..4f5ba9b6831c 100644 --- a/sdk/resourcemanager/synapse/armsynapse/kustopools_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/kustopools_client_example_test.go @@ -25,11 +25,11 @@ func ExampleKustoPoolsClient_NewListSKUsPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListSKUsPager(nil) + pager := clientFactory.NewKustoPoolsClient().NewListSKUsPager(nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -133,11 +133,11 @@ func ExampleKustoPoolsClient_CheckNameAvailability() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CheckNameAvailability(ctx, "westus", armsynapse.KustoPoolCheckNameRequest{ + res, err := clientFactory.NewKustoPoolsClient().CheckNameAvailability(ctx, "westus", armsynapse.KustoPoolCheckNameRequest{ Name: to.Ptr("kustoclusterrptest4"), Type: to.Ptr("Microsoft.Synapse/workspaces/kustoPools"), }, nil) @@ -161,11 +161,11 @@ func ExampleKustoPoolsClient_ListByWorkspace() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.ListByWorkspace(ctx, "kustorptest", "kustorptest", nil) + res, err := clientFactory.NewKustoPoolsClient().ListByWorkspace(ctx, "kustorptest", "kustorptest", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -214,11 +214,11 @@ func ExampleKustoPoolsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "kustorptest", nil) + res, err := clientFactory.NewKustoPoolsClient().Get(ctx, "synapseWorkspaceName", "kustoclusterrptest4", "kustorptest", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -249,11 +249,11 @@ func ExampleKustoPoolsClient_BeginCreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "synapseWorkspaceName", "kustorptest", "kustoclusterrptest4", armsynapse.KustoPool{ + poller, err := clientFactory.NewKustoPoolsClient().BeginCreateOrUpdate(ctx, "synapseWorkspaceName", "kustorptest", "kustoclusterrptest4", armsynapse.KustoPool{ Location: to.Ptr("westus"), Properties: &armsynapse.KustoPoolProperties{ EnablePurge: to.Ptr(true), @@ -304,11 +304,11 @@ func ExampleKustoPoolsClient_BeginUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "synapseWorkspaceName", "kustorptest", "kustoclusterrptest4", armsynapse.KustoPoolUpdate{ + poller, err := clientFactory.NewKustoPoolsClient().BeginUpdate(ctx, "synapseWorkspaceName", "kustorptest", "kustoclusterrptest4", armsynapse.KustoPoolUpdate{ Properties: &armsynapse.KustoPoolProperties{ EnablePurge: to.Ptr(true), EnableStreamingIngest: to.Ptr(true), @@ -356,11 +356,11 @@ func ExampleKustoPoolsClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "kustorptest", "kustorptest", "kustoclusterrptest4", nil) + poller, err := clientFactory.NewKustoPoolsClient().BeginDelete(ctx, "kustorptest", "kustorptest", "kustoclusterrptest4", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -377,11 +377,11 @@ func ExampleKustoPoolsClient_BeginStop() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginStop(ctx, "kustorptest", "kustoclusterrptest4", "kustorptest", nil) + poller, err := clientFactory.NewKustoPoolsClient().BeginStop(ctx, "kustorptest", "kustoclusterrptest4", "kustorptest", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -398,11 +398,11 @@ func ExampleKustoPoolsClient_BeginStart() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginStart(ctx, "kustorptest", "kustoclusterrptest4", "kustorptest", nil) + poller, err := clientFactory.NewKustoPoolsClient().BeginStart(ctx, "kustorptest", "kustoclusterrptest4", "kustorptest", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -419,11 +419,11 @@ func ExampleKustoPoolsClient_NewListSKUsByResourcePager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListSKUsByResourcePager("synapseWorkspaceName", "kustoclusterrptest4", "kustorptest", nil) + pager := clientFactory.NewKustoPoolsClient().NewListSKUsByResourcePager("synapseWorkspaceName", "kustoclusterrptest4", "kustorptest", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -499,11 +499,11 @@ func ExampleKustoPoolsClient_NewListLanguageExtensionsPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListLanguageExtensionsPager("kustorptest", "kustoclusterrptest4", "kustorptest", nil) + pager := clientFactory.NewKustoPoolsClient().NewListLanguageExtensionsPager("kustorptest", "kustoclusterrptest4", "kustorptest", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -533,11 +533,11 @@ func ExampleKustoPoolsClient_BeginAddLanguageExtensions() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginAddLanguageExtensions(ctx, "kustorptest", "kustoclusterrptest4", "kustorptest", armsynapse.LanguageExtensionsList{ + poller, err := clientFactory.NewKustoPoolsClient().BeginAddLanguageExtensions(ctx, "kustorptest", "kustoclusterrptest4", "kustorptest", armsynapse.LanguageExtensionsList{ Value: []*armsynapse.LanguageExtension{ { LanguageExtensionName: to.Ptr(armsynapse.LanguageExtensionNamePYTHON), @@ -562,11 +562,11 @@ func ExampleKustoPoolsClient_BeginRemoveLanguageExtensions() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginRemoveLanguageExtensions(ctx, "kustorptest", "kustoclusterrptest4", "kustorptest", armsynapse.LanguageExtensionsList{ + poller, err := clientFactory.NewKustoPoolsClient().BeginRemoveLanguageExtensions(ctx, "kustorptest", "kustoclusterrptest4", "kustorptest", armsynapse.LanguageExtensionsList{ Value: []*armsynapse.LanguageExtension{ { LanguageExtensionName: to.Ptr(armsynapse.LanguageExtensionNamePYTHON), @@ -591,11 +591,11 @@ func ExampleKustoPoolsClient_NewListFollowerDatabasesPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListFollowerDatabasesPager("kustorptest", "kustoclusterrptest4", "kustorptest", nil) + pager := clientFactory.NewKustoPoolsClient().NewListFollowerDatabasesPager("kustorptest", "kustoclusterrptest4", "kustorptest", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -629,11 +629,11 @@ func ExampleKustoPoolsClient_BeginDetachFollowerDatabases() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewKustoPoolsClient("12345678-1234-1234-1234-123456789098", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDetachFollowerDatabases(ctx, "kustorptest", "kustoclusterrptest4", "kustorptest", armsynapse.FollowerDatabaseDefinition{ + poller, err := clientFactory.NewKustoPoolsClient().BeginDetachFollowerDatabases(ctx, "kustorptest", "kustoclusterrptest4", "kustorptest", armsynapse.FollowerDatabaseDefinition{ AttachedDatabaseConfigurationName: to.Ptr("myAttachedDatabaseConfiguration"), KustoPoolResourceID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Synapse/workspaces/kustorptest/kustoPools/leader4"), }, nil) diff --git a/sdk/resourcemanager/synapse/armsynapse/libraries_client.go b/sdk/resourcemanager/synapse/armsynapse/libraries_client.go index d83f2190ec86..d46af92ef209 100644 --- a/sdk/resourcemanager/synapse/armsynapse/libraries_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/libraries_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // LibrariesClient contains the methods for the Libraries group. // Don't use this type directly, use NewLibrariesClient() instead. type LibrariesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewLibrariesClient creates a new instance of LibrariesClient with the specified values. @@ -36,21 +33,13 @@ type LibrariesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewLibrariesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LibrariesClient, 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+".LibrariesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &LibrariesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -78,7 +67,7 @@ func (client *LibrariesClient) NewListByWorkspacePager(resourceGroupName string, if err != nil { return LibrariesClientListByWorkspaceResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LibrariesClientListByWorkspaceResponse{}, err } @@ -105,7 +94,7 @@ func (client *LibrariesClient) listByWorkspaceCreateRequest(ctx context.Context, return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/libraries_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/libraries_client_example_test.go index 59a9eb78195b..8b7a2aa4f43a 100644 --- a/sdk/resourcemanager/synapse/armsynapse/libraries_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/libraries_client_example_test.go @@ -24,11 +24,11 @@ func ExampleLibrariesClient_NewListByWorkspacePager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewLibrariesClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByWorkspacePager("exampleResourceGroup", "exampleWorkspace", nil) + pager := clientFactory.NewLibrariesClient().NewListByWorkspacePager("exampleResourceGroup", "exampleWorkspace", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/library_client.go b/sdk/resourcemanager/synapse/armsynapse/library_client.go index 8d8f14796349..f53b1511cdf8 100644 --- a/sdk/resourcemanager/synapse/armsynapse/library_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/library_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // LibraryClient contains the methods for the Library group. // Don't use this type directly, use NewLibraryClient() instead. type LibraryClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewLibraryClient creates a new instance of LibraryClient with the specified values. @@ -36,21 +33,13 @@ type LibraryClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewLibraryClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LibraryClient, 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+".LibraryClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &LibraryClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -68,7 +57,7 @@ func (client *LibraryClient) Get(ctx context.Context, resourceGroupName string, if err != nil { return LibraryClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LibraryClientGetResponse{}, err } @@ -97,7 +86,7 @@ func (client *LibraryClient) getCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/library_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/library_client_example_test.go index 8ad546491778..192c76d054d0 100644 --- a/sdk/resourcemanager/synapse/armsynapse/library_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/library_client_example_test.go @@ -24,11 +24,11 @@ func ExampleLibraryClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewLibraryClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "exampleResourceGroup", "exampleLibraryName.jar", "exampleWorkspace", nil) + res, err := clientFactory.NewLibraryClient().Get(ctx, "exampleResourceGroup", "exampleLibraryName.jar", "exampleWorkspace", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/operations_client.go b/sdk/resourcemanager/synapse/armsynapse/operations_client.go index d22911b80b2a..bc9e75e1ebb5 100644 --- a/sdk/resourcemanager/synapse/armsynapse/operations_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/operations_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // 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. @@ -36,21 +33,13 @@ type OperationsClient struct { // - 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 } @@ -67,7 +56,7 @@ func (client *OperationsClient) CheckNameAvailability(ctx context.Context, reque if err != nil { return OperationsClientCheckNameAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientCheckNameAvailabilityResponse{}, err } @@ -84,7 +73,7 @@ func (client *OperationsClient) checkNameAvailabilityCreateRequest(ctx context.C return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -118,7 +107,7 @@ func (client *OperationsClient) GetAzureAsyncHeaderResult(ctx context.Context, r if err != nil { return OperationsClientGetAzureAsyncHeaderResultResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientGetAzureAsyncHeaderResultResponse{}, err } @@ -147,7 +136,7 @@ func (client *OperationsClient) getAzureAsyncHeaderResultCreateRequest(ctx conte return nil, errors.New("parameter operationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -181,7 +170,7 @@ func (client *OperationsClient) GetLocationHeaderResult(ctx context.Context, res if err != nil { return OperationsClientGetLocationHeaderResultResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientGetLocationHeaderResultResponse{}, err } @@ -210,7 +199,7 @@ func (client *OperationsClient) getLocationHeaderResultCreateRequest(ctx context return nil, errors.New("parameter operationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -231,7 +220,7 @@ func (client *OperationsClient) List(ctx context.Context, options *OperationsCli 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 } @@ -244,7 +233,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.Synapse/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/synapse/armsynapse/operations_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/operations_client_example_test.go index 703accd0d721..680709d9a391 100644 --- a/sdk/resourcemanager/synapse/armsynapse/operations_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/operations_client_example_test.go @@ -25,11 +25,11 @@ func ExampleOperationsClient_CheckNameAvailability_checkForAWorkspaceNameThatAlr log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewOperationsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CheckNameAvailability(ctx, armsynapse.CheckNameAvailabilityRequest{ + res, err := clientFactory.NewOperationsClient().CheckNameAvailability(ctx, armsynapse.CheckNameAvailabilityRequest{ Name: to.Ptr("workspace1"), Type: to.Ptr("Microsoft.Synapse/workspaces"), }, nil) @@ -54,11 +54,11 @@ func ExampleOperationsClient_CheckNameAvailability_checkForAWorkspaceNameThatIsA log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewOperationsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CheckNameAvailability(ctx, armsynapse.CheckNameAvailabilityRequest{ + res, err := clientFactory.NewOperationsClient().CheckNameAvailability(ctx, armsynapse.CheckNameAvailabilityRequest{ Name: to.Ptr("workspace1"), Type: to.Ptr("Microsoft.ProjectArcadia/workspaces"), }, nil) @@ -81,11 +81,11 @@ func ExampleOperationsClient_List() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewOperationsClient("", cred, nil) + clientFactory, err := armsynapse.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) } @@ -1545,11 +1545,11 @@ func ExampleOperationsClient_GetLocationHeaderResult() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewOperationsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.GetLocationHeaderResult(ctx, "resourceGroup1", "workspace1", "01234567-89ab-4def-0123-456789abcdef", nil) + _, err = clientFactory.NewOperationsClient().GetLocationHeaderResult(ctx, "resourceGroup1", "workspace1", "01234567-89ab-4def-0123-456789abcdef", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -1562,11 +1562,11 @@ func ExampleOperationsClient_GetAzureAsyncHeaderResult() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewOperationsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.GetAzureAsyncHeaderResult(ctx, "resourceGroup1", "workspace1", "01234567-89ab-4def-0123-456789abcdef", nil) + res, err := clientFactory.NewOperationsClient().GetAzureAsyncHeaderResult(ctx, "resourceGroup1", "workspace1", "01234567-89ab-4def-0123-456789abcdef", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/privateendpointconnections_client.go b/sdk/resourcemanager/synapse/armsynapse/privateendpointconnections_client.go index 1ef623b7f7ac..5d7d794c4831 100644 --- a/sdk/resourcemanager/synapse/armsynapse/privateendpointconnections_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/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,9 +24,8 @@ 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. @@ -36,21 +33,13 @@ type PrivateEndpointConnectionsClient struct { // - 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 } @@ -71,11 +60,11 @@ func (client *PrivateEndpointConnectionsClient) BeginCreate(ctx context.Context, if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[PrivateEndpointConnectionsClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateEndpointConnectionsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -88,7 +77,7 @@ func (client *PrivateEndpointConnectionsClient) create(ctx context.Context, reso 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 +106,7 @@ func (client *PrivateEndpointConnectionsClient) createCreateRequest(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.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 } @@ -143,9 +132,9 @@ func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, if err != nil { return nil, err } - return runtime.NewPoller[PrivateEndpointConnectionsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[PrivateEndpointConnectionsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -158,7 +147,7 @@ func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Cont if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -187,7 +176,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 } @@ -212,7 +201,7 @@ func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourc 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 } @@ -241,7 +230,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 } @@ -284,7 +273,7 @@ func (client *PrivateEndpointConnectionsClient) NewListPager(resourceGroupName s if err != nil { return PrivateEndpointConnectionsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsClientListResponse{}, err } @@ -311,7 +300,7 @@ func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Co return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/privateendpointconnections_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/privateendpointconnections_client_example_test.go index 90db6e4335be..d850507d639d 100644 --- a/sdk/resourcemanager/synapse/armsynapse/privateendpointconnections_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/privateendpointconnections_client_example_test.go @@ -25,11 +25,11 @@ func ExamplePrivateEndpointConnectionsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewPrivateEndpointConnectionsClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExamplePrivateEndpointConnection", nil) + res, err := clientFactory.NewPrivateEndpointConnectionsClient().Get(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExamplePrivateEndpointConnection", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -61,11 +61,11 @@ func ExamplePrivateEndpointConnectionsClient_BeginCreate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewPrivateEndpointConnectionsClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExamplePrivateEndpointConnection", armsynapse.PrivateEndpointConnection{ + poller, err := clientFactory.NewPrivateEndpointConnectionsClient().BeginCreate(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExamplePrivateEndpointConnection", armsynapse.PrivateEndpointConnection{ Properties: &armsynapse.PrivateEndpointConnectionProperties{ PrivateLinkServiceConnectionState: &armsynapse.PrivateLinkServiceConnectionState{ Description: to.Ptr("Approved by abc@example.com"), @@ -108,11 +108,11 @@ func ExamplePrivateEndpointConnectionsClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewPrivateEndpointConnectionsClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExamplePrivateEndpointConnection", nil) + poller, err := clientFactory.NewPrivateEndpointConnectionsClient().BeginDelete(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExamplePrivateEndpointConnection", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -129,11 +129,11 @@ func ExamplePrivateEndpointConnectionsClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewPrivateEndpointConnectionsClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("ExampleResourceGroup", "ExampleWorkspace", nil) + pager := clientFactory.NewPrivateEndpointConnectionsClient().NewListPager("ExampleResourceGroup", "ExampleWorkspace", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/privateendpointconnectionsprivatelinkhub_client.go b/sdk/resourcemanager/synapse/armsynapse/privateendpointconnectionsprivatelinkhub_client.go index 419899c48056..9a0f146f2984 100644 --- a/sdk/resourcemanager/synapse/armsynapse/privateendpointconnectionsprivatelinkhub_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/privateendpointconnectionsprivatelinkhub_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // PrivateEndpointConnectionsPrivateLinkHubClient contains the methods for the PrivateEndpointConnectionsPrivateLinkHub group. // Don't use this type directly, use NewPrivateEndpointConnectionsPrivateLinkHubClient() instead. type PrivateEndpointConnectionsPrivateLinkHubClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPrivateEndpointConnectionsPrivateLinkHubClient creates a new instance of PrivateEndpointConnectionsPrivateLinkHubClient with the specified values. @@ -36,21 +33,13 @@ type PrivateEndpointConnectionsPrivateLinkHubClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewPrivateEndpointConnectionsPrivateLinkHubClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateEndpointConnectionsPrivateLinkHubClient, 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+".PrivateEndpointConnectionsPrivateLinkHubClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PrivateEndpointConnectionsPrivateLinkHubClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -69,7 +58,7 @@ func (client *PrivateEndpointConnectionsPrivateLinkHubClient) Get(ctx context.Co if err != nil { return PrivateEndpointConnectionsPrivateLinkHubClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsPrivateLinkHubClientGetResponse{}, err } @@ -98,7 +87,7 @@ func (client *PrivateEndpointConnectionsPrivateLinkHubClient) getCreateRequest(c 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 } @@ -141,7 +130,7 @@ func (client *PrivateEndpointConnectionsPrivateLinkHubClient) NewListPager(resou if err != nil { return PrivateEndpointConnectionsPrivateLinkHubClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsPrivateLinkHubClientListResponse{}, err } @@ -168,7 +157,7 @@ func (client *PrivateEndpointConnectionsPrivateLinkHubClient) listCreateRequest( return nil, errors.New("parameter privateLinkHubName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateLinkHubName}", url.PathEscape(privateLinkHubName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/privateendpointconnectionsprivatelinkhub_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/privateendpointconnectionsprivatelinkhub_client_example_test.go index 6c237c0c62ba..ef3c8ab17511 100644 --- a/sdk/resourcemanager/synapse/armsynapse/privateendpointconnectionsprivatelinkhub_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/privateendpointconnectionsprivatelinkhub_client_example_test.go @@ -24,11 +24,11 @@ func ExamplePrivateEndpointConnectionsPrivateLinkHubClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewPrivateEndpointConnectionsPrivateLinkHubClient("48b08652-d7a1-4d52-b13f-5a2471dce57b", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("gh-res-grp", "pe0", nil) + pager := clientFactory.NewPrivateEndpointConnectionsPrivateLinkHubClient().NewListPager("gh-res-grp", "pe0", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -80,11 +80,11 @@ func ExamplePrivateEndpointConnectionsPrivateLinkHubClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewPrivateEndpointConnectionsPrivateLinkHubClient("48b08652-d7a1-4d52-b13f-5a2471dce57b", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "gh-res-grp", "pe0", "pe0-f3ed30f5-338c-4855-a542-24a403694ad2", nil) + res, err := clientFactory.NewPrivateEndpointConnectionsPrivateLinkHubClient().Get(ctx, "gh-res-grp", "pe0", "pe0-f3ed30f5-338c-4855-a542-24a403694ad2", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/privatelinkhubprivatelinkresources_client.go b/sdk/resourcemanager/synapse/armsynapse/privatelinkhubprivatelinkresources_client.go index 683d1e554a7b..ff2635cc14b3 100644 --- a/sdk/resourcemanager/synapse/armsynapse/privatelinkhubprivatelinkresources_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/privatelinkhubprivatelinkresources_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // PrivateLinkHubPrivateLinkResourcesClient contains the methods for the PrivateLinkHubPrivateLinkResources group. // Don't use this type directly, use NewPrivateLinkHubPrivateLinkResourcesClient() instead. type PrivateLinkHubPrivateLinkResourcesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPrivateLinkHubPrivateLinkResourcesClient creates a new instance of PrivateLinkHubPrivateLinkResourcesClient with the specified values. @@ -36,21 +33,13 @@ type PrivateLinkHubPrivateLinkResourcesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewPrivateLinkHubPrivateLinkResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateLinkHubPrivateLinkResourcesClient, 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+".PrivateLinkHubPrivateLinkResourcesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PrivateLinkHubPrivateLinkResourcesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -69,7 +58,7 @@ func (client *PrivateLinkHubPrivateLinkResourcesClient) Get(ctx context.Context, if err != nil { return PrivateLinkHubPrivateLinkResourcesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkHubPrivateLinkResourcesClientGetResponse{}, err } @@ -98,7 +87,7 @@ func (client *PrivateLinkHubPrivateLinkResourcesClient) getCreateRequest(ctx con return nil, errors.New("parameter privateLinkResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateLinkResourceName}", url.PathEscape(privateLinkResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -141,7 +130,7 @@ func (client *PrivateLinkHubPrivateLinkResourcesClient) NewListPager(resourceGro if err != nil { return PrivateLinkHubPrivateLinkResourcesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkHubPrivateLinkResourcesClientListResponse{}, err } @@ -168,7 +157,7 @@ func (client *PrivateLinkHubPrivateLinkResourcesClient) listCreateRequest(ctx co return nil, errors.New("parameter privateLinkHubName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateLinkHubName}", url.PathEscape(privateLinkHubName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/privatelinkhubprivatelinkresources_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/privatelinkhubprivatelinkresources_client_example_test.go index 93915c06ec40..283402ff4fa1 100644 --- a/sdk/resourcemanager/synapse/armsynapse/privatelinkhubprivatelinkresources_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/privatelinkhubprivatelinkresources_client_example_test.go @@ -24,11 +24,11 @@ func ExamplePrivateLinkHubPrivateLinkResourcesClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewPrivateLinkHubPrivateLinkResourcesClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("ExampleResourceGroup", "ExamplePrivateLinkHub", nil) + pager := clientFactory.NewPrivateLinkHubPrivateLinkResourcesClient().NewListPager("ExampleResourceGroup", "ExamplePrivateLinkHub", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -64,11 +64,11 @@ func ExamplePrivateLinkHubPrivateLinkResourcesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewPrivateLinkHubPrivateLinkResourcesClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "ExampleResourceGroup", "ExamplePrivateLinkHub", "sql", nil) + res, err := clientFactory.NewPrivateLinkHubPrivateLinkResourcesClient().Get(ctx, "ExampleResourceGroup", "ExamplePrivateLinkHub", "sql", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/privatelinkhubs_client.go b/sdk/resourcemanager/synapse/armsynapse/privatelinkhubs_client.go index d4c9f4658aed..5d23ebb73352 100644 --- a/sdk/resourcemanager/synapse/armsynapse/privatelinkhubs_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/privatelinkhubs_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // PrivateLinkHubsClient contains the methods for the PrivateLinkHubs group. // Don't use this type directly, use NewPrivateLinkHubsClient() instead. type PrivateLinkHubsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPrivateLinkHubsClient creates a new instance of PrivateLinkHubsClient with the specified values. @@ -36,21 +33,13 @@ type PrivateLinkHubsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewPrivateLinkHubsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateLinkHubsClient, 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+".PrivateLinkHubsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PrivateLinkHubsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -69,7 +58,7 @@ func (client *PrivateLinkHubsClient) CreateOrUpdate(ctx context.Context, resourc if err != nil { return PrivateLinkHubsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkHubsClientCreateOrUpdateResponse{}, err } @@ -94,7 +83,7 @@ func (client *PrivateLinkHubsClient) createOrUpdateCreateRequest(ctx context.Con return nil, errors.New("parameter privateLinkHubName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateLinkHubName}", url.PathEscape(privateLinkHubName)) - 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,9 +117,9 @@ func (client *PrivateLinkHubsClient) BeginDelete(ctx context.Context, resourceGr if err != nil { return nil, err } - return runtime.NewPoller[PrivateLinkHubsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[PrivateLinkHubsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[PrivateLinkHubsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PrivateLinkHubsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -143,7 +132,7 @@ func (client *PrivateLinkHubsClient) deleteOperation(ctx context.Context, resour if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -168,7 +157,7 @@ func (client *PrivateLinkHubsClient) deleteCreateRequest(ctx context.Context, re return nil, errors.New("parameter privateLinkHubName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateLinkHubName}", url.PathEscape(privateLinkHubName)) - 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 } @@ -191,7 +180,7 @@ func (client *PrivateLinkHubsClient) Get(ctx context.Context, resourceGroupName if err != nil { return PrivateLinkHubsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkHubsClientGetResponse{}, err } @@ -216,7 +205,7 @@ func (client *PrivateLinkHubsClient) getCreateRequest(ctx context.Context, resou return nil, errors.New("parameter privateLinkHubName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateLinkHubName}", url.PathEscape(privateLinkHubName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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,7 +246,7 @@ func (client *PrivateLinkHubsClient) NewListPager(options *PrivateLinkHubsClient if err != nil { return PrivateLinkHubsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkHubsClientListResponse{}, err } @@ -276,7 +265,7 @@ func (client *PrivateLinkHubsClient) listCreateRequest(ctx context.Context, opti 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 } @@ -318,7 +307,7 @@ func (client *PrivateLinkHubsClient) NewListByResourceGroupPager(resourceGroupNa if err != nil { return PrivateLinkHubsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkHubsClientListByResourceGroupResponse{}, err } @@ -341,7 +330,7 @@ func (client *PrivateLinkHubsClient) 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 } @@ -374,7 +363,7 @@ func (client *PrivateLinkHubsClient) Update(ctx context.Context, resourceGroupNa if err != nil { return PrivateLinkHubsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkHubsClientUpdateResponse{}, err } @@ -399,7 +388,7 @@ func (client *PrivateLinkHubsClient) updateCreateRequest(ctx context.Context, re return nil, errors.New("parameter privateLinkHubName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateLinkHubName}", url.PathEscape(privateLinkHubName)) - 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/synapse/armsynapse/privatelinkhubs_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/privatelinkhubs_client_example_test.go index 043399396b06..1887f742feb2 100644 --- a/sdk/resourcemanager/synapse/armsynapse/privatelinkhubs_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/privatelinkhubs_client_example_test.go @@ -25,11 +25,11 @@ func ExamplePrivateLinkHubsClient_NewListByResourceGroupPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewPrivateLinkHubsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("resourceGroup1", nil) + pager := clientFactory.NewPrivateLinkHubsClient().NewListByResourceGroupPager("resourceGroup1", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -77,11 +77,11 @@ func ExamplePrivateLinkHubsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewPrivateLinkHubsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "resourceGroup1", "privateLinkHub1", nil) + res, err := clientFactory.NewPrivateLinkHubsClient().Get(ctx, "resourceGroup1", "privateLinkHub1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -109,11 +109,11 @@ func ExamplePrivateLinkHubsClient_Update() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewPrivateLinkHubsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "resourceGroup1", "privateLinkHub1", armsynapse.PrivateLinkHubPatchInfo{ + res, err := clientFactory.NewPrivateLinkHubsClient().Update(ctx, "resourceGroup1", "privateLinkHub1", armsynapse.PrivateLinkHubPatchInfo{ Tags: map[string]*string{ "key": to.Ptr("value"), }, @@ -145,11 +145,11 @@ func ExamplePrivateLinkHubsClient_CreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewPrivateLinkHubsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "resourceGroup1", "privateLinkHub1", armsynapse.PrivateLinkHub{ + res, err := clientFactory.NewPrivateLinkHubsClient().CreateOrUpdate(ctx, "resourceGroup1", "privateLinkHub1", armsynapse.PrivateLinkHub{ Location: to.Ptr("East US"), Tags: map[string]*string{ "key": to.Ptr("value"), @@ -183,11 +183,11 @@ func ExamplePrivateLinkHubsClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewPrivateLinkHubsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "resourceGroup1", "privateLinkHub1", nil) + poller, err := clientFactory.NewPrivateLinkHubsClient().BeginDelete(ctx, "resourceGroup1", "privateLinkHub1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -204,11 +204,11 @@ func ExamplePrivateLinkHubsClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewPrivateLinkHubsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewPrivateLinkHubsClient().NewListPager(nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/privatelinkresources_client.go b/sdk/resourcemanager/synapse/armsynapse/privatelinkresources_client.go index e595346fd400..365f96fd0902 100644 --- a/sdk/resourcemanager/synapse/armsynapse/privatelinkresources_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/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,9 +24,8 @@ 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. @@ -36,21 +33,13 @@ type PrivateLinkResourcesClient struct { // - 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 } @@ -69,7 +58,7 @@ func (client *PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroup 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 } @@ -98,7 +87,7 @@ func (client *PrivateLinkResourcesClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter privateLinkResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{privateLinkResourceName}", url.PathEscape(privateLinkResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -141,7 +130,7 @@ func (client *PrivateLinkResourcesClient) NewListPager(resourceGroupName string, if err != nil { return PrivateLinkResourcesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkResourcesClientListResponse{}, err } @@ -168,7 +157,7 @@ func (client *PrivateLinkResourcesClient) listCreateRequest(ctx context.Context, return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/privatelinkresources_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/privatelinkresources_client_example_test.go index 670d1f153668..5c9c5fe32492 100644 --- a/sdk/resourcemanager/synapse/armsynapse/privatelinkresources_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/privatelinkresources_client_example_test.go @@ -24,11 +24,11 @@ func ExamplePrivateLinkResourcesClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewPrivateLinkResourcesClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("ExampleResourceGroup", "ExampleWorkspace", nil) + pager := clientFactory.NewPrivateLinkResourcesClient().NewListPager("ExampleResourceGroup", "ExampleWorkspace", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -64,11 +64,11 @@ func ExamplePrivateLinkResourcesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewPrivateLinkResourcesClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "ExampleResourceGroup", "ExampleWorkspace", "sql", nil) + res, err := clientFactory.NewPrivateLinkResourcesClient().Get(ctx, "ExampleResourceGroup", "ExampleWorkspace", "sql", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/restorabledroppedsqlpools_client.go b/sdk/resourcemanager/synapse/armsynapse/restorabledroppedsqlpools_client.go index 11ab498ba83f..5c7898b166ae 100644 --- a/sdk/resourcemanager/synapse/armsynapse/restorabledroppedsqlpools_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/restorabledroppedsqlpools_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // RestorableDroppedSQLPoolsClient contains the methods for the RestorableDroppedSQLPools group. // Don't use this type directly, use NewRestorableDroppedSQLPoolsClient() instead. type RestorableDroppedSQLPoolsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewRestorableDroppedSQLPoolsClient creates a new instance of RestorableDroppedSQLPoolsClient with the specified values. @@ -36,21 +33,13 @@ type RestorableDroppedSQLPoolsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewRestorableDroppedSQLPoolsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RestorableDroppedSQLPoolsClient, 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+".RestorableDroppedSQLPoolsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &RestorableDroppedSQLPoolsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -69,7 +58,7 @@ func (client *RestorableDroppedSQLPoolsClient) Get(ctx context.Context, resource if err != nil { return RestorableDroppedSQLPoolsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RestorableDroppedSQLPoolsClientGetResponse{}, err } @@ -98,7 +87,7 @@ func (client *RestorableDroppedSQLPoolsClient) getCreateRequest(ctx context.Cont return nil, errors.New("parameter restorableDroppedSQLPoolID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{restorableDroppedSqlPoolId}", url.PathEscape(restorableDroppedSQLPoolID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -135,7 +124,7 @@ func (client *RestorableDroppedSQLPoolsClient) NewListByWorkspacePager(resourceG if err != nil { return RestorableDroppedSQLPoolsClientListByWorkspaceResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RestorableDroppedSQLPoolsClientListByWorkspaceResponse{}, err } @@ -162,7 +151,7 @@ func (client *RestorableDroppedSQLPoolsClient) listByWorkspaceCreateRequest(ctx return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/restorabledroppedsqlpools_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/restorabledroppedsqlpools_client_example_test.go index 3b24c6d5e0d8..7c7483cf3b77 100644 --- a/sdk/resourcemanager/synapse/armsynapse/restorabledroppedsqlpools_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/restorabledroppedsqlpools_client_example_test.go @@ -24,11 +24,11 @@ func ExampleRestorableDroppedSQLPoolsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewRestorableDroppedSQLPoolsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "restorabledroppeddatabasetest-1257", "restorabledroppeddatabasetest-2389", "restorabledroppeddatabasetest-7654,131403269876900000", nil) + res, err := clientFactory.NewRestorableDroppedSQLPoolsClient().Get(ctx, "restorabledroppeddatabasetest-1257", "restorabledroppeddatabasetest-2389", "restorabledroppeddatabasetest-7654,131403269876900000", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -59,11 +59,11 @@ func ExampleRestorableDroppedSQLPoolsClient_NewListByWorkspacePager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewRestorableDroppedSQLPoolsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByWorkspacePager("restorabledroppeddatabasetest-1349", "restorabledroppeddatabasetest-1840", nil) + pager := clientFactory.NewRestorableDroppedSQLPoolsClient().NewListByWorkspacePager("restorabledroppeddatabasetest-1349", "restorabledroppeddatabasetest-1840", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/sparkconfiguration_client.go b/sdk/resourcemanager/synapse/armsynapse/sparkconfiguration_client.go index 9d139dc2f476..4b9f787f7f30 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sparkconfiguration_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sparkconfiguration_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SparkConfigurationClient contains the methods for the SparkConfiguration group. // Don't use this type directly, use NewSparkConfigurationClient() instead. type SparkConfigurationClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSparkConfigurationClient creates a new instance of SparkConfigurationClient with the specified values. @@ -36,21 +33,13 @@ type SparkConfigurationClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSparkConfigurationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SparkConfigurationClient, 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+".SparkConfigurationClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SparkConfigurationClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -68,7 +57,7 @@ func (client *SparkConfigurationClient) Get(ctx context.Context, resourceGroupNa if err != nil { return SparkConfigurationClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SparkConfigurationClientGetResponse{}, err } @@ -97,7 +86,7 @@ func (client *SparkConfigurationClient) getCreateRequest(ctx context.Context, re return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sparkconfiguration_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sparkconfiguration_client_example_test.go index 4728f95414bb..602155a87242 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sparkconfiguration_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sparkconfiguration_client_example_test.go @@ -24,11 +24,11 @@ func ExampleSparkConfigurationClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSparkConfigurationClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "exampleResourceGroup", "exampleSparkConfigurationName", "exampleWorkspace", nil) + res, err := clientFactory.NewSparkConfigurationClient().Get(ctx, "exampleResourceGroup", "exampleSparkConfigurationName", "exampleWorkspace", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/sparkconfigurations_client.go b/sdk/resourcemanager/synapse/armsynapse/sparkconfigurations_client.go index 7389bbc0b3f0..7d402cc68d0e 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sparkconfigurations_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sparkconfigurations_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SparkConfigurationsClient contains the methods for the SparkConfigurations group. // Don't use this type directly, use NewSparkConfigurationsClient() instead. type SparkConfigurationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSparkConfigurationsClient creates a new instance of SparkConfigurationsClient with the specified values. @@ -36,21 +33,13 @@ type SparkConfigurationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSparkConfigurationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SparkConfigurationsClient, 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+".SparkConfigurationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SparkConfigurationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -78,7 +67,7 @@ func (client *SparkConfigurationsClient) NewListByWorkspacePager(resourceGroupNa if err != nil { return SparkConfigurationsClientListByWorkspaceResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SparkConfigurationsClientListByWorkspaceResponse{}, err } @@ -105,7 +94,7 @@ func (client *SparkConfigurationsClient) listByWorkspaceCreateRequest(ctx contex return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sparkconfigurations_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sparkconfigurations_client_example_test.go index d7d05aabfe24..3f99551282e1 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sparkconfigurations_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sparkconfigurations_client_example_test.go @@ -24,11 +24,11 @@ func ExampleSparkConfigurationsClient_NewListByWorkspacePager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSparkConfigurationsClient("12345678-1234-1234-1234-12345678abc", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByWorkspacePager("exampleResourceGroup", "exampleWorkspace", nil) + pager := clientFactory.NewSparkConfigurationsClient().NewListByWorkspacePager("exampleResourceGroup", "exampleWorkspace", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpoolblobauditingpolicies_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolblobauditingpolicies_client.go index 945b9c5849f2..35cc37787d96 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolblobauditingpolicies_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolblobauditingpolicies_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolBlobAuditingPoliciesClient contains the methods for the SQLPoolBlobAuditingPolicies group. // Don't use this type directly, use NewSQLPoolBlobAuditingPoliciesClient() instead. type SQLPoolBlobAuditingPoliciesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolBlobAuditingPoliciesClient creates a new instance of SQLPoolBlobAuditingPoliciesClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolBlobAuditingPoliciesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolBlobAuditingPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolBlobAuditingPoliciesClient, 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+".SQLPoolBlobAuditingPoliciesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolBlobAuditingPoliciesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,7 +59,7 @@ func (client *SQLPoolBlobAuditingPoliciesClient) CreateOrUpdate(ctx context.Cont if err != nil { return SQLPoolBlobAuditingPoliciesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolBlobAuditingPoliciesClientCreateOrUpdateResponse{}, err } @@ -100,7 +89,7 @@ func (client *SQLPoolBlobAuditingPoliciesClient) createOrUpdateCreateRequest(ctx } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) urlPath = strings.ReplaceAll(urlPath, "{blobAuditingPolicyName}", url.PathEscape("default")) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -134,7 +123,7 @@ func (client *SQLPoolBlobAuditingPoliciesClient) Get(ctx context.Context, resour if err != nil { return SQLPoolBlobAuditingPoliciesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolBlobAuditingPoliciesClientGetResponse{}, err } @@ -164,7 +153,7 @@ func (client *SQLPoolBlobAuditingPoliciesClient) getCreateRequest(ctx context.Co } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) urlPath = strings.ReplaceAll(urlPath, "{blobAuditingPolicyName}", url.PathEscape("default")) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -208,7 +197,7 @@ func (client *SQLPoolBlobAuditingPoliciesClient) NewListBySQLPoolPager(resourceG if err != nil { return SQLPoolBlobAuditingPoliciesClientListBySQLPoolResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolBlobAuditingPoliciesClientListBySQLPoolResponse{}, err } @@ -239,7 +228,7 @@ func (client *SQLPoolBlobAuditingPoliciesClient) listBySQLPoolCreateRequest(ctx return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpoolblobauditingpolicies_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolblobauditingpolicies_client_example_test.go index 32d89c598830..b7d98cdcb80b 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolblobauditingpolicies_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolblobauditingpolicies_client_example_test.go @@ -25,11 +25,11 @@ func ExampleSQLPoolBlobAuditingPoliciesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolBlobAuditingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "blobauditingtest-6852", "blobauditingtest-2080", "testdb", nil) + res, err := clientFactory.NewSQLPoolBlobAuditingPoliciesClient().Get(ctx, "blobauditingtest-6852", "blobauditingtest-2080", "testdb", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -61,11 +61,11 @@ func ExampleSQLPoolBlobAuditingPoliciesClient_CreateOrUpdate_createOrUpdateAData log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolBlobAuditingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "blobauditingtest-4799", "blobauditingtest-6440", "testdb", armsynapse.SQLPoolBlobAuditingPolicy{ + res, err := clientFactory.NewSQLPoolBlobAuditingPoliciesClient().CreateOrUpdate(ctx, "blobauditingtest-4799", "blobauditingtest-6440", "testdb", armsynapse.SQLPoolBlobAuditingPolicy{ Properties: &armsynapse.SQLPoolBlobAuditingPolicyProperties{ AuditActionsAndGroups: []*string{ to.Ptr("DATABASE_LOGOUT_GROUP"), @@ -113,11 +113,11 @@ func ExampleSQLPoolBlobAuditingPoliciesClient_CreateOrUpdate_createOrUpdateAData log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolBlobAuditingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "blobauditingtest-4799", "blobauditingtest-6440", "testdb", armsynapse.SQLPoolBlobAuditingPolicy{ + res, err := clientFactory.NewSQLPoolBlobAuditingPoliciesClient().CreateOrUpdate(ctx, "blobauditingtest-4799", "blobauditingtest-6440", "testdb", armsynapse.SQLPoolBlobAuditingPolicy{ Properties: &armsynapse.SQLPoolBlobAuditingPolicyProperties{ State: to.Ptr(armsynapse.BlobAuditingPolicyStateEnabled), StorageAccountAccessKey: to.Ptr("sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD=="), @@ -157,11 +157,11 @@ func ExampleSQLPoolBlobAuditingPoliciesClient_NewListBySQLPoolPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolBlobAuditingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListBySQLPoolPager("blobauditingtest-6852", "blobauditingtest-2080", "testdb", nil) + pager := clientFactory.NewSQLPoolBlobAuditingPoliciesClient().NewListBySQLPoolPager("blobauditingtest-6852", "blobauditingtest-2080", "testdb", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpoolcolumns_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolcolumns_client.go index a7aca43c6059..0a48dc837e92 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolcolumns_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolcolumns_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolColumnsClient contains the methods for the SQLPoolColumns group. // Don't use this type directly, use NewSQLPoolColumnsClient() instead. type SQLPoolColumnsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolColumnsClient creates a new instance of SQLPoolColumnsClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolColumnsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolColumnsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolColumnsClient, 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+".SQLPoolColumnsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolColumnsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,7 +60,7 @@ func (client *SQLPoolColumnsClient) Get(ctx context.Context, resourceGroupName s if err != nil { return SQLPoolColumnsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolColumnsClientGetResponse{}, err } @@ -112,7 +101,7 @@ func (client *SQLPoolColumnsClient) getCreateRequest(ctx context.Context, resour return nil, errors.New("parameter columnName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{columnName}", url.PathEscape(columnName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpoolcolumns_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolcolumns_client_example_test.go index 9c66343172f2..e34db00e0e9d 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolcolumns_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolcolumns_client_example_test.go @@ -24,11 +24,11 @@ func ExampleSQLPoolColumnsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolColumnsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "myRG", "serverName", "myDatabase", "dbo", "table1", "column1", nil) + res, err := clientFactory.NewSQLPoolColumnsClient().Get(ctx, "myRG", "serverName", "myDatabase", "dbo", "table1", "column1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpoolconnectionpolicies_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolconnectionpolicies_client.go index 243b31b2cb15..817d83fb6ad3 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolconnectionpolicies_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolconnectionpolicies_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolConnectionPoliciesClient contains the methods for the SQLPoolConnectionPolicies group. // Don't use this type directly, use NewSQLPoolConnectionPoliciesClient() instead. type SQLPoolConnectionPoliciesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolConnectionPoliciesClient creates a new instance of SQLPoolConnectionPoliciesClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolConnectionPoliciesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolConnectionPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolConnectionPoliciesClient, 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+".SQLPoolConnectionPoliciesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolConnectionPoliciesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,7 +59,7 @@ func (client *SQLPoolConnectionPoliciesClient) Get(ctx context.Context, resource if err != nil { return SQLPoolConnectionPoliciesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolConnectionPoliciesClientGetResponse{}, err } @@ -103,7 +92,7 @@ func (client *SQLPoolConnectionPoliciesClient) getCreateRequest(ctx context.Cont return nil, errors.New("parameter connectionPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{connectionPolicyName}", url.PathEscape(string(connectionPolicyName))) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpoolconnectionpolicies_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolconnectionpolicies_client_example_test.go index cafb9204a133..ee08db909a22 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolconnectionpolicies_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolconnectionpolicies_client_example_test.go @@ -24,11 +24,11 @@ func ExampleSQLPoolConnectionPoliciesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolConnectionPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "blobauditingtest-6852", "blobauditingtest-2080", "testdb", armsynapse.ConnectionPolicyNameDefault, nil) + res, err := clientFactory.NewSQLPoolConnectionPoliciesClient().Get(ctx, "blobauditingtest-6852", "blobauditingtest-2080", "testdb", armsynapse.ConnectionPolicyNameDefault, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpooldatawarehouseuseractivities_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpooldatawarehouseuseractivities_client.go index 781c7b14b65b..7e6b9ec351eb 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpooldatawarehouseuseractivities_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpooldatawarehouseuseractivities_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolDataWarehouseUserActivitiesClient contains the methods for the SQLPoolDataWarehouseUserActivities group. // Don't use this type directly, use NewSQLPoolDataWarehouseUserActivitiesClient() instead. type SQLPoolDataWarehouseUserActivitiesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolDataWarehouseUserActivitiesClient creates a new instance of SQLPoolDataWarehouseUserActivitiesClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolDataWarehouseUserActivitiesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolDataWarehouseUserActivitiesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolDataWarehouseUserActivitiesClient, 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+".SQLPoolDataWarehouseUserActivitiesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolDataWarehouseUserActivitiesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,7 +59,7 @@ func (client *SQLPoolDataWarehouseUserActivitiesClient) Get(ctx context.Context, if err != nil { return SQLPoolDataWarehouseUserActivitiesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolDataWarehouseUserActivitiesClientGetResponse{}, err } @@ -103,7 +92,7 @@ func (client *SQLPoolDataWarehouseUserActivitiesClient) getCreateRequest(ctx con return nil, errors.New("parameter dataWarehouseUserActivityName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dataWarehouseUserActivityName}", url.PathEscape(string(dataWarehouseUserActivityName))) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpooldatawarehouseuseractivities_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpooldatawarehouseuseractivities_client_example_test.go index 46cfab1b76e8..eddc3272c6c1 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpooldatawarehouseuseractivities_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpooldatawarehouseuseractivities_client_example_test.go @@ -24,11 +24,11 @@ func ExampleSQLPoolDataWarehouseUserActivitiesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolDataWarehouseUserActivitiesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "Default-SQL-SouthEastAsia", "testsvr", "testdb", armsynapse.DataWarehouseUserActivityNameCurrent, nil) + res, err := clientFactory.NewSQLPoolDataWarehouseUserActivitiesClient().Get(ctx, "Default-SQL-SouthEastAsia", "testsvr", "testdb", armsynapse.DataWarehouseUserActivityNameCurrent, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpoolgeobackuppolicies_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolgeobackuppolicies_client.go index 8f4a7892ae85..1cecdd4d66f1 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolgeobackuppolicies_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolgeobackuppolicies_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolGeoBackupPoliciesClient contains the methods for the SQLPoolGeoBackupPolicies group. // Don't use this type directly, use NewSQLPoolGeoBackupPoliciesClient() instead. type SQLPoolGeoBackupPoliciesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolGeoBackupPoliciesClient creates a new instance of SQLPoolGeoBackupPoliciesClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolGeoBackupPoliciesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolGeoBackupPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolGeoBackupPoliciesClient, 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+".SQLPoolGeoBackupPoliciesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolGeoBackupPoliciesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,7 +60,7 @@ func (client *SQLPoolGeoBackupPoliciesClient) CreateOrUpdate(ctx context.Context if err != nil { return SQLPoolGeoBackupPoliciesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolGeoBackupPoliciesClientCreateOrUpdateResponse{}, err } @@ -104,7 +93,7 @@ func (client *SQLPoolGeoBackupPoliciesClient) createOrUpdateCreateRequest(ctx co return nil, errors.New("parameter geoBackupPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{geoBackupPolicyName}", url.PathEscape(string(geoBackupPolicyName))) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -139,7 +128,7 @@ func (client *SQLPoolGeoBackupPoliciesClient) Get(ctx context.Context, resourceG if err != nil { return SQLPoolGeoBackupPoliciesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolGeoBackupPoliciesClientGetResponse{}, err } @@ -172,7 +161,7 @@ func (client *SQLPoolGeoBackupPoliciesClient) getCreateRequest(ctx context.Conte return nil, errors.New("parameter geoBackupPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{geoBackupPolicyName}", url.PathEscape(string(geoBackupPolicyName))) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -210,7 +199,7 @@ func (client *SQLPoolGeoBackupPoliciesClient) NewListPager(resourceGroupName str if err != nil { return SQLPoolGeoBackupPoliciesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolGeoBackupPoliciesClientListResponse{}, err } @@ -241,7 +230,7 @@ func (client *SQLPoolGeoBackupPoliciesClient) listCreateRequest(ctx context.Cont return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpoolgeobackuppolicies_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolgeobackuppolicies_client_example_test.go index dd6a2ab30e1c..c593024ad9b8 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolgeobackuppolicies_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolgeobackuppolicies_client_example_test.go @@ -25,11 +25,11 @@ func ExampleSQLPoolGeoBackupPoliciesClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolGeoBackupPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("sqlcrudtest-4799", "sqlcrudtest-5961", "testdw", nil) + pager := clientFactory.NewSQLPoolGeoBackupPoliciesClient().NewListPager("sqlcrudtest-4799", "sqlcrudtest-5961", "testdw", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -63,11 +63,11 @@ func ExampleSQLPoolGeoBackupPoliciesClient_CreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolGeoBackupPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "testrg", "testws", "testdw", armsynapse.GeoBackupPolicyNameDefault, armsynapse.GeoBackupPolicy{ + res, err := clientFactory.NewSQLPoolGeoBackupPoliciesClient().CreateOrUpdate(ctx, "testrg", "testws", "testdw", armsynapse.GeoBackupPolicyNameDefault, armsynapse.GeoBackupPolicy{ Properties: &armsynapse.GeoBackupPolicyProperties{ State: to.Ptr(armsynapse.GeoBackupPolicyStateEnabled), }, @@ -95,11 +95,11 @@ func ExampleSQLPoolGeoBackupPoliciesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolGeoBackupPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "sqlcrudtest-4799", "sqlcrudtest-5961", "testdw", armsynapse.GeoBackupPolicyNameDefault, nil) + res, err := clientFactory.NewSQLPoolGeoBackupPoliciesClient().Get(ctx, "sqlcrudtest-4799", "sqlcrudtest-5961", "testdw", armsynapse.GeoBackupPolicyNameDefault, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpoolmaintenancewindowoptions_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolmaintenancewindowoptions_client.go index 1d55c8915750..b4313d197bf4 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolmaintenancewindowoptions_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolmaintenancewindowoptions_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolMaintenanceWindowOptionsClient contains the methods for the SQLPoolMaintenanceWindowOptions group. // Don't use this type directly, use NewSQLPoolMaintenanceWindowOptionsClient() instead. type SQLPoolMaintenanceWindowOptionsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolMaintenanceWindowOptionsClient creates a new instance of SQLPoolMaintenanceWindowOptionsClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolMaintenanceWindowOptionsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolMaintenanceWindowOptionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolMaintenanceWindowOptionsClient, 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+".SQLPoolMaintenanceWindowOptionsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolMaintenanceWindowOptionsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,7 +59,7 @@ func (client *SQLPoolMaintenanceWindowOptionsClient) Get(ctx context.Context, re if err != nil { return SQLPoolMaintenanceWindowOptionsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolMaintenanceWindowOptionsClientGetResponse{}, err } @@ -99,7 +88,7 @@ func (client *SQLPoolMaintenanceWindowOptionsClient) getCreateRequest(ctx contex return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpoolmaintenancewindowoptions_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolmaintenancewindowoptions_client_example_test.go index 1acf817b22ee..927d993e3296 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolmaintenancewindowoptions_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolmaintenancewindowoptions_client_example_test.go @@ -24,11 +24,11 @@ func ExampleSQLPoolMaintenanceWindowOptionsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolMaintenanceWindowOptionsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "samplerg", "testworkspace", "testsp", "current", nil) + res, err := clientFactory.NewSQLPoolMaintenanceWindowOptionsClient().Get(ctx, "samplerg", "testworkspace", "testsp", "current", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpoolmaintenancewindows_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolmaintenancewindows_client.go index 6ffa27297a90..0974103c8d72 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolmaintenancewindows_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolmaintenancewindows_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolMaintenanceWindowsClient contains the methods for the SQLPoolMaintenanceWindows group. // Don't use this type directly, use NewSQLPoolMaintenanceWindowsClient() instead. type SQLPoolMaintenanceWindowsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolMaintenanceWindowsClient creates a new instance of SQLPoolMaintenanceWindowsClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolMaintenanceWindowsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolMaintenanceWindowsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolMaintenanceWindowsClient, 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+".SQLPoolMaintenanceWindowsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolMaintenanceWindowsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,7 +60,7 @@ func (client *SQLPoolMaintenanceWindowsClient) CreateOrUpdate(ctx context.Contex if err != nil { return SQLPoolMaintenanceWindowsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolMaintenanceWindowsClientCreateOrUpdateResponse{}, err } @@ -100,7 +89,7 @@ func (client *SQLPoolMaintenanceWindowsClient) createOrUpdateCreateRequest(ctx c return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - 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,7 +115,7 @@ func (client *SQLPoolMaintenanceWindowsClient) Get(ctx context.Context, resource if err != nil { return SQLPoolMaintenanceWindowsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolMaintenanceWindowsClientGetResponse{}, err } @@ -155,7 +144,7 @@ func (client *SQLPoolMaintenanceWindowsClient) getCreateRequest(ctx context.Cont return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpoolmaintenancewindows_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolmaintenancewindows_client_example_test.go index 75f0dc3ea806..deb77c2f4517 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolmaintenancewindows_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolmaintenancewindows_client_example_test.go @@ -25,11 +25,11 @@ func ExampleSQLPoolMaintenanceWindowsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolMaintenanceWindowsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "samplerg", "testworkspace", "testsp", "current", nil) + res, err := clientFactory.NewSQLPoolMaintenanceWindowsClient().Get(ctx, "samplerg", "testworkspace", "testsp", "current", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -58,11 +58,11 @@ func ExampleSQLPoolMaintenanceWindowsClient_CreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolMaintenanceWindowsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.CreateOrUpdate(ctx, "samplerg", "testworkspace", "testsp", "current", armsynapse.MaintenanceWindows{ + _, err = clientFactory.NewSQLPoolMaintenanceWindowsClient().CreateOrUpdate(ctx, "samplerg", "testworkspace", "testsp", "current", armsynapse.MaintenanceWindows{ Properties: &armsynapse.MaintenanceWindowsProperties{ TimeRanges: []*armsynapse.MaintenanceWindowTimeRange{ { diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpoolmetadatasyncconfigs_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolmetadatasyncconfigs_client.go index 5671cc49c8b9..1fa624aa20e9 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolmetadatasyncconfigs_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolmetadatasyncconfigs_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolMetadataSyncConfigsClient contains the methods for the SQLPoolMetadataSyncConfigs group. // Don't use this type directly, use NewSQLPoolMetadataSyncConfigsClient() instead. type SQLPoolMetadataSyncConfigsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolMetadataSyncConfigsClient creates a new instance of SQLPoolMetadataSyncConfigsClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolMetadataSyncConfigsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolMetadataSyncConfigsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolMetadataSyncConfigsClient, 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+".SQLPoolMetadataSyncConfigsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolMetadataSyncConfigsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,7 +59,7 @@ func (client *SQLPoolMetadataSyncConfigsClient) Create(ctx context.Context, reso if err != nil { return SQLPoolMetadataSyncConfigsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolMetadataSyncConfigsClientCreateResponse{}, err } @@ -99,7 +88,7 @@ func (client *SQLPoolMetadataSyncConfigsClient) createCreateRequest(ctx context. return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - 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,7 +122,7 @@ func (client *SQLPoolMetadataSyncConfigsClient) Get(ctx context.Context, resourc if err != nil { return SQLPoolMetadataSyncConfigsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolMetadataSyncConfigsClientGetResponse{}, err } @@ -162,7 +151,7 @@ func (client *SQLPoolMetadataSyncConfigsClient) getCreateRequest(ctx context.Con return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpoolmetadatasyncconfigs_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolmetadatasyncconfigs_client_example_test.go index c94eaabc5684..ebdc9c0ad756 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolmetadatasyncconfigs_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolmetadatasyncconfigs_client_example_test.go @@ -25,11 +25,11 @@ func ExampleSQLPoolMetadataSyncConfigsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolMetadataSyncConfigsClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExampleSqlPool", nil) + res, err := clientFactory.NewSQLPoolMetadataSyncConfigsClient().Get(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExampleSqlPool", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -53,11 +53,11 @@ func ExampleSQLPoolMetadataSyncConfigsClient_Create() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolMetadataSyncConfigsClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Create(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExampleSqlPool", armsynapse.MetadataSyncConfig{ + res, err := clientFactory.NewSQLPoolMetadataSyncConfigsClient().Create(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExampleSqlPool", armsynapse.MetadataSyncConfig{ Properties: &armsynapse.MetadataSyncConfigProperties{ Enabled: to.Ptr(true), }, diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpooloperationresults_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpooloperationresults_client.go index acfdbea278dc..0b3a900e95b1 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpooloperationresults_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpooloperationresults_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolOperationResultsClient contains the methods for the SQLPoolOperationResults group. // Don't use this type directly, use NewSQLPoolOperationResultsClient() instead. type SQLPoolOperationResultsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolOperationResultsClient creates a new instance of SQLPoolOperationResultsClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolOperationResultsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolOperationResultsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolOperationResultsClient, 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+".SQLPoolOperationResultsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolOperationResultsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,9 +60,9 @@ func (client *SQLPoolOperationResultsClient) BeginGetLocationHeaderResult(ctx co if err != nil { return nil, err } - return runtime.NewPoller[SQLPoolOperationResultsClientGetLocationHeaderResultResponse](resp, client.pl, nil) + return runtime.NewPoller[SQLPoolOperationResultsClientGetLocationHeaderResultResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[SQLPoolOperationResultsClientGetLocationHeaderResultResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SQLPoolOperationResultsClientGetLocationHeaderResultResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -86,7 +75,7 @@ func (client *SQLPoolOperationResultsClient) getLocationHeaderResult(ctx context 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 } @@ -119,7 +108,7 @@ func (client *SQLPoolOperationResultsClient) getLocationHeaderResultCreateReques return nil, errors.New("parameter operationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpooloperationresults_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpooloperationresults_client_example_test.go index b6f3a4460f5b..bc57ef3f2395 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpooloperationresults_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpooloperationresults_client_example_test.go @@ -24,11 +24,11 @@ func ExampleSQLPoolOperationResultsClient_BeginGetLocationHeaderResult() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolOperationResultsClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginGetLocationHeaderResult(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExampleSqlPool", "fedcba98-7654-4210-fedc-ba9876543210", nil) + poller, err := clientFactory.NewSQLPoolOperationResultsClient().BeginGetLocationHeaderResult(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExampleSqlPool", "fedcba98-7654-4210-fedc-ba9876543210", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpooloperations_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpooloperations_client.go index 5f4e933d4051..edbf4a50acb1 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpooloperations_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpooloperations_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolOperationsClient contains the methods for the SQLPoolOperations group. // Don't use this type directly, use NewSQLPoolOperationsClient() instead. type SQLPoolOperationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolOperationsClient creates a new instance of SQLPoolOperationsClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolOperationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolOperationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolOperationsClient, 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+".SQLPoolOperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolOperationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -79,7 +68,7 @@ func (client *SQLPoolOperationsClient) NewListPager(resourceGroupName string, wo if err != nil { return SQLPoolOperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolOperationsClientListResponse{}, err } @@ -110,7 +99,7 @@ func (client *SQLPoolOperationsClient) listCreateRequest(ctx context.Context, re return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpooloperations_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpooloperations_client_example_test.go index 1fd1e53c085d..b684204934cc 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpooloperations_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpooloperations_client_example_test.go @@ -24,11 +24,11 @@ func ExampleSQLPoolOperationsClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolOperationsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("sqlcrudtest-7398", "sqlcrudtest-4645", "testdb", nil) + pager := clientFactory.NewSQLPoolOperationsClient().NewListPager("sqlcrudtest-7398", "sqlcrudtest-4645", "testdb", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpoolrecommendedsensitivitylabels_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolrecommendedsensitivitylabels_client.go index d222a63d98f1..97230f2f4883 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolrecommendedsensitivitylabels_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolrecommendedsensitivitylabels_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolRecommendedSensitivityLabelsClient contains the methods for the SQLPoolRecommendedSensitivityLabels group. // Don't use this type directly, use NewSQLPoolRecommendedSensitivityLabelsClient() instead. type SQLPoolRecommendedSensitivityLabelsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolRecommendedSensitivityLabelsClient creates a new instance of SQLPoolRecommendedSensitivityLabelsClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolRecommendedSensitivityLabelsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolRecommendedSensitivityLabelsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolRecommendedSensitivityLabelsClient, 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+".SQLPoolRecommendedSensitivityLabelsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolRecommendedSensitivityLabelsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -69,7 +58,7 @@ func (client *SQLPoolRecommendedSensitivityLabelsClient) Update(ctx context.Cont if err != nil { return SQLPoolRecommendedSensitivityLabelsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolRecommendedSensitivityLabelsClientUpdateResponse{}, err } @@ -98,7 +87,7 @@ func (client *SQLPoolRecommendedSensitivityLabelsClient) updateCreateRequest(ctx return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - 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/synapse/armsynapse/sqlpoolrecommendedsensitivitylabels_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolrecommendedsensitivitylabels_client_example_test.go index c26db980949f..4c1517c0a230 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolrecommendedsensitivitylabels_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolrecommendedsensitivitylabels_client_example_test.go @@ -25,11 +25,11 @@ func ExampleSQLPoolRecommendedSensitivityLabelsClient_Update() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolRecommendedSensitivityLabelsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Update(ctx, "myRG", "myWorkspace", "mySqlPool", armsynapse.RecommendedSensitivityLabelUpdateList{ + _, err = clientFactory.NewSQLPoolRecommendedSensitivityLabelsClient().Update(ctx, "myRG", "myWorkspace", "mySqlPool", armsynapse.RecommendedSensitivityLabelUpdateList{ Operations: []*armsynapse.RecommendedSensitivityLabelUpdate{ { Properties: &armsynapse.RecommendedSensitivityLabelUpdateProperties{ diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpoolreplicationlinks_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolreplicationlinks_client.go index 1de7bd223b6d..2b22afa39200 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolreplicationlinks_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolreplicationlinks_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolReplicationLinksClient contains the methods for the SQLPoolReplicationLinks group. // Don't use this type directly, use NewSQLPoolReplicationLinksClient() instead. type SQLPoolReplicationLinksClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolReplicationLinksClient creates a new instance of SQLPoolReplicationLinksClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolReplicationLinksClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolReplicationLinksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolReplicationLinksClient, 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+".SQLPoolReplicationLinksClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolReplicationLinksClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,7 +59,7 @@ func (client *SQLPoolReplicationLinksClient) GetByName(ctx context.Context, reso if err != nil { return SQLPoolReplicationLinksClientGetByNameResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolReplicationLinksClientGetByNameResponse{}, err } @@ -103,7 +92,7 @@ func (client *SQLPoolReplicationLinksClient) getByNameCreateRequest(ctx context. return nil, errors.New("parameter linkID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{linkId}", url.PathEscape(linkID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -147,7 +136,7 @@ func (client *SQLPoolReplicationLinksClient) NewListPager(resourceGroupName stri if err != nil { return SQLPoolReplicationLinksClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolReplicationLinksClientListResponse{}, err } @@ -178,7 +167,7 @@ func (client *SQLPoolReplicationLinksClient) listCreateRequest(ctx context.Conte return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpoolreplicationlinks_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolreplicationlinks_client_example_test.go index e1ea539e7fc1..f3142df5fec5 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolreplicationlinks_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolreplicationlinks_client_example_test.go @@ -24,11 +24,11 @@ func ExampleSQLPoolReplicationLinksClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolReplicationLinksClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("sqlcrudtest-4799", "sqlcrudtest-6440", "testdb", nil) + pager := clientFactory.NewSQLPoolReplicationLinksClient().NewListPager("sqlcrudtest-4799", "sqlcrudtest-6440", "testdb", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -70,11 +70,11 @@ func ExampleSQLPoolReplicationLinksClient_GetByName() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolReplicationLinksClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.GetByName(ctx, "sqlcrudtest-4799", "sqlcrudtest-6440", "testdb", "5b301b68-03f6-4b26-b0f4-73ebb8634238", nil) + res, err := clientFactory.NewSQLPoolReplicationLinksClient().GetByName(ctx, "sqlcrudtest-4799", "sqlcrudtest-6440", "testdb", "5b301b68-03f6-4b26-b0f4-73ebb8634238", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpoolrestorepoints_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolrestorepoints_client.go index 880f24492149..b8067f0f0909 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolrestorepoints_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolrestorepoints_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolRestorePointsClient contains the methods for the SQLPoolRestorePoints group. // Don't use this type directly, use NewSQLPoolRestorePointsClient() instead. type SQLPoolRestorePointsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolRestorePointsClient creates a new instance of SQLPoolRestorePointsClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolRestorePointsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolRestorePointsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolRestorePointsClient, 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+".SQLPoolRestorePointsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolRestorePointsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,11 +60,11 @@ func (client *SQLPoolRestorePointsClient) BeginCreate(ctx context.Context, resou if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SQLPoolRestorePointsClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SQLPoolRestorePointsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[SQLPoolRestorePointsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SQLPoolRestorePointsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -88,7 +77,7 @@ func (client *SQLPoolRestorePointsClient) create(ctx context.Context, resourceGr 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 +106,7 @@ func (client *SQLPoolRestorePointsClient) createCreateRequest(ctx context.Contex return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - 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 } @@ -143,7 +132,7 @@ func (client *SQLPoolRestorePointsClient) Delete(ctx context.Context, resourceGr if err != nil { return SQLPoolRestorePointsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolRestorePointsClientDeleteResponse{}, err } @@ -176,7 +165,7 @@ func (client *SQLPoolRestorePointsClient) deleteCreateRequest(ctx context.Contex return nil, errors.New("parameter restorePointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{restorePointName}", url.PathEscape(restorePointName)) - 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 } @@ -201,7 +190,7 @@ func (client *SQLPoolRestorePointsClient) Get(ctx context.Context, resourceGroup if err != nil { return SQLPoolRestorePointsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolRestorePointsClientGetResponse{}, err } @@ -234,7 +223,7 @@ func (client *SQLPoolRestorePointsClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter restorePointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{restorePointName}", url.PathEscape(restorePointName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -278,7 +267,7 @@ func (client *SQLPoolRestorePointsClient) NewListPager(resourceGroupName string, if err != nil { return SQLPoolRestorePointsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolRestorePointsClientListResponse{}, err } @@ -309,7 +298,7 @@ func (client *SQLPoolRestorePointsClient) listCreateRequest(ctx context.Context, return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpoolrestorepoints_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolrestorepoints_client_example_test.go index c39cce72e203..7421816708d4 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolrestorepoints_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolrestorepoints_client_example_test.go @@ -25,11 +25,11 @@ func ExampleSQLPoolRestorePointsClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolRestorePointsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("Default-SQL-SouthEastAsia", "testserver", "testDatabase", nil) + pager := clientFactory.NewSQLPoolRestorePointsClient().NewListPager("Default-SQL-SouthEastAsia", "testserver", "testDatabase", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -85,11 +85,11 @@ func ExampleSQLPoolRestorePointsClient_BeginCreate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolRestorePointsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "Default-SQL-SouthEastAsia", "testserver", "testDatabase", armsynapse.CreateSQLPoolRestorePointDefinition{ + poller, err := clientFactory.NewSQLPoolRestorePointsClient().BeginCreate(ctx, "Default-SQL-SouthEastAsia", "testserver", "testDatabase", armsynapse.CreateSQLPoolRestorePointDefinition{ RestorePointLabel: to.Ptr("mylabel"), }, nil) if err != nil { @@ -122,11 +122,11 @@ func ExampleSQLPoolRestorePointsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolRestorePointsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "Default-SQL-SouthEastAsia", "testws", "testpool", "131546477590000000", nil) + res, err := clientFactory.NewSQLPoolRestorePointsClient().Get(ctx, "Default-SQL-SouthEastAsia", "testws", "testpool", "131546477590000000", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -153,11 +153,11 @@ func ExampleSQLPoolRestorePointsClient_Delete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolRestorePointsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "Default-SQL-SouthEastAsia", "testws", "testpool", "131546477590000000", nil) + _, err = clientFactory.NewSQLPoolRestorePointsClient().Delete(ctx, "Default-SQL-SouthEastAsia", "testws", "testpool", "131546477590000000", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpools_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpools_client.go index d814488fb76c..77ddcb4d76ba 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpools_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpools_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolsClient contains the methods for the SQLPools group. // Don't use this type directly, use NewSQLPoolsClient() instead. type SQLPoolsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolsClient creates a new instance of SQLPoolsClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolsClient, 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+".SQLPoolsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,11 +59,11 @@ func (client *SQLPoolsClient) BeginCreate(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SQLPoolsClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SQLPoolsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[SQLPoolsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SQLPoolsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -87,7 +76,7 @@ func (client *SQLPoolsClient) create(ctx context.Context, resourceGroupName stri if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -116,7 +105,7 @@ func (client *SQLPoolsClient) createCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - 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 } @@ -141,11 +130,11 @@ func (client *SQLPoolsClient) BeginDelete(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SQLPoolsClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SQLPoolsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[SQLPoolsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SQLPoolsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -158,7 +147,7 @@ func (client *SQLPoolsClient) deleteOperation(ctx context.Context, resourceGroup if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -187,7 +176,7 @@ func (client *SQLPoolsClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - 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 } @@ -211,7 +200,7 @@ func (client *SQLPoolsClient) Get(ctx context.Context, resourceGroupName string, if err != nil { return SQLPoolsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolsClientGetResponse{}, err } @@ -240,7 +229,7 @@ func (client *SQLPoolsClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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,7 +272,7 @@ func (client *SQLPoolsClient) NewListByWorkspacePager(resourceGroupName string, if err != nil { return SQLPoolsClientListByWorkspaceResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolsClientListByWorkspaceResponse{}, err } @@ -310,7 +299,7 @@ func (client *SQLPoolsClient) listByWorkspaceCreateRequest(ctx context.Context, return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -344,11 +333,11 @@ func (client *SQLPoolsClient) BeginPause(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SQLPoolsClientPauseResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SQLPoolsClientPauseResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[SQLPoolsClientPauseResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SQLPoolsClientPauseResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -361,7 +350,7 @@ func (client *SQLPoolsClient) pause(ctx context.Context, resourceGroupName strin 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 } @@ -390,7 +379,7 @@ func (client *SQLPoolsClient) pauseCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - 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 } @@ -415,7 +404,7 @@ func (client *SQLPoolsClient) Rename(ctx context.Context, resourceGroupName stri if err != nil { return SQLPoolsClientRenameResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolsClientRenameResponse{}, err } @@ -444,7 +433,7 @@ func (client *SQLPoolsClient) renameCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - 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 } @@ -468,11 +457,11 @@ func (client *SQLPoolsClient) BeginResume(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SQLPoolsClientResumeResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SQLPoolsClientResumeResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[SQLPoolsClientResumeResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SQLPoolsClientResumeResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -485,7 +474,7 @@ func (client *SQLPoolsClient) resume(ctx context.Context, resourceGroupName stri 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 } @@ -514,7 +503,7 @@ func (client *SQLPoolsClient) resumeCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - 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 } @@ -540,9 +529,9 @@ func (client *SQLPoolsClient) BeginUpdate(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller[SQLPoolsClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[SQLPoolsClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[SQLPoolsClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SQLPoolsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -555,7 +544,7 @@ func (client *SQLPoolsClient) update(ctx context.Context, resourceGroupName stri 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 } @@ -584,7 +573,7 @@ func (client *SQLPoolsClient) updateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - 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/synapse/armsynapse/sqlpools_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpools_client_example_test.go index b7de250a0825..082061f5c229 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpools_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpools_client_example_test.go @@ -27,11 +27,11 @@ func ExampleSQLPoolsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", nil) + res, err := clientFactory.NewSQLPoolsClient().Get(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -68,11 +68,11 @@ func ExampleSQLPoolsClient_BeginUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolsClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExampleSqlPool", armsynapse.SQLPoolPatchInfo{ + poller, err := clientFactory.NewSQLPoolsClient().BeginUpdate(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExampleSqlPool", armsynapse.SQLPoolPatchInfo{ Location: to.Ptr("West US 2"), Properties: &armsynapse.SQLPoolResourceProperties{ Collation: to.Ptr(""), @@ -126,11 +126,11 @@ func ExampleSQLPoolsClient_BeginCreate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolsClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExampleSqlPool", armsynapse.SQLPool{ + poller, err := clientFactory.NewSQLPoolsClient().BeginCreate(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExampleSqlPool", armsynapse.SQLPool{ Location: to.Ptr("Southeast Asia"), Tags: map[string]*string{}, Properties: &armsynapse.SQLPoolResourceProperties{ @@ -187,11 +187,11 @@ func ExampleSQLPoolsClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolsClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExampleSqlPool", nil) + poller, err := clientFactory.NewSQLPoolsClient().BeginDelete(ctx, "ExampleResourceGroup", "ExampleWorkspace", "ExampleSqlPool", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -221,11 +221,11 @@ func ExampleSQLPoolsClient_NewListByWorkspacePager_listSqlAnalyticsPoolsInAWorks log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByWorkspacePager("sqlcrudtest-6845", "sqlcrudtest-7177", nil) + pager := clientFactory.NewSQLPoolsClient().NewListByWorkspacePager("sqlcrudtest-6845", "sqlcrudtest-7177", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -339,11 +339,11 @@ func ExampleSQLPoolsClient_NewListByWorkspacePager_listSqlAnalyticsPoolsInAWorks log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByWorkspacePager("sqlcrudtest-6845", "sqlcrudtest-7177", nil) + pager := clientFactory.NewSQLPoolsClient().NewListByWorkspacePager("sqlcrudtest-6845", "sqlcrudtest-7177", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -385,11 +385,11 @@ func ExampleSQLPoolsClient_BeginPause() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolsClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginPause(ctx, "Default-SQL-SouthEastAsia", "testsvr", "testdwdb", nil) + poller, err := clientFactory.NewSQLPoolsClient().BeginPause(ctx, "Default-SQL-SouthEastAsia", "testsvr", "testdwdb", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -429,11 +429,11 @@ func ExampleSQLPoolsClient_BeginResume() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolsClient("01234567-89ab-4def-0123-456789abcdef", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginResume(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", nil) + poller, err := clientFactory.NewSQLPoolsClient().BeginResume(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -473,11 +473,11 @@ func ExampleSQLPoolsClient_Rename() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Rename(ctx, "Default-SQL-SouthEastAsia", "testsvr", "testdb", armsynapse.ResourceMoveDefinition{ + _, err = clientFactory.NewSQLPoolsClient().Rename(ctx, "Default-SQL-SouthEastAsia", "testsvr", "testdb", armsynapse.ResourceMoveDefinition{ ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Synapse/workspaces/testsvr/sqlPools/newtestdb"), }, nil) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpoolschemas_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolschemas_client.go index 37c1a79d37de..cf290f5b76bd 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolschemas_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolschemas_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolSchemasClient contains the methods for the SQLPoolSchemas group. // Don't use this type directly, use NewSQLPoolSchemasClient() instead. type SQLPoolSchemasClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolSchemasClient creates a new instance of SQLPoolSchemasClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolSchemasClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolSchemasClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolSchemasClient, 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+".SQLPoolSchemasClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolSchemasClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -69,7 +58,7 @@ func (client *SQLPoolSchemasClient) Get(ctx context.Context, resourceGroupName s if err != nil { return SQLPoolSchemasClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolSchemasClientGetResponse{}, err } @@ -102,7 +91,7 @@ func (client *SQLPoolSchemasClient) getCreateRequest(ctx context.Context, resour return nil, errors.New("parameter schemaName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{schemaName}", url.PathEscape(schemaName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -145,7 +134,7 @@ func (client *SQLPoolSchemasClient) NewListPager(resourceGroupName string, works if err != nil { return SQLPoolSchemasClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolSchemasClientListResponse{}, err } @@ -176,7 +165,7 @@ func (client *SQLPoolSchemasClient) listCreateRequest(ctx context.Context, resou return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpoolschemas_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolschemas_client_example_test.go index 1f3a3c27c340..6cabb3123a0f 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolschemas_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolschemas_client_example_test.go @@ -24,11 +24,11 @@ func ExampleSQLPoolSchemasClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolSchemasClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("myRG", "serverName", "myDatabase", &armsynapse.SQLPoolSchemasClientListOptions{Filter: nil}) + pager := clientFactory.NewSQLPoolSchemasClient().NewListPager("myRG", "serverName", "myDatabase", &armsynapse.SQLPoolSchemasClientListOptions{Filter: nil}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -62,11 +62,11 @@ func ExampleSQLPoolSchemasClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolSchemasClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "myRG", "serverName", "myDatabase", "dbo", nil) + res, err := clientFactory.NewSQLPoolSchemasClient().Get(ctx, "myRG", "serverName", "myDatabase", "dbo", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpoolsecurityalertpolicies_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolsecurityalertpolicies_client.go index 5ddde4cd085a..b5c351b37532 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolsecurityalertpolicies_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolsecurityalertpolicies_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolSecurityAlertPoliciesClient contains the methods for the SQLPoolSecurityAlertPolicies group. // Don't use this type directly, use NewSQLPoolSecurityAlertPoliciesClient() instead. type SQLPoolSecurityAlertPoliciesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolSecurityAlertPoliciesClient creates a new instance of SQLPoolSecurityAlertPoliciesClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolSecurityAlertPoliciesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolSecurityAlertPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolSecurityAlertPoliciesClient, 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+".SQLPoolSecurityAlertPoliciesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolSecurityAlertPoliciesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,7 +60,7 @@ func (client *SQLPoolSecurityAlertPoliciesClient) CreateOrUpdate(ctx context.Con if err != nil { return SQLPoolSecurityAlertPoliciesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolSecurityAlertPoliciesClientCreateOrUpdateResponse{}, err } @@ -104,7 +93,7 @@ func (client *SQLPoolSecurityAlertPoliciesClient) createOrUpdateCreateRequest(ct return nil, errors.New("parameter securityAlertPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{securityAlertPolicyName}", url.PathEscape(string(securityAlertPolicyName))) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -139,7 +128,7 @@ func (client *SQLPoolSecurityAlertPoliciesClient) Get(ctx context.Context, resou if err != nil { return SQLPoolSecurityAlertPoliciesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolSecurityAlertPoliciesClientGetResponse{}, err } @@ -172,7 +161,7 @@ func (client *SQLPoolSecurityAlertPoliciesClient) getCreateRequest(ctx context.C return nil, errors.New("parameter securityAlertPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{securityAlertPolicyName}", url.PathEscape(string(securityAlertPolicyName))) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -216,7 +205,7 @@ func (client *SQLPoolSecurityAlertPoliciesClient) NewListPager(resourceGroupName if err != nil { return SQLPoolSecurityAlertPoliciesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolSecurityAlertPoliciesClientListResponse{}, err } @@ -247,7 +236,7 @@ func (client *SQLPoolSecurityAlertPoliciesClient) listCreateRequest(ctx context. return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpoolsecurityalertpolicies_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolsecurityalertpolicies_client_example_test.go index e1761b0efdb9..05b28f53f269 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolsecurityalertpolicies_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolsecurityalertpolicies_client_example_test.go @@ -25,11 +25,11 @@ func ExampleSQLPoolSecurityAlertPoliciesClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolSecurityAlertPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("securityalert-6852", "securityalert-2080", "testdb", nil) + pager := clientFactory.NewSQLPoolSecurityAlertPoliciesClient().NewListPager("securityalert-6852", "securityalert-2080", "testdb", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -70,11 +70,11 @@ func ExampleSQLPoolSecurityAlertPoliciesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolSecurityAlertPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "securityalert-6852", "securityalert-2080", "testdb", armsynapse.SecurityAlertPolicyNameDefault, nil) + res, err := clientFactory.NewSQLPoolSecurityAlertPoliciesClient().Get(ctx, "securityalert-6852", "securityalert-2080", "testdb", armsynapse.SecurityAlertPolicyNameDefault, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -107,11 +107,11 @@ func ExampleSQLPoolSecurityAlertPoliciesClient_CreateOrUpdate_updateASqlPoolsThr log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolSecurityAlertPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "securityalert-4799", "securityalert-6440", "testdb", armsynapse.SecurityAlertPolicyNameDefault, armsynapse.SQLPoolSecurityAlertPolicy{ + res, err := clientFactory.NewSQLPoolSecurityAlertPoliciesClient().CreateOrUpdate(ctx, "securityalert-4799", "securityalert-6440", "testdb", armsynapse.SecurityAlertPolicyNameDefault, armsynapse.SQLPoolSecurityAlertPolicy{ Properties: &armsynapse.SecurityAlertPolicyProperties{ DisabledAlerts: []*string{ to.Ptr("Sql_Injection"), @@ -159,11 +159,11 @@ func ExampleSQLPoolSecurityAlertPoliciesClient_CreateOrUpdate_updateASqlPoolsThr log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolSecurityAlertPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "securityalert-4799", "securityalert-6440", "testdb", armsynapse.SecurityAlertPolicyNameDefault, armsynapse.SQLPoolSecurityAlertPolicy{ + res, err := clientFactory.NewSQLPoolSecurityAlertPoliciesClient().CreateOrUpdate(ctx, "securityalert-4799", "securityalert-6440", "testdb", armsynapse.SecurityAlertPolicyNameDefault, armsynapse.SQLPoolSecurityAlertPolicy{ Properties: &armsynapse.SecurityAlertPolicyProperties{ State: to.Ptr(armsynapse.SecurityAlertPolicyStateEnabled), }, diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpoolsensitivitylabels_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolsensitivitylabels_client.go index ff5f4f700992..9b72ee36b3c3 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolsensitivitylabels_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolsensitivitylabels_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,9 +25,8 @@ import ( // SQLPoolSensitivityLabelsClient contains the methods for the SQLPoolSensitivityLabels group. // Don't use this type directly, use NewSQLPoolSensitivityLabelsClient() instead. type SQLPoolSensitivityLabelsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolSensitivityLabelsClient creates a new instance of SQLPoolSensitivityLabelsClient with the specified values. @@ -37,21 +34,13 @@ type SQLPoolSensitivityLabelsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolSensitivityLabelsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolSensitivityLabelsClient, 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+".SQLPoolSensitivityLabelsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolSensitivityLabelsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -74,7 +63,7 @@ func (client *SQLPoolSensitivityLabelsClient) CreateOrUpdate(ctx context.Context if err != nil { return SQLPoolSensitivityLabelsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolSensitivityLabelsClientCreateOrUpdateResponse{}, err } @@ -116,7 +105,7 @@ func (client *SQLPoolSensitivityLabelsClient) createOrUpdateCreateRequest(ctx co } urlPath = strings.ReplaceAll(urlPath, "{columnName}", url.PathEscape(columnName)) urlPath = strings.ReplaceAll(urlPath, "{sensitivityLabelSource}", url.PathEscape("current")) - 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 } @@ -153,7 +142,7 @@ func (client *SQLPoolSensitivityLabelsClient) Delete(ctx context.Context, resour if err != nil { return SQLPoolSensitivityLabelsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolSensitivityLabelsClientDeleteResponse{}, err } @@ -195,7 +184,7 @@ func (client *SQLPoolSensitivityLabelsClient) deleteCreateRequest(ctx context.Co } urlPath = strings.ReplaceAll(urlPath, "{columnName}", url.PathEscape(columnName)) urlPath = strings.ReplaceAll(urlPath, "{sensitivityLabelSource}", url.PathEscape("current")) - 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 } @@ -222,7 +211,7 @@ func (client *SQLPoolSensitivityLabelsClient) DisableRecommendation(ctx context. if err != nil { return SQLPoolSensitivityLabelsClientDisableRecommendationResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolSensitivityLabelsClientDisableRecommendationResponse{}, err } @@ -264,7 +253,7 @@ func (client *SQLPoolSensitivityLabelsClient) disableRecommendationCreateRequest } urlPath = strings.ReplaceAll(urlPath, "{columnName}", url.PathEscape(columnName)) urlPath = strings.ReplaceAll(urlPath, "{sensitivityLabelSource}", url.PathEscape("recommended")) - 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 } @@ -292,7 +281,7 @@ func (client *SQLPoolSensitivityLabelsClient) EnableRecommendation(ctx context.C if err != nil { return SQLPoolSensitivityLabelsClientEnableRecommendationResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolSensitivityLabelsClientEnableRecommendationResponse{}, err } @@ -334,7 +323,7 @@ func (client *SQLPoolSensitivityLabelsClient) enableRecommendationCreateRequest( } urlPath = strings.ReplaceAll(urlPath, "{columnName}", url.PathEscape(columnName)) urlPath = strings.ReplaceAll(urlPath, "{sensitivityLabelSource}", url.PathEscape("recommended")) - 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 } @@ -362,7 +351,7 @@ func (client *SQLPoolSensitivityLabelsClient) Get(ctx context.Context, resourceG if err != nil { return SQLPoolSensitivityLabelsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolSensitivityLabelsClientGetResponse{}, err } @@ -407,7 +396,7 @@ func (client *SQLPoolSensitivityLabelsClient) getCreateRequest(ctx context.Conte return nil, errors.New("parameter sensitivityLabelSource cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sensitivityLabelSource}", url.PathEscape(string(sensitivityLabelSource))) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -451,7 +440,7 @@ func (client *SQLPoolSensitivityLabelsClient) NewListCurrentPager(resourceGroupN if err != nil { return SQLPoolSensitivityLabelsClientListCurrentResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolSensitivityLabelsClientListCurrentResponse{}, err } @@ -482,7 +471,7 @@ func (client *SQLPoolSensitivityLabelsClient) listCurrentCreateRequest(ctx conte return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -529,7 +518,7 @@ func (client *SQLPoolSensitivityLabelsClient) NewListRecommendedPager(resourceGr if err != nil { return SQLPoolSensitivityLabelsClientListRecommendedResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolSensitivityLabelsClientListRecommendedResponse{}, err } @@ -560,7 +549,7 @@ func (client *SQLPoolSensitivityLabelsClient) listRecommendedCreateRequest(ctx c return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -603,7 +592,7 @@ func (client *SQLPoolSensitivityLabelsClient) Update(ctx context.Context, resour if err != nil { return SQLPoolSensitivityLabelsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolSensitivityLabelsClientUpdateResponse{}, err } @@ -632,7 +621,7 @@ func (client *SQLPoolSensitivityLabelsClient) updateCreateRequest(ctx context.Co return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - 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/synapse/armsynapse/sqlpoolsensitivitylabels_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolsensitivitylabels_client_example_test.go index c4e49b01a077..3c34bb923d07 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolsensitivitylabels_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolsensitivitylabels_client_example_test.go @@ -25,11 +25,11 @@ func ExampleSQLPoolSensitivityLabelsClient_NewListCurrentPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolSensitivityLabelsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListCurrentPager("myRG", "myServer", "myDatabase", &armsynapse.SQLPoolSensitivityLabelsClientListCurrentOptions{Filter: nil}) + pager := clientFactory.NewSQLPoolSensitivityLabelsClient().NewListCurrentPager("myRG", "myServer", "myDatabase", &armsynapse.SQLPoolSensitivityLabelsClientListCurrentOptions{Filter: nil}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -75,11 +75,11 @@ func ExampleSQLPoolSensitivityLabelsClient_Update() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolSensitivityLabelsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Update(ctx, "myRG", "myWorkspace", "mySqlPool", armsynapse.SensitivityLabelUpdateList{ + _, err = clientFactory.NewSQLPoolSensitivityLabelsClient().Update(ctx, "myRG", "myWorkspace", "mySqlPool", armsynapse.SensitivityLabelUpdateList{ Operations: []*armsynapse.SensitivityLabelUpdate{ { Properties: &armsynapse.SensitivityLabelUpdateProperties{ @@ -136,11 +136,11 @@ func ExampleSQLPoolSensitivityLabelsClient_NewListRecommendedPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolSensitivityLabelsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListRecommendedPager("myRG", "myServer", "myDatabase", &armsynapse.SQLPoolSensitivityLabelsClientListRecommendedOptions{IncludeDisabledRecommendations: nil, + pager := clientFactory.NewSQLPoolSensitivityLabelsClient().NewListRecommendedPager("myRG", "myServer", "myDatabase", &armsynapse.SQLPoolSensitivityLabelsClientListRecommendedOptions{IncludeDisabledRecommendations: nil, SkipToken: nil, Filter: nil, }) @@ -189,11 +189,11 @@ func ExampleSQLPoolSensitivityLabelsClient_CreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolSensitivityLabelsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "myRG", "myServer", "myDatabase", "dbo", "myTable", "myColumn", armsynapse.SensitivityLabel{ + res, err := clientFactory.NewSQLPoolSensitivityLabelsClient().CreateOrUpdate(ctx, "myRG", "myServer", "myDatabase", "dbo", "myTable", "myColumn", armsynapse.SensitivityLabel{ Properties: &armsynapse.SensitivityLabelProperties{ InformationType: to.Ptr("PhoneNumber"), InformationTypeID: to.Ptr("d22fa6e9-5ee4-3bde-4c2b-a409604c4646"), @@ -227,11 +227,11 @@ func ExampleSQLPoolSensitivityLabelsClient_Delete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolSensitivityLabelsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "myRG", "myServer", "myDatabase", "dbo", "myTable", "myColumn", nil) + _, err = clientFactory.NewSQLPoolSensitivityLabelsClient().Delete(ctx, "myRG", "myServer", "myDatabase", "dbo", "myTable", "myColumn", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -244,11 +244,11 @@ func ExampleSQLPoolSensitivityLabelsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolSensitivityLabelsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "myRG", "myServer", "myDatabase", "dbo", "myTable", "myColumn", armsynapse.SensitivityLabelSourceCurrent, nil) + res, err := clientFactory.NewSQLPoolSensitivityLabelsClient().Get(ctx, "myRG", "myServer", "myDatabase", "dbo", "myTable", "myColumn", armsynapse.SensitivityLabelSourceCurrent, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -275,11 +275,11 @@ func ExampleSQLPoolSensitivityLabelsClient_EnableRecommendation() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolSensitivityLabelsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.EnableRecommendation(ctx, "myRG", "myServer", "myDatabase", "dbo", "myTable", "myColumn", nil) + _, err = clientFactory.NewSQLPoolSensitivityLabelsClient().EnableRecommendation(ctx, "myRG", "myServer", "myDatabase", "dbo", "myTable", "myColumn", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -292,11 +292,11 @@ func ExampleSQLPoolSensitivityLabelsClient_DisableRecommendation() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolSensitivityLabelsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.DisableRecommendation(ctx, "myRG", "myServer", "myDatabase", "dbo", "myTable", "myColumn", nil) + _, err = clientFactory.NewSQLPoolSensitivityLabelsClient().DisableRecommendation(ctx, "myRG", "myServer", "myDatabase", "dbo", "myTable", "myColumn", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpooltablecolumns_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpooltablecolumns_client.go index 41a5246af777..0cf89ae1c906 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpooltablecolumns_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpooltablecolumns_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolTableColumnsClient contains the methods for the SQLPoolTableColumns group. // Don't use this type directly, use NewSQLPoolTableColumnsClient() instead. type SQLPoolTableColumnsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolTableColumnsClient creates a new instance of SQLPoolTableColumnsClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolTableColumnsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolTableColumnsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolTableColumnsClient, 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+".SQLPoolTableColumnsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolTableColumnsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -81,7 +70,7 @@ func (client *SQLPoolTableColumnsClient) NewListByTableNamePager(resourceGroupNa if err != nil { return SQLPoolTableColumnsClientListByTableNameResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolTableColumnsClientListByTableNameResponse{}, err } @@ -120,7 +109,7 @@ func (client *SQLPoolTableColumnsClient) listByTableNameCreateRequest(ctx contex return nil, errors.New("parameter tableName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{tableName}", url.PathEscape(tableName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpooltablecolumns_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpooltablecolumns_client_example_test.go index 1d8a18ea6816..9311a5c701f9 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpooltablecolumns_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpooltablecolumns_client_example_test.go @@ -24,11 +24,11 @@ func ExampleSQLPoolTableColumnsClient_NewListByTableNamePager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolTableColumnsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByTableNamePager("myRG", "serverName", "myDatabase", "dbo", "table1", &armsynapse.SQLPoolTableColumnsClientListByTableNameOptions{Filter: nil}) + pager := clientFactory.NewSQLPoolTableColumnsClient().NewListByTableNamePager("myRG", "serverName", "myDatabase", "dbo", "table1", &armsynapse.SQLPoolTableColumnsClientListByTableNameOptions{Filter: nil}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpooltables_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpooltables_client.go index 6551f2d325fd..51657f820b01 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpooltables_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpooltables_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolTablesClient contains the methods for the SQLPoolTables group. // Don't use this type directly, use NewSQLPoolTablesClient() instead. type SQLPoolTablesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolTablesClient creates a new instance of SQLPoolTablesClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolTablesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolTablesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolTablesClient, 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+".SQLPoolTablesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolTablesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,7 +59,7 @@ func (client *SQLPoolTablesClient) Get(ctx context.Context, resourceGroupName st if err != nil { return SQLPoolTablesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolTablesClientGetResponse{}, err } @@ -107,7 +96,7 @@ func (client *SQLPoolTablesClient) getCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter tableName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{tableName}", url.PathEscape(tableName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -152,7 +141,7 @@ func (client *SQLPoolTablesClient) NewListBySchemaPager(resourceGroupName string if err != nil { return SQLPoolTablesClientListBySchemaResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolTablesClientListBySchemaResponse{}, err } @@ -187,7 +176,7 @@ func (client *SQLPoolTablesClient) listBySchemaCreateRequest(ctx context.Context return nil, errors.New("parameter schemaName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{schemaName}", url.PathEscape(schemaName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpooltables_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpooltables_client_example_test.go index 7117fc2b3ada..860a029b5277 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpooltables_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpooltables_client_example_test.go @@ -24,11 +24,11 @@ func ExampleSQLPoolTablesClient_NewListBySchemaPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolTablesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListBySchemaPager("myRG", "serverName", "myDatabase", "dbo", &armsynapse.SQLPoolTablesClientListBySchemaOptions{Filter: nil}) + pager := clientFactory.NewSQLPoolTablesClient().NewListBySchemaPager("myRG", "serverName", "myDatabase", "dbo", &armsynapse.SQLPoolTablesClientListBySchemaOptions{Filter: nil}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -62,11 +62,11 @@ func ExampleSQLPoolTablesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolTablesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "myRG", "serverName", "myDatabase", "dbo", "table1", nil) + res, err := clientFactory.NewSQLPoolTablesClient().Get(ctx, "myRG", "serverName", "myDatabase", "dbo", "table1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpooltransparentdataencryptions_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpooltransparentdataencryptions_client.go index 2255508cabcb..7016d8c4338c 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpooltransparentdataencryptions_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpooltransparentdataencryptions_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolTransparentDataEncryptionsClient contains the methods for the SQLPoolTransparentDataEncryptions group. // Don't use this type directly, use NewSQLPoolTransparentDataEncryptionsClient() instead. type SQLPoolTransparentDataEncryptionsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolTransparentDataEncryptionsClient creates a new instance of SQLPoolTransparentDataEncryptionsClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolTransparentDataEncryptionsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolTransparentDataEncryptionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolTransparentDataEncryptionsClient, 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+".SQLPoolTransparentDataEncryptionsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolTransparentDataEncryptionsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,7 +60,7 @@ func (client *SQLPoolTransparentDataEncryptionsClient) CreateOrUpdate(ctx contex if err != nil { return SQLPoolTransparentDataEncryptionsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolTransparentDataEncryptionsClientCreateOrUpdateResponse{}, err } @@ -104,7 +93,7 @@ func (client *SQLPoolTransparentDataEncryptionsClient) createOrUpdateCreateReque return nil, errors.New("parameter transparentDataEncryptionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{transparentDataEncryptionName}", url.PathEscape(string(transparentDataEncryptionName))) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -139,7 +128,7 @@ func (client *SQLPoolTransparentDataEncryptionsClient) Get(ctx context.Context, if err != nil { return SQLPoolTransparentDataEncryptionsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolTransparentDataEncryptionsClientGetResponse{}, err } @@ -172,7 +161,7 @@ func (client *SQLPoolTransparentDataEncryptionsClient) getCreateRequest(ctx cont return nil, errors.New("parameter transparentDataEncryptionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{transparentDataEncryptionName}", url.PathEscape(string(transparentDataEncryptionName))) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -216,7 +205,7 @@ func (client *SQLPoolTransparentDataEncryptionsClient) NewListPager(resourceGrou if err != nil { return SQLPoolTransparentDataEncryptionsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolTransparentDataEncryptionsClientListResponse{}, err } @@ -247,7 +236,7 @@ func (client *SQLPoolTransparentDataEncryptionsClient) listCreateRequest(ctx con return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpooltransparentdataencryptions_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpooltransparentdataencryptions_client_example_test.go index 92577f794ecf..31248fc85cbd 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpooltransparentdataencryptions_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpooltransparentdataencryptions_client_example_test.go @@ -25,11 +25,11 @@ func ExampleSQLPoolTransparentDataEncryptionsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolTransparentDataEncryptionsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", armsynapse.TransparentDataEncryptionNameCurrent, nil) + res, err := clientFactory.NewSQLPoolTransparentDataEncryptionsClient().Get(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", armsynapse.TransparentDataEncryptionNameCurrent, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -54,11 +54,11 @@ func ExampleSQLPoolTransparentDataEncryptionsClient_CreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolTransparentDataEncryptionsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", armsynapse.TransparentDataEncryptionNameCurrent, armsynapse.TransparentDataEncryption{ + res, err := clientFactory.NewSQLPoolTransparentDataEncryptionsClient().CreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", armsynapse.TransparentDataEncryptionNameCurrent, armsynapse.TransparentDataEncryption{ Properties: &armsynapse.TransparentDataEncryptionProperties{ Status: to.Ptr(armsynapse.TransparentDataEncryptionStatusEnabled), }, @@ -87,11 +87,11 @@ func ExampleSQLPoolTransparentDataEncryptionsClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolTransparentDataEncryptionsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", nil) + pager := clientFactory.NewSQLPoolTransparentDataEncryptionsClient().NewListPager("sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpoolusages_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolusages_client.go index 28e60a32c504..ec2ece914860 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolusages_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolusages_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolUsagesClient contains the methods for the SQLPoolUsages group. // Don't use this type directly, use NewSQLPoolUsagesClient() instead. type SQLPoolUsagesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolUsagesClient creates a new instance of SQLPoolUsagesClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolUsagesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolUsagesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolUsagesClient, 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+".SQLPoolUsagesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolUsagesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -78,7 +67,7 @@ func (client *SQLPoolUsagesClient) NewListPager(resourceGroupName string, worksp if err != nil { return SQLPoolUsagesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolUsagesClientListResponse{}, err } @@ -109,7 +98,7 @@ func (client *SQLPoolUsagesClient) listCreateRequest(ctx context.Context, resour return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpoolusages_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolusages_client_example_test.go index 3e0113291510..b93edc6856c0 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolusages_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolusages_client_example_test.go @@ -24,11 +24,11 @@ func ExampleSQLPoolUsagesClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolUsagesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("sqlcrudtest-6730", "sqlcrudtest-9007", "3481", nil) + pager := clientFactory.NewSQLPoolUsagesClient().NewListPager("sqlcrudtest-6730", "sqlcrudtest-9007", "3481", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessmentrulebaselines_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessmentrulebaselines_client.go index b85a23ceeaf7..27cf547e5618 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessmentrulebaselines_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessmentrulebaselines_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolVulnerabilityAssessmentRuleBaselinesClient contains the methods for the SQLPoolVulnerabilityAssessmentRuleBaselines group. // Don't use this type directly, use NewSQLPoolVulnerabilityAssessmentRuleBaselinesClient() instead. type SQLPoolVulnerabilityAssessmentRuleBaselinesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolVulnerabilityAssessmentRuleBaselinesClient creates a new instance of SQLPoolVulnerabilityAssessmentRuleBaselinesClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolVulnerabilityAssessmentRuleBaselinesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolVulnerabilityAssessmentRuleBaselinesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolVulnerabilityAssessmentRuleBaselinesClient, 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+".SQLPoolVulnerabilityAssessmentRuleBaselinesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolVulnerabilityAssessmentRuleBaselinesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -74,7 +63,7 @@ func (client *SQLPoolVulnerabilityAssessmentRuleBaselinesClient) CreateOrUpdate( if err != nil { return SQLPoolVulnerabilityAssessmentRuleBaselinesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolVulnerabilityAssessmentRuleBaselinesClientCreateOrUpdateResponse{}, err } @@ -115,7 +104,7 @@ func (client *SQLPoolVulnerabilityAssessmentRuleBaselinesClient) createOrUpdateC return nil, errors.New("parameter baselineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{baselineName}", url.PathEscape(string(baselineName))) - 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 } @@ -153,7 +142,7 @@ func (client *SQLPoolVulnerabilityAssessmentRuleBaselinesClient) Delete(ctx cont if err != nil { return SQLPoolVulnerabilityAssessmentRuleBaselinesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolVulnerabilityAssessmentRuleBaselinesClientDeleteResponse{}, err } @@ -194,7 +183,7 @@ func (client *SQLPoolVulnerabilityAssessmentRuleBaselinesClient) deleteCreateReq return nil, errors.New("parameter baselineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{baselineName}", url.PathEscape(string(baselineName))) - 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 } @@ -222,7 +211,7 @@ func (client *SQLPoolVulnerabilityAssessmentRuleBaselinesClient) Get(ctx context if err != nil { return SQLPoolVulnerabilityAssessmentRuleBaselinesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolVulnerabilityAssessmentRuleBaselinesClientGetResponse{}, err } @@ -263,7 +252,7 @@ func (client *SQLPoolVulnerabilityAssessmentRuleBaselinesClient) getCreateReques return nil, errors.New("parameter baselineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{baselineName}", url.PathEscape(string(baselineName))) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpoolvulnerabilityassessmentrulebaselines_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessmentrulebaselines_client_example_test.go index 3e3d39f46bdd..7a643ff8845d 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessmentrulebaselines_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessmentrulebaselines_client_example_test.go @@ -25,11 +25,11 @@ func ExampleSQLPoolVulnerabilityAssessmentRuleBaselinesClient_CreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolVulnerabilityAssessmentRuleBaselinesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "vulnerabilityaseessmenttest-4799", "vulnerabilityaseessmenttest-6440", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, "VA1001", armsynapse.VulnerabilityAssessmentPolicyBaselineNameDefault, armsynapse.SQLPoolVulnerabilityAssessmentRuleBaseline{ + res, err := clientFactory.NewSQLPoolVulnerabilityAssessmentRuleBaselinesClient().CreateOrUpdate(ctx, "vulnerabilityaseessmenttest-4799", "vulnerabilityaseessmenttest-6440", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, "VA1001", armsynapse.VulnerabilityAssessmentPolicyBaselineNameDefault, armsynapse.SQLPoolVulnerabilityAssessmentRuleBaseline{ Properties: &armsynapse.SQLPoolVulnerabilityAssessmentRuleBaselineProperties{ BaselineResults: []*armsynapse.SQLPoolVulnerabilityAssessmentRuleBaselineItem{ { @@ -89,11 +89,11 @@ func ExampleSQLPoolVulnerabilityAssessmentRuleBaselinesClient_Delete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolVulnerabilityAssessmentRuleBaselinesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "vulnerabilityaseessmenttest-4799", "vulnerabilityaseessmenttest-6440", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, "VA1001", armsynapse.VulnerabilityAssessmentPolicyBaselineNameDefault, nil) + _, err = clientFactory.NewSQLPoolVulnerabilityAssessmentRuleBaselinesClient().Delete(ctx, "vulnerabilityaseessmenttest-4799", "vulnerabilityaseessmenttest-6440", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, "VA1001", armsynapse.VulnerabilityAssessmentPolicyBaselineNameDefault, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -106,11 +106,11 @@ func ExampleSQLPoolVulnerabilityAssessmentRuleBaselinesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolVulnerabilityAssessmentRuleBaselinesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "vulnerabilityaseessmenttest-4711", "vulnerabilityaseessmenttest-6411", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, "VA1001", armsynapse.VulnerabilityAssessmentPolicyBaselineNameMaster, nil) + res, err := clientFactory.NewSQLPoolVulnerabilityAssessmentRuleBaselinesClient().Get(ctx, "vulnerabilityaseessmenttest-4711", "vulnerabilityaseessmenttest-6411", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, "VA1001", armsynapse.VulnerabilityAssessmentPolicyBaselineNameMaster, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessments_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessments_client.go index 9b1a7d381dcd..5d215fafbc88 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessments_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessments_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolVulnerabilityAssessmentsClient contains the methods for the SQLPoolVulnerabilityAssessments group. // Don't use this type directly, use NewSQLPoolVulnerabilityAssessmentsClient() instead. type SQLPoolVulnerabilityAssessmentsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolVulnerabilityAssessmentsClient creates a new instance of SQLPoolVulnerabilityAssessmentsClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolVulnerabilityAssessmentsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolVulnerabilityAssessmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolVulnerabilityAssessmentsClient, 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+".SQLPoolVulnerabilityAssessmentsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolVulnerabilityAssessmentsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,7 +60,7 @@ func (client *SQLPoolVulnerabilityAssessmentsClient) CreateOrUpdate(ctx context. if err != nil { return SQLPoolVulnerabilityAssessmentsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolVulnerabilityAssessmentsClientCreateOrUpdateResponse{}, err } @@ -104,7 +93,7 @@ func (client *SQLPoolVulnerabilityAssessmentsClient) createOrUpdateCreateRequest return nil, errors.New("parameter vulnerabilityAssessmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vulnerabilityAssessmentName}", url.PathEscape(string(vulnerabilityAssessmentName))) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -139,7 +128,7 @@ func (client *SQLPoolVulnerabilityAssessmentsClient) Delete(ctx context.Context, if err != nil { return SQLPoolVulnerabilityAssessmentsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolVulnerabilityAssessmentsClientDeleteResponse{}, err } @@ -172,7 +161,7 @@ func (client *SQLPoolVulnerabilityAssessmentsClient) deleteCreateRequest(ctx con return nil, errors.New("parameter vulnerabilityAssessmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vulnerabilityAssessmentName}", url.PathEscape(string(vulnerabilityAssessmentName))) - 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,7 +186,7 @@ func (client *SQLPoolVulnerabilityAssessmentsClient) Get(ctx context.Context, re if err != nil { return SQLPoolVulnerabilityAssessmentsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolVulnerabilityAssessmentsClientGetResponse{}, err } @@ -230,7 +219,7 @@ func (client *SQLPoolVulnerabilityAssessmentsClient) getCreateRequest(ctx contex return nil, errors.New("parameter vulnerabilityAssessmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vulnerabilityAssessmentName}", url.PathEscape(string(vulnerabilityAssessmentName))) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -274,7 +263,7 @@ func (client *SQLPoolVulnerabilityAssessmentsClient) NewListPager(resourceGroupN if err != nil { return SQLPoolVulnerabilityAssessmentsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolVulnerabilityAssessmentsClientListResponse{}, err } @@ -305,7 +294,7 @@ func (client *SQLPoolVulnerabilityAssessmentsClient) listCreateRequest(ctx conte return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpoolvulnerabilityassessments_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessments_client_example_test.go index 18960fe782ab..95e17e0cef03 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessments_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessments_client_example_test.go @@ -25,11 +25,11 @@ func ExampleSQLPoolVulnerabilityAssessmentsClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolVulnerabilityAssessmentsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("vulnerabilityaseessmenttest-4799", "vulnerabilityaseessmenttest-6440", "testdb", nil) + pager := clientFactory.NewSQLPoolVulnerabilityAssessmentsClient().NewListPager("vulnerabilityaseessmenttest-4799", "vulnerabilityaseessmenttest-6440", "testdb", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -67,11 +67,11 @@ func ExampleSQLPoolVulnerabilityAssessmentsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolVulnerabilityAssessmentsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "vulnerabilityaseessmenttest-4799", "vulnerabilityaseessmenttest-6440", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, nil) + res, err := clientFactory.NewSQLPoolVulnerabilityAssessmentsClient().Get(ctx, "vulnerabilityaseessmenttest-4799", "vulnerabilityaseessmenttest-6440", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -101,11 +101,11 @@ func ExampleSQLPoolVulnerabilityAssessmentsClient_CreateOrUpdate_createADatabase log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolVulnerabilityAssessmentsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "vulnerabilityaseessmenttest-4799", "vulnerabilityaseessmenttest-6440", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, armsynapse.SQLPoolVulnerabilityAssessment{ + res, err := clientFactory.NewSQLPoolVulnerabilityAssessmentsClient().CreateOrUpdate(ctx, "vulnerabilityaseessmenttest-4799", "vulnerabilityaseessmenttest-6440", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, armsynapse.SQLPoolVulnerabilityAssessment{ Properties: &armsynapse.SQLPoolVulnerabilityAssessmentProperties{ RecurringScans: &armsynapse.VulnerabilityAssessmentRecurringScansProperties{ EmailSubscriptionAdmins: to.Ptr(true), @@ -148,11 +148,11 @@ func ExampleSQLPoolVulnerabilityAssessmentsClient_CreateOrUpdate_createADatabase log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolVulnerabilityAssessmentsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "vulnerabilityaseessmenttest-4799", "vulnerabilityaseessmenttest-6440", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, armsynapse.SQLPoolVulnerabilityAssessment{ + res, err := clientFactory.NewSQLPoolVulnerabilityAssessmentsClient().CreateOrUpdate(ctx, "vulnerabilityaseessmenttest-4799", "vulnerabilityaseessmenttest-6440", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, armsynapse.SQLPoolVulnerabilityAssessment{ Properties: &armsynapse.SQLPoolVulnerabilityAssessmentProperties{ StorageAccountAccessKey: to.Ptr("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"), StorageContainerPath: to.Ptr("https://myStorage.blob.core.windows.net/vulnerability-assessment/"), @@ -186,11 +186,11 @@ func ExampleSQLPoolVulnerabilityAssessmentsClient_CreateOrUpdate_createADatabase log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolVulnerabilityAssessmentsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "vulnerabilityaseessmenttest-4799", "vulnerabilityaseessmenttest-6440", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, armsynapse.SQLPoolVulnerabilityAssessment{ + res, err := clientFactory.NewSQLPoolVulnerabilityAssessmentsClient().CreateOrUpdate(ctx, "vulnerabilityaseessmenttest-4799", "vulnerabilityaseessmenttest-6440", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, armsynapse.SQLPoolVulnerabilityAssessment{ Properties: &armsynapse.SQLPoolVulnerabilityAssessmentProperties{ StorageContainerPath: to.Ptr("https://myStorage.blob.core.windows.net/vulnerability-assessment/"), StorageContainerSasKey: to.Ptr("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"), @@ -224,11 +224,11 @@ func ExampleSQLPoolVulnerabilityAssessmentsClient_Delete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolVulnerabilityAssessmentsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "vulnerabilityaseessmenttest-4799", "vulnerabilityaseessmenttest-6440", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, nil) + _, err = clientFactory.NewSQLPoolVulnerabilityAssessmentsClient().Delete(ctx, "vulnerabilityaseessmenttest-4799", "vulnerabilityaseessmenttest-6440", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessmentscans_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessmentscans_client.go index 6bc170132e7b..35a23622c06c 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessmentscans_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessmentscans_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolVulnerabilityAssessmentScansClient contains the methods for the SQLPoolVulnerabilityAssessmentScans group. // Don't use this type directly, use NewSQLPoolVulnerabilityAssessmentScansClient() instead. type SQLPoolVulnerabilityAssessmentScansClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolVulnerabilityAssessmentScansClient creates a new instance of SQLPoolVulnerabilityAssessmentScansClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolVulnerabilityAssessmentScansClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolVulnerabilityAssessmentScansClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolVulnerabilityAssessmentScansClient, 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+".SQLPoolVulnerabilityAssessmentScansClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolVulnerabilityAssessmentScansClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,7 +60,7 @@ func (client *SQLPoolVulnerabilityAssessmentScansClient) Export(ctx context.Cont if err != nil { return SQLPoolVulnerabilityAssessmentScansClientExportResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolVulnerabilityAssessmentScansClientExportResponse{}, err } @@ -108,7 +97,7 @@ func (client *SQLPoolVulnerabilityAssessmentScansClient) exportCreateRequest(ctx return nil, errors.New("parameter scanID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{scanId}", url.PathEscape(scanID)) - 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 } @@ -144,7 +133,7 @@ func (client *SQLPoolVulnerabilityAssessmentScansClient) Get(ctx context.Context if err != nil { return SQLPoolVulnerabilityAssessmentScansClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolVulnerabilityAssessmentScansClientGetResponse{}, err } @@ -181,7 +170,7 @@ func (client *SQLPoolVulnerabilityAssessmentScansClient) getCreateRequest(ctx co return nil, errors.New("parameter scanID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{scanId}", url.PathEscape(scanID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -218,9 +207,9 @@ func (client *SQLPoolVulnerabilityAssessmentScansClient) BeginInitiateScan(ctx c if err != nil { return nil, err } - return runtime.NewPoller[SQLPoolVulnerabilityAssessmentScansClientInitiateScanResponse](resp, client.pl, nil) + return runtime.NewPoller[SQLPoolVulnerabilityAssessmentScansClientInitiateScanResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[SQLPoolVulnerabilityAssessmentScansClientInitiateScanResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SQLPoolVulnerabilityAssessmentScansClientInitiateScanResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -233,7 +222,7 @@ func (client *SQLPoolVulnerabilityAssessmentScansClient) initiateScan(ctx contex 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 } @@ -270,7 +259,7 @@ func (client *SQLPoolVulnerabilityAssessmentScansClient) initiateScanCreateReque return nil, errors.New("parameter scanID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{scanId}", url.PathEscape(scanID)) - 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 } @@ -305,7 +294,7 @@ func (client *SQLPoolVulnerabilityAssessmentScansClient) NewListPager(resourceGr if err != nil { return SQLPoolVulnerabilityAssessmentScansClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolVulnerabilityAssessmentScansClientListResponse{}, err } @@ -340,7 +329,7 @@ func (client *SQLPoolVulnerabilityAssessmentScansClient) listCreateRequest(ctx c return nil, errors.New("parameter vulnerabilityAssessmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vulnerabilityAssessmentName}", url.PathEscape(string(vulnerabilityAssessmentName))) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpoolvulnerabilityassessmentscans_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessmentscans_client_example_test.go index e78b3665e33b..b8ad4f8ecf8a 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessmentscans_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolvulnerabilityassessmentscans_client_example_test.go @@ -24,11 +24,11 @@ func ExampleSQLPoolVulnerabilityAssessmentScansClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolVulnerabilityAssessmentScansClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("vulnerabilityassessmenttest-4711", "vulnerabilityassessmenttest-6411", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, nil) + pager := clientFactory.NewSQLPoolVulnerabilityAssessmentScansClient().NewListPager("vulnerabilityassessmenttest-4711", "vulnerabilityassessmenttest-6411", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -100,11 +100,11 @@ func ExampleSQLPoolVulnerabilityAssessmentScansClient_BeginInitiateScan() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolVulnerabilityAssessmentScansClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginInitiateScan(ctx, "vulnerabilityassessmenttest-4711", "vulnerabilityassessmenttest-6411", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, "scan01", nil) + poller, err := clientFactory.NewSQLPoolVulnerabilityAssessmentScansClient().BeginInitiateScan(ctx, "vulnerabilityassessmenttest-4711", "vulnerabilityassessmenttest-6411", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, "scan01", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -121,11 +121,11 @@ func ExampleSQLPoolVulnerabilityAssessmentScansClient_Export() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolVulnerabilityAssessmentScansClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Export(ctx, "vulnerabilityassessmenttest-4799", "vulnerabilityassessmenttest-6440", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, "scan001", nil) + res, err := clientFactory.NewSQLPoolVulnerabilityAssessmentScansClient().Export(ctx, "vulnerabilityassessmenttest-4799", "vulnerabilityassessmenttest-6440", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, "scan001", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -149,11 +149,11 @@ func ExampleSQLPoolVulnerabilityAssessmentScansClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolVulnerabilityAssessmentScansClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "vulnerabilityassessmenttest-4711", "vulnerabilityassessmenttest-6411", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, "scan001", nil) + res, err := clientFactory.NewSQLPoolVulnerabilityAssessmentScansClient().Get(ctx, "vulnerabilityassessmenttest-4711", "vulnerabilityassessmenttest-6411", "testdb", armsynapse.VulnerabilityAssessmentNameDefault, "scan001", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpoolworkloadclassifier_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolworkloadclassifier_client.go index 976f98f6d929..33ecaa55cb6f 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolworkloadclassifier_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolworkloadclassifier_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolWorkloadClassifierClient contains the methods for the SQLPoolWorkloadClassifier group. // Don't use this type directly, use NewSQLPoolWorkloadClassifierClient() instead. type SQLPoolWorkloadClassifierClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolWorkloadClassifierClient creates a new instance of SQLPoolWorkloadClassifierClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolWorkloadClassifierClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolWorkloadClassifierClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolWorkloadClassifierClient, 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+".SQLPoolWorkloadClassifierClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolWorkloadClassifierClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -73,9 +62,9 @@ func (client *SQLPoolWorkloadClassifierClient) BeginCreateOrUpdate(ctx context.C if err != nil { return nil, err } - return runtime.NewPoller[SQLPoolWorkloadClassifierClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[SQLPoolWorkloadClassifierClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[SQLPoolWorkloadClassifierClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SQLPoolWorkloadClassifierClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -88,7 +77,7 @@ func (client *SQLPoolWorkloadClassifierClient) createOrUpdate(ctx context.Contex 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 } @@ -125,7 +114,7 @@ func (client *SQLPoolWorkloadClassifierClient) createOrUpdateCreateRequest(ctx c return nil, errors.New("parameter workloadClassifierName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workloadClassifierName}", url.PathEscape(workloadClassifierName)) - 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 } @@ -153,9 +142,9 @@ func (client *SQLPoolWorkloadClassifierClient) BeginDelete(ctx context.Context, if err != nil { return nil, err } - return runtime.NewPoller[SQLPoolWorkloadClassifierClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[SQLPoolWorkloadClassifierClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[SQLPoolWorkloadClassifierClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SQLPoolWorkloadClassifierClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -168,7 +157,7 @@ func (client *SQLPoolWorkloadClassifierClient) deleteOperation(ctx context.Conte 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 } @@ -205,7 +194,7 @@ func (client *SQLPoolWorkloadClassifierClient) deleteCreateRequest(ctx context.C return nil, errors.New("parameter workloadClassifierName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workloadClassifierName}", url.PathEscape(workloadClassifierName)) - 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 } @@ -231,7 +220,7 @@ func (client *SQLPoolWorkloadClassifierClient) Get(ctx context.Context, resource if err != nil { return SQLPoolWorkloadClassifierClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolWorkloadClassifierClientGetResponse{}, err } @@ -268,7 +257,7 @@ func (client *SQLPoolWorkloadClassifierClient) getCreateRequest(ctx context.Cont return nil, errors.New("parameter workloadClassifierName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workloadClassifierName}", url.PathEscape(workloadClassifierName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -313,7 +302,7 @@ func (client *SQLPoolWorkloadClassifierClient) NewListPager(resourceGroupName st if err != nil { return SQLPoolWorkloadClassifierClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolWorkloadClassifierClientListResponse{}, err } @@ -348,7 +337,7 @@ func (client *SQLPoolWorkloadClassifierClient) listCreateRequest(ctx context.Con return nil, errors.New("parameter workloadGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workloadGroupName}", url.PathEscape(workloadGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpoolworkloadclassifier_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolworkloadclassifier_client_example_test.go index a93ac410c9c3..a064c84d5a05 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolworkloadclassifier_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolworkloadclassifier_client_example_test.go @@ -25,11 +25,11 @@ func ExampleSQLPoolWorkloadClassifierClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolWorkloadClassifierClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", "wlm_workloadgroup", "wlm_classifier", nil) + res, err := clientFactory.NewSQLPoolWorkloadClassifierClient().Get(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", "wlm_workloadgroup", "wlm_classifier", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -58,11 +58,11 @@ func ExampleSQLPoolWorkloadClassifierClient_BeginCreateOrUpdate_createAWorkloadC log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolWorkloadClassifierClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", "wlm_workloadgroup", "wlm_workloadclassifier", armsynapse.WorkloadClassifier{ + poller, err := clientFactory.NewSQLPoolWorkloadClassifierClient().BeginCreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", "wlm_workloadgroup", "wlm_workloadclassifier", armsynapse.WorkloadClassifier{ Properties: &armsynapse.WorkloadClassifierProperties{ Context: to.Ptr("test_context"), EndTime: to.Ptr("14:00"), @@ -104,11 +104,11 @@ func ExampleSQLPoolWorkloadClassifierClient_BeginCreateOrUpdate_createAWorkloadC log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolWorkloadClassifierClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", "wlm_workloadgroup", "wlm_workloadclassifier", armsynapse.WorkloadClassifier{ + poller, err := clientFactory.NewSQLPoolWorkloadClassifierClient().BeginCreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", "wlm_workloadgroup", "wlm_workloadclassifier", armsynapse.WorkloadClassifier{ Properties: &armsynapse.WorkloadClassifierProperties{ MemberName: to.Ptr("dbo"), }, @@ -145,11 +145,11 @@ func ExampleSQLPoolWorkloadClassifierClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolWorkloadClassifierClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", "wlm_workloadgroup", "wlm_workloadclassifier", nil) + poller, err := clientFactory.NewSQLPoolWorkloadClassifierClient().BeginDelete(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", "wlm_workloadgroup", "wlm_workloadclassifier", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -166,11 +166,11 @@ func ExampleSQLPoolWorkloadClassifierClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolWorkloadClassifierClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", "wlm_workloadgroup", nil) + pager := clientFactory.NewSQLPoolWorkloadClassifierClient().NewListPager("sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", "wlm_workloadgroup", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/sqlpoolworkloadgroup_client.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolworkloadgroup_client.go index 94fe28ca4aa8..0d819a998c99 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolworkloadgroup_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolworkloadgroup_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // SQLPoolWorkloadGroupClient contains the methods for the SQLPoolWorkloadGroup group. // Don't use this type directly, use NewSQLPoolWorkloadGroupClient() instead. type SQLPoolWorkloadGroupClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSQLPoolWorkloadGroupClient creates a new instance of SQLPoolWorkloadGroupClient with the specified values. @@ -36,21 +33,13 @@ type SQLPoolWorkloadGroupClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSQLPoolWorkloadGroupClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SQLPoolWorkloadGroupClient, 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+".SQLPoolWorkloadGroupClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SQLPoolWorkloadGroupClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -72,9 +61,9 @@ func (client *SQLPoolWorkloadGroupClient) BeginCreateOrUpdate(ctx context.Contex if err != nil { return nil, err } - return runtime.NewPoller[SQLPoolWorkloadGroupClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[SQLPoolWorkloadGroupClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[SQLPoolWorkloadGroupClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SQLPoolWorkloadGroupClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -87,7 +76,7 @@ func (client *SQLPoolWorkloadGroupClient) createOrUpdate(ctx context.Context, re 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 } @@ -120,7 +109,7 @@ func (client *SQLPoolWorkloadGroupClient) createOrUpdateCreateRequest(ctx contex return nil, errors.New("parameter workloadGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workloadGroupName}", url.PathEscape(workloadGroupName)) - 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 } @@ -147,9 +136,9 @@ func (client *SQLPoolWorkloadGroupClient) BeginDelete(ctx context.Context, resou if err != nil { return nil, err } - return runtime.NewPoller[SQLPoolWorkloadGroupClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[SQLPoolWorkloadGroupClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[SQLPoolWorkloadGroupClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SQLPoolWorkloadGroupClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -162,7 +151,7 @@ func (client *SQLPoolWorkloadGroupClient) deleteOperation(ctx context.Context, r 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 } @@ -195,7 +184,7 @@ func (client *SQLPoolWorkloadGroupClient) deleteCreateRequest(ctx context.Contex return nil, errors.New("parameter workloadGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workloadGroupName}", url.PathEscape(workloadGroupName)) - 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 } @@ -220,7 +209,7 @@ func (client *SQLPoolWorkloadGroupClient) Get(ctx context.Context, resourceGroup if err != nil { return SQLPoolWorkloadGroupClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolWorkloadGroupClientGetResponse{}, err } @@ -253,7 +242,7 @@ func (client *SQLPoolWorkloadGroupClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter workloadGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workloadGroupName}", url.PathEscape(workloadGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -297,7 +286,7 @@ func (client *SQLPoolWorkloadGroupClient) NewListPager(resourceGroupName string, if err != nil { return SQLPoolWorkloadGroupClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SQLPoolWorkloadGroupClientListResponse{}, err } @@ -328,7 +317,7 @@ func (client *SQLPoolWorkloadGroupClient) listCreateRequest(ctx context.Context, return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/sqlpoolworkloadgroup_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/sqlpoolworkloadgroup_client_example_test.go index 0b873b525461..bb1e7764feab 100644 --- a/sdk/resourcemanager/synapse/armsynapse/sqlpoolworkloadgroup_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/sqlpoolworkloadgroup_client_example_test.go @@ -25,11 +25,11 @@ func ExampleSQLPoolWorkloadGroupClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolWorkloadGroupClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", "smallrc", nil) + res, err := clientFactory.NewSQLPoolWorkloadGroupClient().Get(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", "smallrc", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -58,11 +58,11 @@ func ExampleSQLPoolWorkloadGroupClient_BeginCreateOrUpdate_createAWorkloadGroupW log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolWorkloadGroupClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", "smallrc", armsynapse.WorkloadGroup{ + poller, err := clientFactory.NewSQLPoolWorkloadGroupClient().BeginCreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", "smallrc", armsynapse.WorkloadGroup{ Properties: &armsynapse.WorkloadGroupProperties{ Importance: to.Ptr("normal"), MaxResourcePercent: to.Ptr[int32](100), @@ -104,11 +104,11 @@ func ExampleSQLPoolWorkloadGroupClient_BeginCreateOrUpdate_createAWorkloadGroupW log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolWorkloadGroupClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", "smallrc", armsynapse.WorkloadGroup{ + poller, err := clientFactory.NewSQLPoolWorkloadGroupClient().BeginCreateOrUpdate(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", "smallrc", armsynapse.WorkloadGroup{ Properties: &armsynapse.WorkloadGroupProperties{ MaxResourcePercent: to.Ptr[int32](100), MinResourcePercent: to.Ptr[int32](0), @@ -147,11 +147,11 @@ func ExampleSQLPoolWorkloadGroupClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolWorkloadGroupClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", "wlm_workloadgroup", nil) + poller, err := clientFactory.NewSQLPoolWorkloadGroupClient().BeginDelete(ctx, "sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", "wlm_workloadgroup", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -168,11 +168,11 @@ func ExampleSQLPoolWorkloadGroupClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewSQLPoolWorkloadGroupClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", nil) + pager := clientFactory.NewSQLPoolWorkloadGroupClient().NewListPager("sqlcrudtest-6852", "sqlcrudtest-2080", "sqlcrudtest-9187", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/workspaceaadadmins_client.go b/sdk/resourcemanager/synapse/armsynapse/workspaceaadadmins_client.go index 717bd81061ec..275bf4cb6860 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspaceaadadmins_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspaceaadadmins_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // WorkspaceAADAdminsClient contains the methods for the WorkspaceAADAdmins group. // Don't use this type directly, use NewWorkspaceAADAdminsClient() instead. type WorkspaceAADAdminsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewWorkspaceAADAdminsClient creates a new instance of WorkspaceAADAdminsClient with the specified values. @@ -36,21 +33,13 @@ type WorkspaceAADAdminsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkspaceAADAdminsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceAADAdminsClient, 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+".WorkspaceAADAdminsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &WorkspaceAADAdminsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,11 +59,11 @@ func (client *WorkspaceAADAdminsClient) BeginCreateOrUpdate(ctx context.Context, if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[WorkspaceAADAdminsClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkspaceAADAdminsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[WorkspaceAADAdminsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[WorkspaceAADAdminsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -87,7 +76,7 @@ func (client *WorkspaceAADAdminsClient) createOrUpdate(ctx context.Context, reso 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 +101,7 @@ func (client *WorkspaceAADAdminsClient) createOrUpdateCreateRequest(ctx context. return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - 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 } @@ -137,11 +126,11 @@ func (client *WorkspaceAADAdminsClient) BeginDelete(ctx context.Context, resourc if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[WorkspaceAADAdminsClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkspaceAADAdminsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[WorkspaceAADAdminsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[WorkspaceAADAdminsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -154,7 +143,7 @@ func (client *WorkspaceAADAdminsClient) deleteOperation(ctx context.Context, res 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 +168,7 @@ func (client *WorkspaceAADAdminsClient) deleteCreateRequest(ctx context.Context, return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - 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,7 +191,7 @@ func (client *WorkspaceAADAdminsClient) Get(ctx context.Context, resourceGroupNa if err != nil { return WorkspaceAADAdminsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceAADAdminsClientGetResponse{}, err } @@ -227,7 +216,7 @@ func (client *WorkspaceAADAdminsClient) getCreateRequest(ctx context.Context, re return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/workspaceaadadmins_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/workspaceaadadmins_client_example_test.go index bb7de348f4ae..28e257f38dcc 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspaceaadadmins_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspaceaadadmins_client_example_test.go @@ -25,11 +25,11 @@ func ExampleWorkspaceAADAdminsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceAADAdminsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "resourceGroup1", "workspace1", nil) + res, err := clientFactory.NewWorkspaceAADAdminsClient().Get(ctx, "resourceGroup1", "workspace1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -55,11 +55,11 @@ func ExampleWorkspaceAADAdminsClient_BeginCreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceAADAdminsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "resourceGroup1", "workspace1", armsynapse.WorkspaceAADAdminInfo{ + poller, err := clientFactory.NewWorkspaceAADAdminsClient().BeginCreateOrUpdate(ctx, "resourceGroup1", "workspace1", armsynapse.WorkspaceAADAdminInfo{ Properties: &armsynapse.AADAdminProperties{ AdministratorType: to.Ptr("ActiveDirectory"), Login: to.Ptr("bob@contoso.com"), @@ -96,11 +96,11 @@ func ExampleWorkspaceAADAdminsClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceAADAdminsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "resourceGroup1", "workspace1", nil) + poller, err := clientFactory.NewWorkspaceAADAdminsClient().BeginDelete(ctx, "resourceGroup1", "workspace1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedidentitysqlcontrolsettings_client.go b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedidentitysqlcontrolsettings_client.go index 3c33aeefd857..4594a0c09a35 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedidentitysqlcontrolsettings_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedidentitysqlcontrolsettings_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // WorkspaceManagedIdentitySQLControlSettingsClient contains the methods for the WorkspaceManagedIdentitySQLControlSettings group. // Don't use this type directly, use NewWorkspaceManagedIdentitySQLControlSettingsClient() instead. type WorkspaceManagedIdentitySQLControlSettingsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewWorkspaceManagedIdentitySQLControlSettingsClient creates a new instance of WorkspaceManagedIdentitySQLControlSettingsClient with the specified values. @@ -36,21 +33,13 @@ type WorkspaceManagedIdentitySQLControlSettingsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkspaceManagedIdentitySQLControlSettingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceManagedIdentitySQLControlSettingsClient, 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+".WorkspaceManagedIdentitySQLControlSettingsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &WorkspaceManagedIdentitySQLControlSettingsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,11 +59,11 @@ func (client *WorkspaceManagedIdentitySQLControlSettingsClient) BeginCreateOrUpd if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[WorkspaceManagedIdentitySQLControlSettingsClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkspaceManagedIdentitySQLControlSettingsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[WorkspaceManagedIdentitySQLControlSettingsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[WorkspaceManagedIdentitySQLControlSettingsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -87,7 +76,7 @@ func (client *WorkspaceManagedIdentitySQLControlSettingsClient) createOrUpdate(c 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 +101,7 @@ func (client *WorkspaceManagedIdentitySQLControlSettingsClient) createOrUpdateCr return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - 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 } @@ -136,7 +125,7 @@ func (client *WorkspaceManagedIdentitySQLControlSettingsClient) Get(ctx context. if err != nil { return WorkspaceManagedIdentitySQLControlSettingsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceManagedIdentitySQLControlSettingsClientGetResponse{}, err } @@ -161,7 +150,7 @@ func (client *WorkspaceManagedIdentitySQLControlSettingsClient) getCreateRequest return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/workspacemanagedidentitysqlcontrolsettings_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedidentitysqlcontrolsettings_client_example_test.go index 2f44d3103cec..4f449d451694 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedidentitysqlcontrolsettings_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedidentitysqlcontrolsettings_client_example_test.go @@ -25,11 +25,11 @@ func ExampleWorkspaceManagedIdentitySQLControlSettingsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedIdentitySQLControlSettingsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "resourceGroup1", "workspace1", nil) + res, err := clientFactory.NewWorkspaceManagedIdentitySQLControlSettingsClient().Get(ctx, "resourceGroup1", "workspace1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -55,11 +55,11 @@ func ExampleWorkspaceManagedIdentitySQLControlSettingsClient_BeginCreateOrUpdate log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedIdentitySQLControlSettingsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "resourceGroup1", "workspace1", armsynapse.ManagedIdentitySQLControlSettingsModel{ + poller, err := clientFactory.NewWorkspaceManagedIdentitySQLControlSettingsClient().BeginCreateOrUpdate(ctx, "resourceGroup1", "workspace1", armsynapse.ManagedIdentitySQLControlSettingsModel{ Properties: &armsynapse.ManagedIdentitySQLControlSettingsModelProperties{ GrantSQLControlToManagedIdentity: &armsynapse.ManagedIdentitySQLControlSettingsModelPropertiesGrantSQLControlToManagedIdentity{ DesiredState: to.Ptr(armsynapse.DesiredStateEnabled), diff --git a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverblobauditingpolicies_client.go b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverblobauditingpolicies_client.go index 1ab467f50db4..f285e71102b3 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverblobauditingpolicies_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverblobauditingpolicies_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // WorkspaceManagedSQLServerBlobAuditingPoliciesClient contains the methods for the WorkspaceManagedSQLServerBlobAuditingPolicies group. // Don't use this type directly, use NewWorkspaceManagedSQLServerBlobAuditingPoliciesClient() instead. type WorkspaceManagedSQLServerBlobAuditingPoliciesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewWorkspaceManagedSQLServerBlobAuditingPoliciesClient creates a new instance of WorkspaceManagedSQLServerBlobAuditingPoliciesClient with the specified values. @@ -36,21 +33,13 @@ type WorkspaceManagedSQLServerBlobAuditingPoliciesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkspaceManagedSQLServerBlobAuditingPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceManagedSQLServerBlobAuditingPoliciesClient, 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+".WorkspaceManagedSQLServerBlobAuditingPoliciesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &WorkspaceManagedSQLServerBlobAuditingPoliciesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,9 +60,9 @@ func (client *WorkspaceManagedSQLServerBlobAuditingPoliciesClient) BeginCreateOr if err != nil { return nil, err } - return runtime.NewPoller[WorkspaceManagedSQLServerBlobAuditingPoliciesClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[WorkspaceManagedSQLServerBlobAuditingPoliciesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[WorkspaceManagedSQLServerBlobAuditingPoliciesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[WorkspaceManagedSQLServerBlobAuditingPoliciesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -86,7 +75,7 @@ func (client *WorkspaceManagedSQLServerBlobAuditingPoliciesClient) createOrUpdat 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 +104,7 @@ func (client *WorkspaceManagedSQLServerBlobAuditingPoliciesClient) createOrUpdat return nil, errors.New("parameter blobAuditingPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{blobAuditingPolicyName}", url.PathEscape(string(blobAuditingPolicyName))) - 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 } @@ -140,7 +129,7 @@ func (client *WorkspaceManagedSQLServerBlobAuditingPoliciesClient) Get(ctx conte if err != nil { return WorkspaceManagedSQLServerBlobAuditingPoliciesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceManagedSQLServerBlobAuditingPoliciesClientGetResponse{}, err } @@ -169,7 +158,7 @@ func (client *WorkspaceManagedSQLServerBlobAuditingPoliciesClient) getCreateRequ return nil, errors.New("parameter blobAuditingPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{blobAuditingPolicyName}", url.PathEscape(string(blobAuditingPolicyName))) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -212,7 +201,7 @@ func (client *WorkspaceManagedSQLServerBlobAuditingPoliciesClient) NewListByWork if err != nil { return WorkspaceManagedSQLServerBlobAuditingPoliciesClientListByWorkspaceResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceManagedSQLServerBlobAuditingPoliciesClientListByWorkspaceResponse{}, err } @@ -239,7 +228,7 @@ func (client *WorkspaceManagedSQLServerBlobAuditingPoliciesClient) listByWorkspa return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/workspacemanagedsqlserverblobauditingpolicies_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverblobauditingpolicies_client_example_test.go index d5c4570d3258..b896d69ac5d2 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverblobauditingpolicies_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverblobauditingpolicies_client_example_test.go @@ -25,11 +25,11 @@ func ExampleWorkspaceManagedSQLServerBlobAuditingPoliciesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerBlobAuditingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "wsg-7398", "testWorkspace", armsynapse.BlobAuditingPolicyNameDefault, nil) + res, err := clientFactory.NewWorkspaceManagedSQLServerBlobAuditingPoliciesClient().Get(ctx, "wsg-7398", "testWorkspace", armsynapse.BlobAuditingPolicyNameDefault, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -61,11 +61,11 @@ func ExampleWorkspaceManagedSQLServerBlobAuditingPoliciesClient_BeginCreateOrUpd log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerBlobAuditingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.BlobAuditingPolicyNameDefault, armsynapse.ServerBlobAuditingPolicy{ + poller, err := clientFactory.NewWorkspaceManagedSQLServerBlobAuditingPoliciesClient().BeginCreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.BlobAuditingPolicyNameDefault, armsynapse.ServerBlobAuditingPolicy{ Properties: &armsynapse.ServerBlobAuditingPolicyProperties{ AuditActionsAndGroups: []*string{ to.Ptr("SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP"), @@ -118,11 +118,11 @@ func ExampleWorkspaceManagedSQLServerBlobAuditingPoliciesClient_BeginCreateOrUpd log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerBlobAuditingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.BlobAuditingPolicyNameDefault, armsynapse.ServerBlobAuditingPolicy{ + poller, err := clientFactory.NewWorkspaceManagedSQLServerBlobAuditingPoliciesClient().BeginCreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.BlobAuditingPolicyNameDefault, armsynapse.ServerBlobAuditingPolicy{ Properties: &armsynapse.ServerBlobAuditingPolicyProperties{ State: to.Ptr(armsynapse.BlobAuditingPolicyStateEnabled), StorageAccountAccessKey: to.Ptr("sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD=="), @@ -164,11 +164,11 @@ func ExampleWorkspaceManagedSQLServerBlobAuditingPoliciesClient_NewListByWorkspa log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerBlobAuditingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByWorkspacePager("wsg-7398", "testWorkspace", nil) + pager := clientFactory.NewWorkspaceManagedSQLServerBlobAuditingPoliciesClient().NewListByWorkspacePager("wsg-7398", "testWorkspace", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverdedicatedsqlminimaltlssettings_client.go b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverdedicatedsqlminimaltlssettings_client.go index 12d293852f4c..0c20fd35ab92 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverdedicatedsqlminimaltlssettings_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverdedicatedsqlminimaltlssettings_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient contains the methods for the WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettings group. // Don't use this type directly, use NewWorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient() instead. type WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewWorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient creates a new instance of WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient with the specified values. @@ -36,21 +33,13 @@ type WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient, 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+".WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -69,7 +58,7 @@ func (client *WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient) Get if err != nil { return WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClientGetResponse{}, err } @@ -98,7 +87,7 @@ func (client *WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient) get return nil, errors.New("parameter dedicatedSQLminimalTLSSettingsName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dedicatedSQLminimalTlsSettingsName}", url.PathEscape(dedicatedSQLminimalTLSSettingsName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -141,7 +130,7 @@ func (client *WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient) New if err != nil { return WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClientListResponse{}, err } @@ -168,7 +157,7 @@ func (client *WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient) lis return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -204,9 +193,9 @@ func (client *WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient) Beg if err != nil { return nil, err } - return runtime.NewPoller[WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -219,7 +208,7 @@ func (client *WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient) upd 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 } @@ -248,7 +237,7 @@ func (client *WorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient) upd return nil, errors.New("parameter dedicatedSQLminimalTLSSettingsName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dedicatedSQLminimalTlsSettingsName}", url.PathEscape(string(dedicatedSQLminimalTLSSettingsName))) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverdedicatedsqlminimaltlssettings_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverdedicatedsqlminimaltlssettings_client_example_test.go index 8936c3848053..c8eace26ff95 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverdedicatedsqlminimaltlssettings_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverdedicatedsqlminimaltlssettings_client_example_test.go @@ -25,11 +25,11 @@ func ExampleWorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient_BeginU log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "workspace-6852", "workspace-2080", armsynapse.DedicatedSQLMinimalTLSSettingsNameDefault, armsynapse.DedicatedSQLminimalTLSSettings{ + poller, err := clientFactory.NewWorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient().BeginUpdate(ctx, "workspace-6852", "workspace-2080", armsynapse.DedicatedSQLMinimalTLSSettingsNameDefault, armsynapse.DedicatedSQLminimalTLSSettings{ Properties: &armsynapse.DedicatedSQLminimalTLSSettingsProperties{ MinimalTLSVersion: to.Ptr("1.1"), }, @@ -61,11 +61,11 @@ func ExampleWorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient_Get() log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "workspace-6852", "workspace-2080", "default", nil) + res, err := clientFactory.NewWorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient().Get(ctx, "workspace-6852", "workspace-2080", "default", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -90,11 +90,11 @@ func ExampleWorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient_NewLis log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("workspace-6852", "workspace-2080", nil) + pager := clientFactory.NewWorkspaceManagedSQLServerDedicatedSQLMinimalTLSSettingsClient().NewListPager("workspace-6852", "workspace-2080", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverencryptionprotector_client.go b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverencryptionprotector_client.go index 57b99df195a5..2b3050be4f82 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverencryptionprotector_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverencryptionprotector_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // WorkspaceManagedSQLServerEncryptionProtectorClient contains the methods for the WorkspaceManagedSQLServerEncryptionProtector group. // Don't use this type directly, use NewWorkspaceManagedSQLServerEncryptionProtectorClient() instead. type WorkspaceManagedSQLServerEncryptionProtectorClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewWorkspaceManagedSQLServerEncryptionProtectorClient creates a new instance of WorkspaceManagedSQLServerEncryptionProtectorClient with the specified values. @@ -36,21 +33,13 @@ type WorkspaceManagedSQLServerEncryptionProtectorClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkspaceManagedSQLServerEncryptionProtectorClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceManagedSQLServerEncryptionProtectorClient, 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+".WorkspaceManagedSQLServerEncryptionProtectorClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &WorkspaceManagedSQLServerEncryptionProtectorClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,9 +60,9 @@ func (client *WorkspaceManagedSQLServerEncryptionProtectorClient) BeginCreateOrU if err != nil { return nil, err } - return runtime.NewPoller[WorkspaceManagedSQLServerEncryptionProtectorClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[WorkspaceManagedSQLServerEncryptionProtectorClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[WorkspaceManagedSQLServerEncryptionProtectorClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[WorkspaceManagedSQLServerEncryptionProtectorClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -86,7 +75,7 @@ func (client *WorkspaceManagedSQLServerEncryptionProtectorClient) createOrUpdate 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 +104,7 @@ func (client *WorkspaceManagedSQLServerEncryptionProtectorClient) createOrUpdate return nil, errors.New("parameter encryptionProtectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{encryptionProtectorName}", url.PathEscape(string(encryptionProtectorName))) - 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 } @@ -140,7 +129,7 @@ func (client *WorkspaceManagedSQLServerEncryptionProtectorClient) Get(ctx contex if err != nil { return WorkspaceManagedSQLServerEncryptionProtectorClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceManagedSQLServerEncryptionProtectorClientGetResponse{}, err } @@ -169,7 +158,7 @@ func (client *WorkspaceManagedSQLServerEncryptionProtectorClient) getCreateReque return nil, errors.New("parameter encryptionProtectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{encryptionProtectorName}", url.PathEscape(string(encryptionProtectorName))) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -212,7 +201,7 @@ func (client *WorkspaceManagedSQLServerEncryptionProtectorClient) NewListPager(r if err != nil { return WorkspaceManagedSQLServerEncryptionProtectorClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceManagedSQLServerEncryptionProtectorClientListResponse{}, err } @@ -239,7 +228,7 @@ func (client *WorkspaceManagedSQLServerEncryptionProtectorClient) listCreateRequ return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -274,9 +263,9 @@ func (client *WorkspaceManagedSQLServerEncryptionProtectorClient) BeginRevalidat if err != nil { return nil, err } - return runtime.NewPoller[WorkspaceManagedSQLServerEncryptionProtectorClientRevalidateResponse](resp, client.pl, nil) + return runtime.NewPoller[WorkspaceManagedSQLServerEncryptionProtectorClientRevalidateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[WorkspaceManagedSQLServerEncryptionProtectorClientRevalidateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[WorkspaceManagedSQLServerEncryptionProtectorClientRevalidateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -289,7 +278,7 @@ func (client *WorkspaceManagedSQLServerEncryptionProtectorClient) revalidate(ctx 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 } @@ -318,7 +307,7 @@ func (client *WorkspaceManagedSQLServerEncryptionProtectorClient) revalidateCrea return nil, errors.New("parameter encryptionProtectorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{encryptionProtectorName}", url.PathEscape(string(encryptionProtectorName))) - 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/synapse/armsynapse/workspacemanagedsqlserverencryptionprotector_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverencryptionprotector_client_example_test.go index d32318643fe6..65eaa1b4197f 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverencryptionprotector_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverencryptionprotector_client_example_test.go @@ -25,11 +25,11 @@ func ExampleWorkspaceManagedSQLServerEncryptionProtectorClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerEncryptionProtectorClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "wsg-7398", "testWorkspace", armsynapse.EncryptionProtectorNameCurrent, nil) + res, err := clientFactory.NewWorkspaceManagedSQLServerEncryptionProtectorClient().Get(ctx, "wsg-7398", "testWorkspace", armsynapse.EncryptionProtectorNameCurrent, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -57,11 +57,11 @@ func ExampleWorkspaceManagedSQLServerEncryptionProtectorClient_BeginCreateOrUpda log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerEncryptionProtectorClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.EncryptionProtectorNameCurrent, armsynapse.EncryptionProtector{ + poller, err := clientFactory.NewWorkspaceManagedSQLServerEncryptionProtectorClient().BeginCreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.EncryptionProtectorNameCurrent, armsynapse.EncryptionProtector{ Properties: &armsynapse.EncryptionProtectorProperties{ ServerKeyName: to.Ptr("someVault_someKey_01234567890123456789012345678901"), ServerKeyType: to.Ptr(armsynapse.ServerKeyTypeAzureKeyVault), @@ -97,11 +97,11 @@ func ExampleWorkspaceManagedSQLServerEncryptionProtectorClient_BeginCreateOrUpda log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerEncryptionProtectorClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.EncryptionProtectorNameCurrent, armsynapse.EncryptionProtector{ + poller, err := clientFactory.NewWorkspaceManagedSQLServerEncryptionProtectorClient().BeginCreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.EncryptionProtectorNameCurrent, armsynapse.EncryptionProtector{ Properties: &armsynapse.EncryptionProtectorProperties{ ServerKeyName: to.Ptr("ServiceManaged"), ServerKeyType: to.Ptr(armsynapse.ServerKeyTypeServiceManaged), @@ -137,11 +137,11 @@ func ExampleWorkspaceManagedSQLServerEncryptionProtectorClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerEncryptionProtectorClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("wsg-7398", "testWorkspace", nil) + pager := clientFactory.NewWorkspaceManagedSQLServerEncryptionProtectorClient().NewListPager("wsg-7398", "testWorkspace", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -177,11 +177,11 @@ func ExampleWorkspaceManagedSQLServerEncryptionProtectorClient_BeginRevalidate() log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerEncryptionProtectorClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginRevalidate(ctx, "wsg-7398", "testWorkspace", armsynapse.EncryptionProtectorNameCurrent, nil) + poller, err := clientFactory.NewWorkspaceManagedSQLServerEncryptionProtectorClient().BeginRevalidate(ctx, "wsg-7398", "testWorkspace", armsynapse.EncryptionProtectorNameCurrent, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverextendedblobauditingpolicies_client.go b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverextendedblobauditingpolicies_client.go index 8dc4384a4116..fc30fd2eacd2 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverextendedblobauditingpolicies_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverextendedblobauditingpolicies_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient contains the methods for the WorkspaceManagedSQLServerExtendedBlobAuditingPolicies group. // Don't use this type directly, use NewWorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient() instead. type WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewWorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient creates a new instance of WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient with the specified values. @@ -36,21 +33,13 @@ type WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient, 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+".WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,9 +60,9 @@ func (client *WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient) Begin if err != nil { return nil, err } - return runtime.NewPoller[WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -86,7 +75,7 @@ func (client *WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient) creat 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 +104,7 @@ func (client *WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient) creat return nil, errors.New("parameter blobAuditingPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{blobAuditingPolicyName}", url.PathEscape(string(blobAuditingPolicyName))) - 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 } @@ -140,7 +129,7 @@ func (client *WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient) Get(c if err != nil { return WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClientGetResponse{}, err } @@ -169,7 +158,7 @@ func (client *WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient) getCr return nil, errors.New("parameter blobAuditingPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{blobAuditingPolicyName}", url.PathEscape(string(blobAuditingPolicyName))) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -212,7 +201,7 @@ func (client *WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient) NewLi if err != nil { return WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClientListByWorkspaceResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClientListByWorkspaceResponse{}, err } @@ -239,7 +228,7 @@ func (client *WorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient) listB return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/workspacemanagedsqlserverextendedblobauditingpolicies_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverextendedblobauditingpolicies_client_example_test.go index dcee4a6ef00e..cf4a09a56568 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverextendedblobauditingpolicies_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverextendedblobauditingpolicies_client_example_test.go @@ -25,11 +25,11 @@ func ExampleWorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "wsg-7398", "testWorkspace", armsynapse.BlobAuditingPolicyNameDefault, nil) + res, err := clientFactory.NewWorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient().Get(ctx, "wsg-7398", "testWorkspace", armsynapse.BlobAuditingPolicyNameDefault, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -61,11 +61,11 @@ func ExampleWorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient_BeginCre log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.BlobAuditingPolicyNameDefault, armsynapse.ExtendedServerBlobAuditingPolicy{ + poller, err := clientFactory.NewWorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient().BeginCreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.BlobAuditingPolicyNameDefault, armsynapse.ExtendedServerBlobAuditingPolicy{ Properties: &armsynapse.ExtendedServerBlobAuditingPolicyProperties{ AuditActionsAndGroups: []*string{ to.Ptr("SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP"), @@ -118,11 +118,11 @@ func ExampleWorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient_BeginCre log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.BlobAuditingPolicyNameDefault, armsynapse.ExtendedServerBlobAuditingPolicy{ + poller, err := clientFactory.NewWorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient().BeginCreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.BlobAuditingPolicyNameDefault, armsynapse.ExtendedServerBlobAuditingPolicy{ Properties: &armsynapse.ExtendedServerBlobAuditingPolicyProperties{ State: to.Ptr(armsynapse.BlobAuditingPolicyStateEnabled), StorageAccountAccessKey: to.Ptr("sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD=="), @@ -165,11 +165,11 @@ func ExampleWorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient_NewListB log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByWorkspacePager("wsg-7398", "testWorkspace", nil) + pager := clientFactory.NewWorkspaceManagedSQLServerExtendedBlobAuditingPoliciesClient().NewListByWorkspacePager("wsg-7398", "testWorkspace", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverrecoverablesqlpools_client.go b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverrecoverablesqlpools_client.go index f513fb19cb8d..035495b32f9f 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverrecoverablesqlpools_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverrecoverablesqlpools_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // WorkspaceManagedSQLServerRecoverableSQLPoolsClient contains the methods for the WorkspaceManagedSQLServerRecoverableSQLPools group. // Don't use this type directly, use NewWorkspaceManagedSQLServerRecoverableSQLPoolsClient() instead. type WorkspaceManagedSQLServerRecoverableSQLPoolsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewWorkspaceManagedSQLServerRecoverableSQLPoolsClient creates a new instance of WorkspaceManagedSQLServerRecoverableSQLPoolsClient with the specified values. @@ -36,21 +33,13 @@ type WorkspaceManagedSQLServerRecoverableSQLPoolsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkspaceManagedSQLServerRecoverableSQLPoolsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceManagedSQLServerRecoverableSQLPoolsClient, 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+".WorkspaceManagedSQLServerRecoverableSQLPoolsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &WorkspaceManagedSQLServerRecoverableSQLPoolsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -69,7 +58,7 @@ func (client *WorkspaceManagedSQLServerRecoverableSQLPoolsClient) Get(ctx contex if err != nil { return WorkspaceManagedSQLServerRecoverableSQLPoolsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceManagedSQLServerRecoverableSQLPoolsClientGetResponse{}, err } @@ -98,7 +87,7 @@ func (client *WorkspaceManagedSQLServerRecoverableSQLPoolsClient) getCreateReque return nil, errors.New("parameter sqlPoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sqlPoolName}", url.PathEscape(sqlPoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -141,7 +130,7 @@ func (client *WorkspaceManagedSQLServerRecoverableSQLPoolsClient) NewListPager(r if err != nil { return WorkspaceManagedSQLServerRecoverableSQLPoolsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceManagedSQLServerRecoverableSQLPoolsClientListResponse{}, err } @@ -168,7 +157,7 @@ func (client *WorkspaceManagedSQLServerRecoverableSQLPoolsClient) listCreateRequ return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/workspacemanagedsqlserverrecoverablesqlpools_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverrecoverablesqlpools_client_example_test.go index b976d29fe2ac..f7cd9f9e7582 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverrecoverablesqlpools_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverrecoverablesqlpools_client_example_test.go @@ -24,11 +24,11 @@ func ExampleWorkspaceManagedSQLServerRecoverableSQLPoolsClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerRecoverableSQLPoolsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("wsg-7398", "testWorkspace", nil) + pager := clientFactory.NewWorkspaceManagedSQLServerRecoverableSQLPoolsClient().NewListPager("wsg-7398", "testWorkspace", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -82,11 +82,11 @@ func ExampleWorkspaceManagedSQLServerRecoverableSQLPoolsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerRecoverableSQLPoolsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "wsg-7398", "testWorkspace", "recoverableSqlpools-1235", nil) + res, err := clientFactory.NewWorkspaceManagedSQLServerRecoverableSQLPoolsClient().Get(ctx, "wsg-7398", "testWorkspace", "recoverableSqlpools-1235", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserversecurityalertpolicy_client.go b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserversecurityalertpolicy_client.go index c461dedcb7c8..00fb8d59f8ea 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserversecurityalertpolicy_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserversecurityalertpolicy_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // WorkspaceManagedSQLServerSecurityAlertPolicyClient contains the methods for the WorkspaceManagedSQLServerSecurityAlertPolicy group. // Don't use this type directly, use NewWorkspaceManagedSQLServerSecurityAlertPolicyClient() instead. type WorkspaceManagedSQLServerSecurityAlertPolicyClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewWorkspaceManagedSQLServerSecurityAlertPolicyClient creates a new instance of WorkspaceManagedSQLServerSecurityAlertPolicyClient with the specified values. @@ -36,21 +33,13 @@ type WorkspaceManagedSQLServerSecurityAlertPolicyClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkspaceManagedSQLServerSecurityAlertPolicyClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceManagedSQLServerSecurityAlertPolicyClient, 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+".WorkspaceManagedSQLServerSecurityAlertPolicyClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &WorkspaceManagedSQLServerSecurityAlertPolicyClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -71,9 +60,9 @@ func (client *WorkspaceManagedSQLServerSecurityAlertPolicyClient) BeginCreateOrU if err != nil { return nil, err } - return runtime.NewPoller[WorkspaceManagedSQLServerSecurityAlertPolicyClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[WorkspaceManagedSQLServerSecurityAlertPolicyClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[WorkspaceManagedSQLServerSecurityAlertPolicyClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[WorkspaceManagedSQLServerSecurityAlertPolicyClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -86,7 +75,7 @@ func (client *WorkspaceManagedSQLServerSecurityAlertPolicyClient) createOrUpdate 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 +104,7 @@ func (client *WorkspaceManagedSQLServerSecurityAlertPolicyClient) createOrUpdate return nil, errors.New("parameter securityAlertPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{securityAlertPolicyName}", url.PathEscape(string(securityAlertPolicyName))) - 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 } @@ -140,7 +129,7 @@ func (client *WorkspaceManagedSQLServerSecurityAlertPolicyClient) Get(ctx contex if err != nil { return WorkspaceManagedSQLServerSecurityAlertPolicyClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceManagedSQLServerSecurityAlertPolicyClientGetResponse{}, err } @@ -169,7 +158,7 @@ func (client *WorkspaceManagedSQLServerSecurityAlertPolicyClient) getCreateReque return nil, errors.New("parameter securityAlertPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{securityAlertPolicyName}", url.PathEscape(string(securityAlertPolicyName))) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -212,7 +201,7 @@ func (client *WorkspaceManagedSQLServerSecurityAlertPolicyClient) NewListPager(r if err != nil { return WorkspaceManagedSQLServerSecurityAlertPolicyClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceManagedSQLServerSecurityAlertPolicyClientListResponse{}, err } @@ -239,7 +228,7 @@ func (client *WorkspaceManagedSQLServerSecurityAlertPolicyClient) listCreateRequ return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/workspacemanagedsqlserversecurityalertpolicy_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserversecurityalertpolicy_client_example_test.go index 35c6e964c527..c5f5881eeada 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserversecurityalertpolicy_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserversecurityalertpolicy_client_example_test.go @@ -25,11 +25,11 @@ func ExampleWorkspaceManagedSQLServerSecurityAlertPolicyClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerSecurityAlertPolicyClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "wsg-7398", "testWorkspace", armsynapse.SecurityAlertPolicyNameAutoGeneratedDefault, nil) + res, err := clientFactory.NewWorkspaceManagedSQLServerSecurityAlertPolicyClient().Get(ctx, "wsg-7398", "testWorkspace", armsynapse.SecurityAlertPolicyNameAutoGeneratedDefault, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -62,11 +62,11 @@ func ExampleWorkspaceManagedSQLServerSecurityAlertPolicyClient_BeginCreateOrUpda log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerSecurityAlertPolicyClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.SecurityAlertPolicyNameAutoGeneratedDefault, armsynapse.ServerSecurityAlertPolicy{ + poller, err := clientFactory.NewWorkspaceManagedSQLServerSecurityAlertPolicyClient().BeginCreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.SecurityAlertPolicyNameAutoGeneratedDefault, armsynapse.ServerSecurityAlertPolicy{ Properties: &armsynapse.ServerSecurityAlertPolicyProperties{ DisabledAlerts: []*string{ to.Ptr("Access_Anomaly"), @@ -117,11 +117,11 @@ func ExampleWorkspaceManagedSQLServerSecurityAlertPolicyClient_BeginCreateOrUpda log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerSecurityAlertPolicyClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.SecurityAlertPolicyNameAutoGeneratedDefault, armsynapse.ServerSecurityAlertPolicy{ + poller, err := clientFactory.NewWorkspaceManagedSQLServerSecurityAlertPolicyClient().BeginCreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.SecurityAlertPolicyNameAutoGeneratedDefault, armsynapse.ServerSecurityAlertPolicy{ Properties: &armsynapse.ServerSecurityAlertPolicyProperties{ EmailAccountAdmins: to.Ptr(true), State: to.Ptr(armsynapse.SecurityAlertPolicyStateDisabled), @@ -165,11 +165,11 @@ func ExampleWorkspaceManagedSQLServerSecurityAlertPolicyClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerSecurityAlertPolicyClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("wsg-7398", "testWorkspace", nil) + pager := clientFactory.NewWorkspaceManagedSQLServerSecurityAlertPolicyClient().NewListPager("wsg-7398", "testWorkspace", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverusages_client.go b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverusages_client.go index e624316434b3..133d43c7bb39 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverusages_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverusages_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // WorkspaceManagedSQLServerUsagesClient contains the methods for the WorkspaceManagedSQLServerUsages group. // Don't use this type directly, use NewWorkspaceManagedSQLServerUsagesClient() instead. type WorkspaceManagedSQLServerUsagesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewWorkspaceManagedSQLServerUsagesClient creates a new instance of WorkspaceManagedSQLServerUsagesClient with the specified values. @@ -36,21 +33,13 @@ type WorkspaceManagedSQLServerUsagesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkspaceManagedSQLServerUsagesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceManagedSQLServerUsagesClient, 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+".WorkspaceManagedSQLServerUsagesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &WorkspaceManagedSQLServerUsagesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -78,7 +67,7 @@ func (client *WorkspaceManagedSQLServerUsagesClient) NewListPager(resourceGroupN if err != nil { return WorkspaceManagedSQLServerUsagesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceManagedSQLServerUsagesClientListResponse{}, err } @@ -105,7 +94,7 @@ func (client *WorkspaceManagedSQLServerUsagesClient) listCreateRequest(ctx conte return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/workspacemanagedsqlserverusages_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverusages_client_example_test.go index 33977bf9ecf8..ad4755aae98c 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverusages_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlserverusages_client_example_test.go @@ -24,11 +24,11 @@ func ExampleWorkspaceManagedSQLServerUsagesClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerUsagesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("wsg-7398", "testWorkspace", nil) + pager := clientFactory.NewWorkspaceManagedSQLServerUsagesClient().NewListPager("wsg-7398", "testWorkspace", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlservervulnerabilityassessments_client.go b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlservervulnerabilityassessments_client.go index fc36c8df3a43..e531a779c0a5 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlservervulnerabilityassessments_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlservervulnerabilityassessments_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // WorkspaceManagedSQLServerVulnerabilityAssessmentsClient contains the methods for the WorkspaceManagedSQLServerVulnerabilityAssessments group. // Don't use this type directly, use NewWorkspaceManagedSQLServerVulnerabilityAssessmentsClient() instead. type WorkspaceManagedSQLServerVulnerabilityAssessmentsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewWorkspaceManagedSQLServerVulnerabilityAssessmentsClient creates a new instance of WorkspaceManagedSQLServerVulnerabilityAssessmentsClient with the specified values. @@ -36,21 +33,13 @@ type WorkspaceManagedSQLServerVulnerabilityAssessmentsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkspaceManagedSQLServerVulnerabilityAssessmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceManagedSQLServerVulnerabilityAssessmentsClient, 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+".WorkspaceManagedSQLServerVulnerabilityAssessmentsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &WorkspaceManagedSQLServerVulnerabilityAssessmentsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,7 +59,7 @@ func (client *WorkspaceManagedSQLServerVulnerabilityAssessmentsClient) CreateOrU if err != nil { return WorkspaceManagedSQLServerVulnerabilityAssessmentsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceManagedSQLServerVulnerabilityAssessmentsClientCreateOrUpdateResponse{}, err } @@ -99,7 +88,7 @@ func (client *WorkspaceManagedSQLServerVulnerabilityAssessmentsClient) createOrU return nil, errors.New("parameter vulnerabilityAssessmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vulnerabilityAssessmentName}", url.PathEscape(string(vulnerabilityAssessmentName))) - 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,7 +122,7 @@ func (client *WorkspaceManagedSQLServerVulnerabilityAssessmentsClient) Delete(ct if err != nil { return WorkspaceManagedSQLServerVulnerabilityAssessmentsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceManagedSQLServerVulnerabilityAssessmentsClientDeleteResponse{}, err } @@ -162,7 +151,7 @@ func (client *WorkspaceManagedSQLServerVulnerabilityAssessmentsClient) deleteCre return nil, errors.New("parameter vulnerabilityAssessmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vulnerabilityAssessmentName}", url.PathEscape(string(vulnerabilityAssessmentName))) - 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,7 +175,7 @@ func (client *WorkspaceManagedSQLServerVulnerabilityAssessmentsClient) Get(ctx c if err != nil { return WorkspaceManagedSQLServerVulnerabilityAssessmentsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceManagedSQLServerVulnerabilityAssessmentsClientGetResponse{}, err } @@ -215,7 +204,7 @@ func (client *WorkspaceManagedSQLServerVulnerabilityAssessmentsClient) getCreate return nil, errors.New("parameter vulnerabilityAssessmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vulnerabilityAssessmentName}", url.PathEscape(string(vulnerabilityAssessmentName))) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -258,7 +247,7 @@ func (client *WorkspaceManagedSQLServerVulnerabilityAssessmentsClient) NewListPa if err != nil { return WorkspaceManagedSQLServerVulnerabilityAssessmentsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceManagedSQLServerVulnerabilityAssessmentsClientListResponse{}, err } @@ -285,7 +274,7 @@ func (client *WorkspaceManagedSQLServerVulnerabilityAssessmentsClient) listCreat return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/workspacemanagedsqlservervulnerabilityassessments_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlservervulnerabilityassessments_client_example_test.go index e393a07d5d9d..bf3698b813c2 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlservervulnerabilityassessments_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacemanagedsqlservervulnerabilityassessments_client_example_test.go @@ -25,11 +25,11 @@ func ExampleWorkspaceManagedSQLServerVulnerabilityAssessmentsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerVulnerabilityAssessmentsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "wsg-7398", "testWorkspace", armsynapse.VulnerabilityAssessmentNameDefault, nil) + res, err := clientFactory.NewWorkspaceManagedSQLServerVulnerabilityAssessmentsClient().Get(ctx, "wsg-7398", "testWorkspace", armsynapse.VulnerabilityAssessmentNameDefault, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -60,11 +60,11 @@ func ExampleWorkspaceManagedSQLServerVulnerabilityAssessmentsClient_CreateOrUpda log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerVulnerabilityAssessmentsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.VulnerabilityAssessmentNameDefault, armsynapse.ServerVulnerabilityAssessment{ + res, err := clientFactory.NewWorkspaceManagedSQLServerVulnerabilityAssessmentsClient().CreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.VulnerabilityAssessmentNameDefault, armsynapse.ServerVulnerabilityAssessment{ Properties: &armsynapse.ServerVulnerabilityAssessmentProperties{ RecurringScans: &armsynapse.VulnerabilityAssessmentRecurringScansProperties{ EmailSubscriptionAdmins: to.Ptr(true), @@ -108,11 +108,11 @@ func ExampleWorkspaceManagedSQLServerVulnerabilityAssessmentsClient_CreateOrUpda log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerVulnerabilityAssessmentsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.VulnerabilityAssessmentNameDefault, armsynapse.ServerVulnerabilityAssessment{ + res, err := clientFactory.NewWorkspaceManagedSQLServerVulnerabilityAssessmentsClient().CreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.VulnerabilityAssessmentNameDefault, armsynapse.ServerVulnerabilityAssessment{ Properties: &armsynapse.ServerVulnerabilityAssessmentProperties{ StorageAccountAccessKey: to.Ptr("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"), StorageContainerPath: to.Ptr("https://myStorage.blob.core.windows.net/vulnerability-assessment/"), @@ -147,11 +147,11 @@ func ExampleWorkspaceManagedSQLServerVulnerabilityAssessmentsClient_CreateOrUpda log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerVulnerabilityAssessmentsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.VulnerabilityAssessmentNameDefault, armsynapse.ServerVulnerabilityAssessment{ + res, err := clientFactory.NewWorkspaceManagedSQLServerVulnerabilityAssessmentsClient().CreateOrUpdate(ctx, "wsg-7398", "testWorkspace", armsynapse.VulnerabilityAssessmentNameDefault, armsynapse.ServerVulnerabilityAssessment{ Properties: &armsynapse.ServerVulnerabilityAssessmentProperties{ StorageContainerPath: to.Ptr("https://myStorage.blob.core.windows.net/vulnerability-assessment/"), StorageContainerSasKey: to.Ptr("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"), @@ -186,11 +186,11 @@ func ExampleWorkspaceManagedSQLServerVulnerabilityAssessmentsClient_Delete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerVulnerabilityAssessmentsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "wsg-7398", "testWorkspace", armsynapse.VulnerabilityAssessmentNameDefault, nil) + _, err = clientFactory.NewWorkspaceManagedSQLServerVulnerabilityAssessmentsClient().Delete(ctx, "wsg-7398", "testWorkspace", armsynapse.VulnerabilityAssessmentNameDefault, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -203,11 +203,11 @@ func ExampleWorkspaceManagedSQLServerVulnerabilityAssessmentsClient_NewListPager log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceManagedSQLServerVulnerabilityAssessmentsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("wsg-7398", "testWorkspace", nil) + pager := clientFactory.NewWorkspaceManagedSQLServerVulnerabilityAssessmentsClient().NewListPager("wsg-7398", "testWorkspace", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/workspaces_client.go b/sdk/resourcemanager/synapse/armsynapse/workspaces_client.go index 4eb819f8314b..e5379548ee8d 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspaces_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspaces_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // WorkspacesClient contains the methods for the Workspaces group. // Don't use this type directly, use NewWorkspacesClient() instead. type WorkspacesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewWorkspacesClient creates a new instance of WorkspacesClient with the specified values. @@ -36,21 +33,13 @@ type WorkspacesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkspacesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspacesClient, 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+".WorkspacesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &WorkspacesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,11 +59,11 @@ func (client *WorkspacesClient) BeginCreateOrUpdate(ctx context.Context, resourc if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[WorkspacesClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkspacesClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[WorkspacesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[WorkspacesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -87,7 +76,7 @@ func (client *WorkspacesClient) createOrUpdate(ctx context.Context, resourceGrou 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 +101,7 @@ func (client *WorkspacesClient) createOrUpdateCreateRequest(ctx context.Context, return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - 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 } @@ -136,11 +125,11 @@ func (client *WorkspacesClient) BeginDelete(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[WorkspacesClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkspacesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[WorkspacesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[WorkspacesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -153,7 +142,7 @@ func (client *WorkspacesClient) deleteOperation(ctx context.Context, resourceGro 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 +167,7 @@ func (client *WorkspacesClient) deleteCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - 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 } @@ -201,7 +190,7 @@ func (client *WorkspacesClient) Get(ctx context.Context, resourceGroupName strin if err != nil { return WorkspacesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspacesClientGetResponse{}, err } @@ -226,7 +215,7 @@ func (client *WorkspacesClient) getCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -266,7 +255,7 @@ func (client *WorkspacesClient) NewListPager(options *WorkspacesClientListOption if err != nil { return WorkspacesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspacesClientListResponse{}, err } @@ -285,7 +274,7 @@ func (client *WorkspacesClient) 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 } @@ -327,7 +316,7 @@ func (client *WorkspacesClient) NewListByResourceGroupPager(resourceGroupName st if err != nil { return WorkspacesClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspacesClientListByResourceGroupResponse{}, err } @@ -350,7 +339,7 @@ func (client *WorkspacesClient) listByResourceGroupCreateRequest(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.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -384,11 +373,11 @@ func (client *WorkspacesClient) BeginUpdate(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[WorkspacesClientUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkspacesClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[WorkspacesClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[WorkspacesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -401,7 +390,7 @@ func (client *WorkspacesClient) update(ctx context.Context, resourceGroupName st 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 } @@ -426,7 +415,7 @@ func (client *WorkspacesClient) updateCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - 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/synapse/armsynapse/workspaces_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/workspaces_client_example_test.go index 965b7a870e4a..1ea2f387c49b 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspaces_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspaces_client_example_test.go @@ -25,11 +25,11 @@ func ExampleWorkspacesClient_NewListByResourceGroupPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspacesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("resourceGroup1", nil) + pager := clientFactory.NewWorkspacesClient().NewListByResourceGroupPager("resourceGroup1", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -99,11 +99,11 @@ func ExampleWorkspacesClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspacesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "resourceGroup1", "workspace1", nil) + res, err := clientFactory.NewWorkspacesClient().Get(ctx, "resourceGroup1", "workspace1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -185,11 +185,11 @@ func ExampleWorkspacesClient_BeginUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspacesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "resourceGroup1", "workspace1", armsynapse.WorkspacePatchInfo{ + poller, err := clientFactory.NewWorkspacesClient().BeginUpdate(ctx, "resourceGroup1", "workspace1", armsynapse.WorkspacePatchInfo{ Identity: &armsynapse.ManagedIdentity{ Type: to.Ptr(armsynapse.ResourceIdentityTypeSystemAssigned), }, @@ -289,11 +289,11 @@ func ExampleWorkspacesClient_BeginCreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspacesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "resourceGroup1", "workspace1", armsynapse.Workspace{ + poller, err := clientFactory.NewWorkspacesClient().BeginCreateOrUpdate(ctx, "resourceGroup1", "workspace1", armsynapse.Workspace{ Location: to.Ptr("East US"), Tags: map[string]*string{ "key": to.Ptr("value"), @@ -444,11 +444,11 @@ func ExampleWorkspacesClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspacesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "resourceGroup1", "workspace1", nil) + poller, err := clientFactory.NewWorkspacesClient().BeginDelete(ctx, "resourceGroup1", "workspace1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -490,11 +490,11 @@ func ExampleWorkspacesClient_NewListPager() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspacesClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewWorkspacesClient().NewListPager(nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/synapse/armsynapse/workspacesqlaadadmins_client.go b/sdk/resourcemanager/synapse/armsynapse/workspacesqlaadadmins_client.go index 348963fa9cb3..747ba9dab30c 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacesqlaadadmins_client.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacesqlaadadmins_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,9 +24,8 @@ import ( // WorkspaceSQLAADAdminsClient contains the methods for the WorkspaceSQLAADAdmins group. // Don't use this type directly, use NewWorkspaceSQLAADAdminsClient() instead. type WorkspaceSQLAADAdminsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewWorkspaceSQLAADAdminsClient creates a new instance of WorkspaceSQLAADAdminsClient with the specified values. @@ -36,21 +33,13 @@ type WorkspaceSQLAADAdminsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkspaceSQLAADAdminsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspaceSQLAADAdminsClient, 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+".WorkspaceSQLAADAdminsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &WorkspaceSQLAADAdminsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -70,11 +59,11 @@ func (client *WorkspaceSQLAADAdminsClient) BeginCreateOrUpdate(ctx context.Conte if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[WorkspaceSQLAADAdminsClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkspaceSQLAADAdminsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[WorkspaceSQLAADAdminsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[WorkspaceSQLAADAdminsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -87,7 +76,7 @@ func (client *WorkspaceSQLAADAdminsClient) createOrUpdate(ctx context.Context, r 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 +101,7 @@ func (client *WorkspaceSQLAADAdminsClient) createOrUpdateCreateRequest(ctx conte return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - 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 } @@ -137,11 +126,11 @@ func (client *WorkspaceSQLAADAdminsClient) BeginDelete(ctx context.Context, reso if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[WorkspaceSQLAADAdminsClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkspaceSQLAADAdminsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[WorkspaceSQLAADAdminsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[WorkspaceSQLAADAdminsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -154,7 +143,7 @@ func (client *WorkspaceSQLAADAdminsClient) deleteOperation(ctx context.Context, 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 +168,7 @@ func (client *WorkspaceSQLAADAdminsClient) deleteCreateRequest(ctx context.Conte return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -203,7 +192,7 @@ func (client *WorkspaceSQLAADAdminsClient) Get(ctx context.Context, resourceGrou if err != nil { return WorkspaceSQLAADAdminsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkspaceSQLAADAdminsClientGetResponse{}, err } @@ -228,7 +217,7 @@ func (client *WorkspaceSQLAADAdminsClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter workspaceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{workspaceName}", url.PathEscape(workspaceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/synapse/armsynapse/workspacesqlaadadmins_client_example_test.go b/sdk/resourcemanager/synapse/armsynapse/workspacesqlaadadmins_client_example_test.go index 7f13f85a0d12..8a59c40254b5 100644 --- a/sdk/resourcemanager/synapse/armsynapse/workspacesqlaadadmins_client_example_test.go +++ b/sdk/resourcemanager/synapse/armsynapse/workspacesqlaadadmins_client_example_test.go @@ -25,11 +25,11 @@ func ExampleWorkspaceSQLAADAdminsClient_Get() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceSQLAADAdminsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "resourceGroup1", "workspace1", nil) + res, err := clientFactory.NewWorkspaceSQLAADAdminsClient().Get(ctx, "resourceGroup1", "workspace1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -55,11 +55,11 @@ func ExampleWorkspaceSQLAADAdminsClient_BeginCreateOrUpdate() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceSQLAADAdminsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, "resourceGroup1", "workspace1", armsynapse.WorkspaceAADAdminInfo{ + poller, err := clientFactory.NewWorkspaceSQLAADAdminsClient().BeginCreateOrUpdate(ctx, "resourceGroup1", "workspace1", armsynapse.WorkspaceAADAdminInfo{ Properties: &armsynapse.AADAdminProperties{ AdministratorType: to.Ptr("ActiveDirectory"), Login: to.Ptr("bob@contoso.com"), @@ -96,11 +96,11 @@ func ExampleWorkspaceSQLAADAdminsClient_BeginDelete() { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armsynapse.NewWorkspaceSQLAADAdminsClient("00000000-1111-2222-3333-444444444444", cred, nil) + clientFactory, err := armsynapse.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "resourceGroup1", "workspace1", nil) + poller, err := clientFactory.NewWorkspaceSQLAADAdminsClient().BeginDelete(ctx, "resourceGroup1", "workspace1", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/testbase/armtestbase/CHANGELOG.md b/sdk/resourcemanager/testbase/armtestbase/CHANGELOG.md index 49369cbf3a60..67ede0c0236e 100644 --- a/sdk/resourcemanager/testbase/armtestbase/CHANGELOG.md +++ b/sdk/resourcemanager/testbase/armtestbase/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 0.6.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 0.5.0 (2022-05-18) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase` 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/testbase/armtestbase/README.md b/sdk/resourcemanager/testbase/armtestbase/README.md index f39d30094bf4..cd290af826ce 100644 --- a/sdk/resourcemanager/testbase/armtestbase/README.md +++ b/sdk/resourcemanager/testbase/armtestbase/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 Test Base for M365 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 Test Base for M365 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 := armtestbase.NewEmailEventsClient(, cred, nil) +clientFactory, err := armtestbase.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 := armtestbase.NewEmailEventsClient(, cred, &options) +clientFactory, err := armtestbase.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.NewEmailEventsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/testbase/armtestbase/zz_generated_accounts_client.go b/sdk/resourcemanager/testbase/armtestbase/accounts_client.go similarity index 84% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_accounts_client.go rename to sdk/resourcemanager/testbase/armtestbase/accounts_client.go index 682e6f3478e9..d1fedea9e5d7 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_accounts_client.go +++ b/sdk/resourcemanager/testbase/armtestbase/accounts_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 armtestbase @@ -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 ( // AccountsClient contains the methods for the TestBaseAccounts 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. This is a GUID-formatted string. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string. +// - 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 } // CheckPackageNameAvailability - Checks that the Test Base Package name and version is valid and is not already in use. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// parameters - Parameters supplied to the Test Base Package CheckNameAvailability operation. -// options - AccountsClientCheckPackageNameAvailabilityOptions contains the optional parameters for the AccountsClient.CheckPackageNameAvailability -// method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - parameters - Parameters supplied to the Test Base Package CheckNameAvailability operation. +// - options - AccountsClientCheckPackageNameAvailabilityOptions contains the optional parameters for the AccountsClient.CheckPackageNameAvailability +// method. func (client *AccountsClient) CheckPackageNameAvailability(ctx context.Context, resourceGroupName string, testBaseAccountName string, parameters PackageCheckNameAvailabilityParameters, options *AccountsClientCheckPackageNameAvailabilityOptions) (AccountsClientCheckPackageNameAvailabilityResponse, error) { req, err := client.checkPackageNameAvailabilityCreateRequest(ctx, resourceGroupName, testBaseAccountName, parameters, options) if err != nil { return AccountsClientCheckPackageNameAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientCheckPackageNameAvailabilityResponse{}, err } @@ -93,7 +84,7 @@ func (client *AccountsClient) checkPackageNameAvailabilityCreateRequest(ctx cont return nil, errors.New("parameter testBaseAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testBaseAccountName}", url.PathEscape(testBaseAccountName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -115,34 +106,36 @@ func (client *AccountsClient) checkPackageNameAvailabilityHandleResponse(resp *h // BeginCreate - Create or replace (overwrite/recreate, with potential downtime) a Test Base Account in the specified subscription. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// parameters - Parameters supplied to create a Test Base Account. -// options - AccountsClientBeginCreateOptions contains the optional parameters for the AccountsClient.BeginCreate method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - parameters - Parameters supplied to create a Test Base Account. +// - options - AccountsClientBeginCreateOptions contains the optional parameters for the AccountsClient.BeginCreate method. func (client *AccountsClient) BeginCreate(ctx context.Context, resourceGroupName string, testBaseAccountName string, parameters AccountResource, options *AccountsClientBeginCreateOptions) (*runtime.Poller[AccountsClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, testBaseAccountName, parameters, 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 - Create or replace (overwrite/recreate, with potential downtime) a Test Base Account in the specified subscription. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview func (client *AccountsClient) create(ctx context.Context, resourceGroupName string, testBaseAccountName string, parameters AccountResource, options *AccountsClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, testBaseAccountName, 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 } @@ -167,7 +160,7 @@ func (client *AccountsClient) createCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter testBaseAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testBaseAccountName}", url.PathEscape(testBaseAccountName)) - 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 } @@ -183,33 +176,35 @@ func (client *AccountsClient) createCreateRequest(ctx context.Context, resourceG // BeginDelete - Deletes a Test Base Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// options - AccountsClientBeginDeleteOptions contains the optional parameters for the AccountsClient.BeginDelete method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - options - AccountsClientBeginDeleteOptions contains the optional parameters for the AccountsClient.BeginDelete method. func (client *AccountsClient) BeginDelete(ctx context.Context, resourceGroupName string, testBaseAccountName string, options *AccountsClientBeginDeleteOptions) (*runtime.Poller[AccountsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, testBaseAccountName, 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.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[AccountsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AccountsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a Test Base Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview func (client *AccountsClient) deleteOperation(ctx context.Context, resourceGroupName string, testBaseAccountName string, options *AccountsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, testBaseAccountName, 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 +229,7 @@ func (client *AccountsClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter testBaseAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testBaseAccountName}", url.PathEscape(testBaseAccountName)) - 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 } @@ -247,16 +242,17 @@ func (client *AccountsClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Gets a Test Base Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// options - AccountsClientGetOptions contains the optional parameters for the AccountsClient.Get method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - options - AccountsClientGetOptions contains the optional parameters for the AccountsClient.Get method. func (client *AccountsClient) Get(ctx context.Context, resourceGroupName string, testBaseAccountName string, options *AccountsClientGetOptions) (AccountsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, testBaseAccountName, 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 } @@ -281,7 +277,7 @@ func (client *AccountsClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter testBaseAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testBaseAccountName}", url.PathEscape(testBaseAccountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -303,17 +299,18 @@ func (client *AccountsClient) getHandleResponse(resp *http.Response) (AccountsCl // GetFileUploadURL - Gets the file upload URL of a Test Base Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// options - AccountsClientGetFileUploadURLOptions contains the optional parameters for the AccountsClient.GetFileUploadURL -// method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - options - AccountsClientGetFileUploadURLOptions contains the optional parameters for the AccountsClient.GetFileUploadURL +// method. func (client *AccountsClient) GetFileUploadURL(ctx context.Context, resourceGroupName string, testBaseAccountName string, options *AccountsClientGetFileUploadURLOptions) (AccountsClientGetFileUploadURLResponse, error) { req, err := client.getFileUploadURLCreateRequest(ctx, resourceGroupName, testBaseAccountName, options) if err != nil { return AccountsClientGetFileUploadURLResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientGetFileUploadURLResponse{}, err } @@ -338,7 +335,7 @@ func (client *AccountsClient) getFileUploadURLCreateRequest(ctx context.Context, return nil, errors.New("parameter testBaseAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testBaseAccountName}", url.PathEscape(testBaseAccountName)) - 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 } @@ -362,11 +359,11 @@ func (client *AccountsClient) getFileUploadURLHandleResponse(resp *http.Response } // NewListByResourceGroupPager - Lists all the Test Base Accounts in a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// options - AccountsClientListByResourceGroupOptions contains the optional parameters for the AccountsClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - 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 { @@ -383,7 +380,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 } @@ -406,7 +403,7 @@ func (client *AccountsClient) 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 } @@ -430,10 +427,10 @@ func (client *AccountsClient) listByResourceGroupHandleResponse(resp *http.Respo } // NewListBySubscriptionPager - Lists all the Test Base Accounts in a subscription. This API is required by ARM guidelines. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// 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 { @@ -450,7 +447,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 } @@ -469,7 +466,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 } @@ -494,33 +491,35 @@ func (client *AccountsClient) listBySubscriptionHandleResponse(resp *http.Respon // BeginOffboard - Offboard a Test Base Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// options - AccountsClientBeginOffboardOptions contains the optional parameters for the AccountsClient.BeginOffboard method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - options - AccountsClientBeginOffboardOptions contains the optional parameters for the AccountsClient.BeginOffboard method. func (client *AccountsClient) BeginOffboard(ctx context.Context, resourceGroupName string, testBaseAccountName string, options *AccountsClientBeginOffboardOptions) (*runtime.Poller[AccountsClientOffboardResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.offboard(ctx, resourceGroupName, testBaseAccountName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AccountsClientOffboardResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AccountsClientOffboardResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[AccountsClientOffboardResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AccountsClientOffboardResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Offboard - Offboard a Test Base Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview func (client *AccountsClient) offboard(ctx context.Context, resourceGroupName string, testBaseAccountName string, options *AccountsClientBeginOffboardOptions) (*http.Response, error) { req, err := client.offboardCreateRequest(ctx, resourceGroupName, testBaseAccountName, 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 } @@ -545,7 +544,7 @@ func (client *AccountsClient) offboardCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter testBaseAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testBaseAccountName}", url.PathEscape(testBaseAccountName)) - 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 } @@ -558,34 +557,36 @@ func (client *AccountsClient) offboardCreateRequest(ctx context.Context, resourc // BeginUpdate - Update an existing Test Base Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// parameters - Parameters supplied to update a Test Base Account. -// options - AccountsClientBeginUpdateOptions contains the optional parameters for the AccountsClient.BeginUpdate method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - parameters - Parameters supplied to update a Test Base Account. +// - options - AccountsClientBeginUpdateOptions contains the optional parameters for the AccountsClient.BeginUpdate method. func (client *AccountsClient) BeginUpdate(ctx context.Context, resourceGroupName string, testBaseAccountName string, parameters AccountUpdateParameters, options *AccountsClientBeginUpdateOptions) (*runtime.Poller[AccountsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, testBaseAccountName, parameters, 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 - Update an existing Test Base Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview func (client *AccountsClient) update(ctx context.Context, resourceGroupName string, testBaseAccountName string, parameters AccountUpdateParameters, options *AccountsClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, testBaseAccountName, 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 } @@ -610,7 +611,7 @@ func (client *AccountsClient) updateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter testBaseAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testBaseAccountName}", url.PathEscape(testBaseAccountName)) - 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/testbase/armtestbase/accounts_client_example_test.go b/sdk/resourcemanager/testbase/armtestbase/accounts_client_example_test.go new file mode 100644 index 000000000000..d69e95df3c11 --- /dev/null +++ b/sdk/resourcemanager/testbase/armtestbase/accounts_client_example_test.go @@ -0,0 +1,457 @@ +//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 armtestbase_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/testbase/armtestbase" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestBaseAccountsListBySubscription.json +func ExampleAccountsClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAccountsClient().NewListBySubscriptionPager(&armtestbase.AccountsClientListBySubscriptionOptions{GetDeleted: 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.AccountListResult = armtestbase.AccountListResult{ + // Value: []*armtestbase.AccountResource{ + // { + // Name: to.Ptr("contoso-testBaseAccount1"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // }, + // Properties: &armtestbase.AccountResourceProperties{ + // AccessLevel: to.Ptr("EarlyAccess"), + // ProvisioningState: to.Ptr(armtestbase.ProvisioningStateSucceeded), + // SKU: &armtestbase.AccountSKU{ + // Name: to.Ptr("S0"), + // Capabilities: []*armtestbase.AccountSKUCapability{ + // { + // Name: to.Ptr("SLA"), + // Value: to.Ptr("99.9%"), + // }, + // { + // Name: to.Ptr("maximumPackageCount"), + // Value: to.Ptr("5"), + // }, + // { + // Name: to.Ptr("packageMaximumRunSeconds"), + // Value: to.Ptr("3600"), + // }}, + // Tier: to.Ptr(armtestbase.TierStandard), + // }, + // }, + // }, + // { + // Name: to.Ptr("contoso-testBaseAccount2"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg2/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount2"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armtestbase.AccountResourceProperties{ + // AccessLevel: to.Ptr("EarlyAccess"), + // ProvisioningState: to.Ptr(armtestbase.ProvisioningStateSucceeded), + // SKU: &armtestbase.AccountSKU{ + // Name: to.Ptr("S0"), + // Capabilities: []*armtestbase.AccountSKUCapability{ + // { + // Name: to.Ptr("SLA"), + // Value: to.Ptr("99.999%"), + // }, + // { + // Name: to.Ptr("maximumPackageCount"), + // Value: to.Ptr("100"), + // }, + // { + // Name: to.Ptr("packageMaximumRunSeconds"), + // Value: to.Ptr("10800"), + // }}, + // Tier: to.Ptr(armtestbase.TierStandard), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestBaseAccountsList.json +func ExampleAccountsClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAccountsClient().NewListByResourceGroupPager("contoso-rg1", &armtestbase.AccountsClientListByResourceGroupOptions{GetDeleted: 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.AccountListResult = armtestbase.AccountListResult{ + // Value: []*armtestbase.AccountResource{ + // { + // Name: to.Ptr("contoso-testBaseAccount1"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // }, + // Properties: &armtestbase.AccountResourceProperties{ + // AccessLevel: to.Ptr("EarlyAccess"), + // ProvisioningState: to.Ptr(armtestbase.ProvisioningStateSucceeded), + // SKU: &armtestbase.AccountSKU{ + // Name: to.Ptr("S0"), + // Capabilities: []*armtestbase.AccountSKUCapability{ + // { + // Name: to.Ptr("SLA"), + // Value: to.Ptr("99.9%"), + // }, + // { + // Name: to.Ptr("maximumPackageCount"), + // Value: to.Ptr("5"), + // }, + // { + // Name: to.Ptr("packageMaximumRunSeconds"), + // Value: to.Ptr("3600"), + // }}, + // Tier: to.Ptr(armtestbase.TierStandard), + // }, + // }, + // }, + // { + // Name: to.Ptr("contoso-testBaseAccount2"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg2/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount2"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armtestbase.AccountResourceProperties{ + // AccessLevel: to.Ptr("EarlyAccess"), + // ProvisioningState: to.Ptr(armtestbase.ProvisioningStateSucceeded), + // SKU: &armtestbase.AccountSKU{ + // Name: to.Ptr("S0"), + // Capabilities: []*armtestbase.AccountSKUCapability{ + // { + // Name: to.Ptr("SLA"), + // Value: to.Ptr("99.999%"), + // }, + // { + // Name: to.Ptr("maximumPackageCount"), + // Value: to.Ptr("100"), + // }, + // { + // Name: to.Ptr("packageMaximumRunSeconds"), + // Value: to.Ptr("10800"), + // }}, + // Tier: to.Ptr(armtestbase.TierStandard), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestBaseAccountCreate.json +func ExampleAccountsClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAccountsClient().BeginCreate(ctx, "contoso-rg1", "contoso-testBaseAccount1", armtestbase.AccountResource{ + Location: to.Ptr("westus"), + Properties: &armtestbase.AccountResourceProperties{ + SKU: &armtestbase.AccountSKU{ + Name: to.Ptr("S0"), + Tier: to.Ptr(armtestbase.TierStandard), + }, + }, + }, &armtestbase.AccountsClientBeginCreateOptions{Restore: 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.AccountResource = armtestbase.AccountResource{ + // Name: to.Ptr("contoso-testBaseAccount1"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // }, + // Properties: &armtestbase.AccountResourceProperties{ + // AccessLevel: to.Ptr("StandardAccess"), + // ProvisioningState: to.Ptr(armtestbase.ProvisioningStateSucceeded), + // SKU: &armtestbase.AccountSKU{ + // Name: to.Ptr("S0"), + // Capabilities: []*armtestbase.AccountSKUCapability{ + // { + // Name: to.Ptr("SLA"), + // Value: to.Ptr("99.9%"), + // }, + // { + // Name: to.Ptr("maximumPackageCount"), + // Value: to.Ptr("5"), + // }, + // { + // Name: to.Ptr("packageMaximumRunSeconds"), + // Value: to.Ptr("3600"), + // }}, + // Tier: to.Ptr(armtestbase.TierStandard), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestBaseAccountUpdate.json +func ExampleAccountsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAccountsClient().BeginUpdate(ctx, "contoso-rg1", "contoso-testBaseAccount1", armtestbase.AccountUpdateParameters{ + Properties: &armtestbase.AccountUpdateParameterProperties{ + SKU: &armtestbase.AccountSKU{ + Name: to.Ptr("S0"), + Tier: to.Ptr(armtestbase.TierStandard), + }, + }, + }, 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.AccountResource = armtestbase.AccountResource{ + // Name: to.Ptr("contoso-testBaseAccount1"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // }, + // Properties: &armtestbase.AccountResourceProperties{ + // AccessLevel: to.Ptr("EarlyAccess"), + // ProvisioningState: to.Ptr(armtestbase.ProvisioningStateSucceeded), + // SKU: &armtestbase.AccountSKU{ + // Name: to.Ptr("S0"), + // Capabilities: []*armtestbase.AccountSKUCapability{ + // { + // Name: to.Ptr("SLA"), + // Value: to.Ptr("99.9%"), + // }, + // { + // Name: to.Ptr("maximumPackageCount"), + // Value: to.Ptr("5"), + // }, + // { + // Name: to.Ptr("packageMaximumRunSeconds"), + // Value: to.Ptr("3600"), + // }}, + // Tier: to.Ptr(armtestbase.TierStandard), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestBaseAccountDelete.json +func ExampleAccountsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAccountsClient().BeginDelete(ctx, "contoso-rg1", "contoso-testBaseAccount1", 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestBaseAccountGet.json +func ExampleAccountsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().Get(ctx, "contoso-rg1", "contoso-testBaseAccount1", 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.AccountResource = armtestbase.AccountResource{ + // Name: to.Ptr("contoso-testBaseAccount1"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // }, + // Properties: &armtestbase.AccountResourceProperties{ + // AccessLevel: to.Ptr("EarlyAccess"), + // ProvisioningState: to.Ptr(armtestbase.ProvisioningStateSucceeded), + // SKU: &armtestbase.AccountSKU{ + // Name: to.Ptr("S0"), + // Capabilities: []*armtestbase.AccountSKUCapability{ + // { + // Name: to.Ptr("SLA"), + // Value: to.Ptr("99.9%"), + // }, + // { + // Name: to.Ptr("maximumPackageCount"), + // Value: to.Ptr("5"), + // }, + // { + // Name: to.Ptr("packageMaximumRunSeconds"), + // Value: to.Ptr("3600"), + // }}, + // Tier: to.Ptr(armtestbase.TierStandard), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestBaseAccountOffboard.json +func ExampleAccountsClient_BeginOffboard() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAccountsClient().BeginOffboard(ctx, "contoso-rg1", "contoso-testBaseAccount1", 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestBaseAccountGetFileUploadUrl.json +func ExampleAccountsClient_GetFileUploadURL() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().GetFileUploadURL(ctx, "contoso-rg1", "contoso-testBaseAccount1", &armtestbase.AccountsClientGetFileUploadURLOptions{Parameters: &armtestbase.GetFileUploadURLParameters{ + BlobName: to.Ptr("package.zip"), + }, + }) + 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.FileUploadURLResponse = armtestbase.FileUploadURLResponse{ + // BlobPath: to.Ptr("https://uslwestusdevsa.blob.core.windows.net/usltest/temp/20c0d7e0-1bb6-477f-bc04-57c734453000/package.zip"), + // UploadURL: to.Ptr("https://uslwestusdevsa.blob.core.windows.net/usltest/temp/20c0d7e0-1bb6-477f-bc04-57c734453000/token"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/CheckPackageNameAvailability.json +func ExampleAccountsClient_CheckPackageNameAvailability() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().CheckPackageNameAvailability(ctx, "contoso-rg1", "contoso-testBaseAccount1", armtestbase.PackageCheckNameAvailabilityParameters{ + Name: to.Ptr("testApp"), + Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages"), + ApplicationName: to.Ptr("testApp"), + Version: to.Ptr("1.0.0"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.CheckNameAvailabilityResult = armtestbase.CheckNameAvailabilityResult{ + // } +} diff --git a/sdk/resourcemanager/testbase/armtestbase/zz_generated_analysisresults_client.go b/sdk/resourcemanager/testbase/armtestbase/analysisresults_client.go similarity index 80% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_analysisresults_client.go rename to sdk/resourcemanager/testbase/armtestbase/analysisresults_client.go index d9c847bd6333..595fab9ad943 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_analysisresults_client.go +++ b/sdk/resourcemanager/testbase/armtestbase/analysisresults_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 armtestbase @@ -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 ( // AnalysisResultsClient contains the methods for the AnalysisResults group. // Don't use this type directly, use NewAnalysisResultsClient() instead. type AnalysisResultsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAnalysisResultsClient creates a new instance of AnalysisResultsClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAnalysisResultsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AnalysisResultsClient, 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+".AnalysisResultsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AnalysisResultsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets an Analysis Result of a Test Result by name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// packageName - The resource name of the Test Base Package. -// testResultName - The Test Result Name. It equals to {osName}-{TestResultId} string. -// analysisResultName - The name of the Analysis Result of a Test Result. -// options - AnalysisResultsClientGetOptions contains the optional parameters for the AnalysisResultsClient.Get method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - packageName - The resource name of the Test Base Package. +// - testResultName - The Test Result Name. It equals to {osName}-{TestResultId} string. +// - analysisResultName - The name of the Analysis Result of a Test Result. +// - options - AnalysisResultsClientGetOptions contains the optional parameters for the AnalysisResultsClient.Get method. func (client *AnalysisResultsClient) Get(ctx context.Context, resourceGroupName string, testBaseAccountName string, packageName string, testResultName string, analysisResultName AnalysisResultName, options *AnalysisResultsClientGetOptions) (AnalysisResultsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, testBaseAccountName, packageName, testResultName, analysisResultName, options) if err != nil { return AnalysisResultsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AnalysisResultsClientGetResponse{}, err } @@ -105,7 +96,7 @@ func (client *AnalysisResultsClient) getCreateRequest(ctx context.Context, resou return nil, errors.New("parameter analysisResultName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{analysisResultName}", url.PathEscape(string(analysisResultName))) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -127,14 +118,15 @@ func (client *AnalysisResultsClient) getHandleResponse(resp *http.Response) (Ana // NewListPager - Lists the Analysis Results of a Test Result. The result collection will only contain one element as all // the data will be nested in a singleton object. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// packageName - The resource name of the Test Base Package. -// testResultName - The Test Result Name. It equals to {osName}-{TestResultId} string. -// analysisResultType - The type of the Analysis Result of a Test Result. -// options - AnalysisResultsClientListOptions contains the optional parameters for the AnalysisResultsClient.List method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - packageName - The resource name of the Test Base Package. +// - testResultName - The Test Result Name. It equals to {osName}-{TestResultId} string. +// - analysisResultType - The type of the Analysis Result of a Test Result. +// - options - AnalysisResultsClientListOptions contains the optional parameters for the AnalysisResultsClient.NewListPager +// method. func (client *AnalysisResultsClient) NewListPager(resourceGroupName string, testBaseAccountName string, packageName string, testResultName string, analysisResultType AnalysisResultType, options *AnalysisResultsClientListOptions) *runtime.Pager[AnalysisResultsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AnalysisResultsClientListResponse]{ More: func(page AnalysisResultsClientListResponse) bool { @@ -145,7 +137,7 @@ func (client *AnalysisResultsClient) NewListPager(resourceGroupName string, test if err != nil { return AnalysisResultsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AnalysisResultsClientListResponse{}, err } @@ -180,7 +172,7 @@ func (client *AnalysisResultsClient) listCreateRequest(ctx context.Context, reso return nil, errors.New("parameter testResultName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testResultName}", url.PathEscape(testResultName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/testbase/armtestbase/analysisresults_client_example_test.go b/sdk/resourcemanager/testbase/armtestbase/analysisresults_client_example_test.go new file mode 100644 index 000000000000..137803954e56 --- /dev/null +++ b/sdk/resourcemanager/testbase/armtestbase/analysisresults_client_example_test.go @@ -0,0 +1,602 @@ +//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 armtestbase_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/CPURegressionAnalysisResultsList.json +func ExampleAnalysisResultsClient_NewListPager_cpuRegressionAnalysisResultsList() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAnalysisResultsClient().NewListPager("contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", "Windows-10-1909-Test-Id", armtestbase.AnalysisResultTypeCPURegression, 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.AnalysisResultListResult = armtestbase.AnalysisResultListResult{ + // Value: []*armtestbase.AnalysisResultSingletonResource{ + // { + // Name: to.Ptr("cpuRegression"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages/testResults/analysisResults"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/testResults/Windows-10-1909-Test-Id/analysisResults/cpuRegression"), + // Properties: &armtestbase.CPURegressionResultSingletonResourceProperties{ + // AnalysisResultType: to.Ptr(armtestbase.AnalysisResultTypeCPURegression), + // Grade: to.Ptr(armtestbase.GradePass), + // CPURegressionResults: []*armtestbase.RegressionResult{ + // { + // Diff: to.Ptr[float64](0.1), + // FileName: to.Ptr("testApp.exe"), + // Grade: to.Ptr(armtestbase.GradePass), + // IsRegressed: to.Ptr(false), + // Details: to.Ptr("Some details of testApp"), + // }, + // { + // Diff: to.Ptr[float64](0.15), + // FileName: to.Ptr("dependencies.exe"), + // Grade: to.Ptr(armtestbase.GradePass), + // IsRegressed: to.Ptr(false), + // Details: to.Ptr("Some details of dependencies"), + // }}, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/CPUUtilizationAnalysisResultsList.json +func ExampleAnalysisResultsClient_NewListPager_cpuUtilizationAnalysisResultsList() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAnalysisResultsClient().NewListPager("contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", "Windows-10-1909-Test-Id", armtestbase.AnalysisResultTypeCPUUtilization, 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.AnalysisResultListResult = armtestbase.AnalysisResultListResult{ + // Value: []*armtestbase.AnalysisResultSingletonResource{ + // { + // Name: to.Ptr("cpuUtilization"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages/testResults/analysisResults"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/testResults/Windows-10-1909-Test-Id/analysisResults/cpuUtilization"), + // Properties: &armtestbase.CPUUtilizationResultSingletonResourceProperties{ + // AnalysisResultType: to.Ptr(armtestbase.AnalysisResultTypeCPUUtilization), + // Grade: to.Ptr(armtestbase.GradePass), + // CPUUtilizationResults: []*armtestbase.UtilizationResult{ + // { + // LowerBound: &armtestbase.UtilizationBound{ + // Percentile: to.Ptr[float64](50), + // Value: to.Ptr[float64](20), + // }, + // Process: to.Ptr("app.exe"), + // UpperBound: &armtestbase.UtilizationBound{ + // Percentile: to.Ptr[float64](90), + // Value: to.Ptr[float64](60), + // }, + // Utilization: []*armtestbase.UtilizationEntry{ + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:30:00Z"); return t}()), + // Value: to.Ptr[float64](34.7), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:31:00Z"); return t}()), + // Value: to.Ptr[float64](35.9), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:32:00Z"); return t}()), + // Value: to.Ptr[float64](27.1), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:33:00Z"); return t}()), + // Value: to.Ptr[float64](49.8), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:34:00Z"); return t}()), + // Value: to.Ptr[float64](45.6), + // }}, + // }, + // { + // LowerBound: &armtestbase.UtilizationBound{ + // Percentile: to.Ptr[float64](50), + // Value: to.Ptr[float64](20), + // }, + // Process: to.Ptr("anotherProcess.exe"), + // UpperBound: &armtestbase.UtilizationBound{ + // Percentile: to.Ptr[float64](90), + // Value: to.Ptr[float64](60), + // }, + // Utilization: []*armtestbase.UtilizationEntry{ + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:30:00Z"); return t}()), + // Value: to.Ptr[float64](34.7), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:31:00Z"); return t}()), + // Value: to.Ptr[float64](35.9), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:32:00Z"); return t}()), + // Value: to.Ptr[float64](27.1), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:33:00Z"); return t}()), + // Value: to.Ptr[float64](49.8), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:34:00Z"); return t}()), + // Value: to.Ptr[float64](45.6), + // }}, + // }}, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/MemoryRegressionAnalysisResultsList.json +func ExampleAnalysisResultsClient_NewListPager_memoryRegressionAnalysisResultsList() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAnalysisResultsClient().NewListPager("contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", "Windows-10-1909-Test-Id", armtestbase.AnalysisResultTypeMemoryRegression, 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.AnalysisResultListResult = armtestbase.AnalysisResultListResult{ + // Value: []*armtestbase.AnalysisResultSingletonResource{ + // { + // Name: to.Ptr("memoryRegression"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages/testResults/analysisResults"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/testResults/Windows-10-1909-Test-Id/analysisResults/memoryRegression"), + // Properties: &armtestbase.MemoryRegressionResultSingletonResourceProperties{ + // AnalysisResultType: to.Ptr(armtestbase.AnalysisResultTypeMemoryRegression), + // Grade: to.Ptr(armtestbase.GradePass), + // MemoryRegressionResults: []*armtestbase.RegressionResult{ + // { + // Diff: to.Ptr[float64](0.1), + // FileName: to.Ptr("testApp.exe"), + // Grade: to.Ptr(armtestbase.GradePass), + // IsRegressed: to.Ptr(false), + // Details: to.Ptr("Some details of testApp"), + // }, + // { + // Diff: to.Ptr[float64](0.15), + // FileName: to.Ptr("dependencies.exe"), + // Grade: to.Ptr(armtestbase.GradePass), + // IsRegressed: to.Ptr(false), + // Details: to.Ptr("Some details of dependencies"), + // }}, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/MemoryUtilizationAnalysisResultsList.json +func ExampleAnalysisResultsClient_NewListPager_memoryUtilizationAnalysisResultsList() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAnalysisResultsClient().NewListPager("contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", "Windows-10-1909-Test-Id", armtestbase.AnalysisResultTypeMemoryUtilization, 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.AnalysisResultListResult = armtestbase.AnalysisResultListResult{ + // Value: []*armtestbase.AnalysisResultSingletonResource{ + // { + // Name: to.Ptr("cpuUtilization"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages/testResults/analysisResults"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/testResults/Windows-10-1909-Test-Id/analysisResults/memoryUtilization"), + // Properties: &armtestbase.MemoryUtilizationResultSingletonResourceProperties{ + // AnalysisResultType: to.Ptr(armtestbase.AnalysisResultTypeMemoryUtilization), + // Grade: to.Ptr(armtestbase.GradePass), + // MemoryUtilizationResults: []*armtestbase.UtilizationResult{ + // { + // LowerBound: &armtestbase.UtilizationBound{ + // Percentile: to.Ptr[float64](50), + // Value: to.Ptr[float64](20), + // }, + // Process: to.Ptr("app.exe"), + // UpperBound: &armtestbase.UtilizationBound{ + // Percentile: to.Ptr[float64](90), + // Value: to.Ptr[float64](60), + // }, + // Utilization: []*armtestbase.UtilizationEntry{ + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:30:00Z"); return t}()), + // Value: to.Ptr[float64](34.7), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:31:00Z"); return t}()), + // Value: to.Ptr[float64](35.9), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:32:00Z"); return t}()), + // Value: to.Ptr[float64](27.1), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:33:00Z"); return t}()), + // Value: to.Ptr[float64](49.8), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:34:00Z"); return t}()), + // Value: to.Ptr[float64](45.6), + // }}, + // }, + // { + // LowerBound: &armtestbase.UtilizationBound{ + // Percentile: to.Ptr[float64](50), + // Value: to.Ptr[float64](20), + // }, + // Process: to.Ptr("anotherProcess.exe"), + // UpperBound: &armtestbase.UtilizationBound{ + // Percentile: to.Ptr[float64](90), + // Value: to.Ptr[float64](60), + // }, + // Utilization: []*armtestbase.UtilizationEntry{ + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:30:00Z"); return t}()), + // Value: to.Ptr[float64](34.7), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:31:00Z"); return t}()), + // Value: to.Ptr[float64](35.9), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:32:00Z"); return t}()), + // Value: to.Ptr[float64](27.1), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:33:00Z"); return t}()), + // Value: to.Ptr[float64](49.8), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:34:00Z"); return t}()), + // Value: to.Ptr[float64](45.6), + // }}, + // }}, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/CPURegressionAnalysisResultGet.json +func ExampleAnalysisResultsClient_Get_cpuRegressionAnalysisResultGet() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAnalysisResultsClient().Get(ctx, "contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", "Windows-10-1909-Test-Id", armtestbase.AnalysisResultNameCPURegression, 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.AnalysisResultSingletonResource = armtestbase.AnalysisResultSingletonResource{ + // Name: to.Ptr("cpuRegression"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages/testResults/analysisResults"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/testResults/Windows-10-1909-Test-Id/analysisResults/cpuRegression"), + // Properties: &armtestbase.CPURegressionResultSingletonResourceProperties{ + // AnalysisResultType: to.Ptr(armtestbase.AnalysisResultTypeCPURegression), + // Grade: to.Ptr(armtestbase.GradePass), + // CPURegressionResults: []*armtestbase.RegressionResult{ + // { + // Diff: to.Ptr[float64](0.1), + // FileName: to.Ptr("testApp.exe"), + // Grade: to.Ptr(armtestbase.GradePass), + // IsRegressed: to.Ptr(false), + // Details: to.Ptr("Some details of testApp"), + // }, + // { + // Diff: to.Ptr[float64](0.15), + // FileName: to.Ptr("dependencies.exe"), + // Grade: to.Ptr(armtestbase.GradePass), + // IsRegressed: to.Ptr(false), + // Details: to.Ptr("Some details of dependencies"), + // }}, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/CPUUtilizationAnalysisResultGet.json +func ExampleAnalysisResultsClient_Get_cpuUtilizationAnalysisResultGet() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAnalysisResultsClient().Get(ctx, "contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", "Windows-10-1909-Test-Id", armtestbase.AnalysisResultNameCPUUtilization, 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.AnalysisResultSingletonResource = armtestbase.AnalysisResultSingletonResource{ + // Name: to.Ptr("cpuUtilization"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages/testResults/analysisResults"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/testResults/Windows-10-1909-Test-Id/analysisResults/cpuUtilization"), + // Properties: &armtestbase.CPUUtilizationResultSingletonResourceProperties{ + // AnalysisResultType: to.Ptr(armtestbase.AnalysisResultTypeCPUUtilization), + // Grade: to.Ptr(armtestbase.GradePass), + // CPUUtilizationResults: []*armtestbase.UtilizationResult{ + // { + // LowerBound: &armtestbase.UtilizationBound{ + // Percentile: to.Ptr[float64](50), + // Value: to.Ptr[float64](20), + // }, + // Process: to.Ptr("app.exe"), + // UpperBound: &armtestbase.UtilizationBound{ + // Percentile: to.Ptr[float64](90), + // Value: to.Ptr[float64](60), + // }, + // Utilization: []*armtestbase.UtilizationEntry{ + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:30:00Z"); return t}()), + // Value: to.Ptr[float64](34.7), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:31:00Z"); return t}()), + // Value: to.Ptr[float64](35.9), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:32:00Z"); return t}()), + // Value: to.Ptr[float64](27.1), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:33:00Z"); return t}()), + // Value: to.Ptr[float64](49.8), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:34:00Z"); return t}()), + // Value: to.Ptr[float64](45.6), + // }}, + // }, + // { + // LowerBound: &armtestbase.UtilizationBound{ + // Percentile: to.Ptr[float64](50), + // Value: to.Ptr[float64](20), + // }, + // Process: to.Ptr("anotherProcess.exe"), + // UpperBound: &armtestbase.UtilizationBound{ + // Percentile: to.Ptr[float64](90), + // Value: to.Ptr[float64](60), + // }, + // Utilization: []*armtestbase.UtilizationEntry{ + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:30:00Z"); return t}()), + // Value: to.Ptr[float64](34.7), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:31:00Z"); return t}()), + // Value: to.Ptr[float64](35.9), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:32:00Z"); return t}()), + // Value: to.Ptr[float64](27.1), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:33:00Z"); return t}()), + // Value: to.Ptr[float64](49.8), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:34:00Z"); return t}()), + // Value: to.Ptr[float64](45.6), + // }}, + // }}, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/MemoryRegressionAnalysisResultGet.json +func ExampleAnalysisResultsClient_Get_memoryRegressionAnalysisResultGet() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAnalysisResultsClient().Get(ctx, "contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", "Windows-10-1909-Test-Id", armtestbase.AnalysisResultNameMemoryRegression, 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.AnalysisResultSingletonResource = armtestbase.AnalysisResultSingletonResource{ + // Name: to.Ptr("memoryRegression"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages/testResults/analysisResults"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/testResults/Windows-10-1909-Test-Id/analysisResults/memoryRegression"), + // Properties: &armtestbase.MemoryRegressionResultSingletonResourceProperties{ + // AnalysisResultType: to.Ptr(armtestbase.AnalysisResultTypeMemoryRegression), + // Grade: to.Ptr(armtestbase.GradePass), + // MemoryRegressionResults: []*armtestbase.RegressionResult{ + // { + // Diff: to.Ptr[float64](0.1), + // FileName: to.Ptr("testApp.exe"), + // Grade: to.Ptr(armtestbase.GradePass), + // IsRegressed: to.Ptr(false), + // Details: to.Ptr("Some details of testApp"), + // }, + // { + // Diff: to.Ptr[float64](0.15), + // FileName: to.Ptr("dependencies.exe"), + // Grade: to.Ptr(armtestbase.GradePass), + // IsRegressed: to.Ptr(false), + // Details: to.Ptr("Some details of dependencies"), + // }}, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/MemoryUtilizationAnalysisResultGet.json +func ExampleAnalysisResultsClient_Get_memoryUtilizationAnalysisResultGet() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAnalysisResultsClient().Get(ctx, "contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", "Windows-10-1909-Test-Id", armtestbase.AnalysisResultNameMemoryUtilization, 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.AnalysisResultSingletonResource = armtestbase.AnalysisResultSingletonResource{ + // Name: to.Ptr("memoryUtilization"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages/testResults/analysisResults"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/testResults/Windows-10-1909-Test-Id/analysisResults/memoryUtilization"), + // Properties: &armtestbase.MemoryUtilizationResultSingletonResourceProperties{ + // AnalysisResultType: to.Ptr(armtestbase.AnalysisResultTypeMemoryUtilization), + // Grade: to.Ptr(armtestbase.GradePass), + // MemoryUtilizationResults: []*armtestbase.UtilizationResult{ + // { + // LowerBound: &armtestbase.UtilizationBound{ + // Percentile: to.Ptr[float64](50), + // Value: to.Ptr[float64](20), + // }, + // Process: to.Ptr("app.exe"), + // UpperBound: &armtestbase.UtilizationBound{ + // Percentile: to.Ptr[float64](90), + // Value: to.Ptr[float64](60), + // }, + // Utilization: []*armtestbase.UtilizationEntry{ + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:30:00Z"); return t}()), + // Value: to.Ptr[float64](34.7), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:31:00Z"); return t}()), + // Value: to.Ptr[float64](35.9), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:32:00Z"); return t}()), + // Value: to.Ptr[float64](27.1), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:33:00Z"); return t}()), + // Value: to.Ptr[float64](49.8), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:34:00Z"); return t}()), + // Value: to.Ptr[float64](45.6), + // }}, + // }, + // { + // LowerBound: &armtestbase.UtilizationBound{ + // Percentile: to.Ptr[float64](50), + // Value: to.Ptr[float64](20), + // }, + // Process: to.Ptr("anotherProcess.exe"), + // UpperBound: &armtestbase.UtilizationBound{ + // Percentile: to.Ptr[float64](90), + // Value: to.Ptr[float64](60), + // }, + // Utilization: []*armtestbase.UtilizationEntry{ + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:30:00Z"); return t}()), + // Value: to.Ptr[float64](34.7), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:31:00Z"); return t}()), + // Value: to.Ptr[float64](35.9), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:32:00Z"); return t}()), + // Value: to.Ptr[float64](27.1), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:33:00Z"); return t}()), + // Value: to.Ptr[float64](49.8), + // }, + // { + // Timestamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:34:00Z"); return t}()), + // Value: to.Ptr[float64](45.6), + // }}, + // }}, + // }, + // } +} diff --git a/sdk/resourcemanager/testbase/armtestbase/autorest.md b/sdk/resourcemanager/testbase/armtestbase/autorest.md index 8bcc4d588079..15991afb5f80 100644 --- a/sdk/resourcemanager/testbase/armtestbase/autorest.md +++ b/sdk/resourcemanager/testbase/armtestbase/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/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/testbase/armtestbase/zz_generated_availableos_client.go b/sdk/resourcemanager/testbase/armtestbase/availableos_client.go similarity index 81% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_availableos_client.go rename to sdk/resourcemanager/testbase/armtestbase/availableos_client.go index e2173f5f45de..d6bb3528d4ae 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_availableos_client.go +++ b/sdk/resourcemanager/testbase/armtestbase/availableos_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 armtestbase @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // AvailableOSClient contains the methods for the AvailableOS group. // Don't use this type directly, use NewAvailableOSClient() instead. type AvailableOSClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAvailableOSClient creates a new instance of AvailableOSClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAvailableOSClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AvailableOSClient, 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+".AvailableOSClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AvailableOSClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets an available OS to run a package under a Test Base Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// availableOSResourceName - The resource name of an Available OS. -// options - AvailableOSClientGetOptions contains the optional parameters for the AvailableOSClient.Get method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - availableOSResourceName - The resource name of an Available OS. +// - options - AvailableOSClientGetOptions contains the optional parameters for the AvailableOSClient.Get method. func (client *AvailableOSClient) Get(ctx context.Context, resourceGroupName string, testBaseAccountName string, availableOSResourceName string, options *AvailableOSClientGetOptions) (AvailableOSClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, testBaseAccountName, availableOSResourceName, options) if err != nil { return AvailableOSClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AvailableOSClientGetResponse{}, err } @@ -95,7 +86,7 @@ func (client *AvailableOSClient) getCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter availableOSResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{availableOSResourceName}", url.PathEscape(availableOSResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -116,12 +107,12 @@ func (client *AvailableOSClient) getHandleResponse(resp *http.Response) (Availab } // NewListPager - Lists all the available OSs to run a package under a Test Base Account. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// osUpdateType - The type of the OS Update. -// options - AvailableOSClientListOptions contains the optional parameters for the AvailableOSClient.List method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - osUpdateType - The type of the OS Update. +// - options - AvailableOSClientListOptions contains the optional parameters for the AvailableOSClient.NewListPager method. func (client *AvailableOSClient) NewListPager(resourceGroupName string, testBaseAccountName string, osUpdateType OsUpdateType, options *AvailableOSClientListOptions) *runtime.Pager[AvailableOSClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AvailableOSClientListResponse]{ More: func(page AvailableOSClientListResponse) bool { @@ -138,7 +129,7 @@ func (client *AvailableOSClient) NewListPager(resourceGroupName string, testBase if err != nil { return AvailableOSClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AvailableOSClientListResponse{}, err } @@ -165,7 +156,7 @@ func (client *AvailableOSClient) listCreateRequest(ctx context.Context, resource return nil, errors.New("parameter testBaseAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testBaseAccountName}", url.PathEscape(testBaseAccountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/testbase/armtestbase/availableos_client_example_test.go b/sdk/resourcemanager/testbase/armtestbase/availableos_client_example_test.go new file mode 100644 index 000000000000..9baf94000c3e --- /dev/null +++ b/sdk/resourcemanager/testbase/armtestbase/availableos_client_example_test.go @@ -0,0 +1,141 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armtestbase_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/AvailableOSsList.json +func ExampleAvailableOSClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAvailableOSClient().NewListPager("contoso-rg", "contoso-testBaseAccount", armtestbase.OsUpdateTypeSecurityUpdate, 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.AvailableOSListResult = armtestbase.AvailableOSListResult{ + // Value: []*armtestbase.AvailableOSResource{ + // { + // Name: to.Ptr("Windows-10-2004"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/availableOSs"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount/availableOSs/Windows-10-2004"), + // Properties: &armtestbase.AvailableOSProperties{ + // InsiderChannel: to.Ptr("Channel 1"), + // OSID: to.Ptr("Windows 10 2004"), + // OSName: to.Ptr("Windows 10 2004"), + // OSPlatform: to.Ptr("Client"), + // OSUpdateType: to.Ptr("Feature update"), + // OSVersion: to.Ptr("Windows 10"), + // }, + // }, + // { + // Name: to.Ptr("Windows-10-1909"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/availableOSs"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount/availableOSs/Windows-10-1909"), + // Properties: &armtestbase.AvailableOSProperties{ + // OSID: to.Ptr("Windows 10 1909"), + // OSName: to.Ptr("Windows 10 1909"), + // OSPlatform: to.Ptr("Client"), + // OSUpdateType: to.Ptr("Security update"), + // OSVersion: to.Ptr("Windows 10"), + // }, + // }, + // { + // Name: to.Ptr("Windows-10-1903"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/availableOSs"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount/availableOSs/Windows-10-1903"), + // Properties: &armtestbase.AvailableOSProperties{ + // OSID: to.Ptr("Windows 10 1903"), + // OSName: to.Ptr("Windows 10 1903"), + // OSPlatform: to.Ptr("Client"), + // OSUpdateType: to.Ptr("Security update"), + // OSVersion: to.Ptr("Windows 10"), + // }, + // }, + // { + // Name: to.Ptr("Windows-10-1809"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/availableOSs"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount/availableOSs/Windows-10-1809"), + // Properties: &armtestbase.AvailableOSProperties{ + // InsiderChannel: to.Ptr("Channel 3"), + // OSID: to.Ptr("Windows 10 1809"), + // OSName: to.Ptr("Windows 10 1809"), + // OSPlatform: to.Ptr("Client"), + // OSUpdateType: to.Ptr("Feature update"), + // OSVersion: to.Ptr("Windows 10"), + // }, + // }, + // { + // Name: to.Ptr("Windows-Server-2016"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/availableOSs"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount/availableOSs/Windows-Server-2016"), + // Properties: &armtestbase.AvailableOSProperties{ + // OSID: to.Ptr("Windows Server 2016"), + // OSName: to.Ptr("Windows Server 2016"), + // OSPlatform: to.Ptr("Server"), + // OSUpdateType: to.Ptr("Security update"), + // OSVersion: to.Ptr("Windows Server 2016"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/AvailableOSGet.json +func ExampleAvailableOSClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAvailableOSClient().Get(ctx, "contoso-rg", "contoso-testBaseAccount", "Windows-10-2004", 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.AvailableOSResource = armtestbase.AvailableOSResource{ + // Name: to.Ptr("Windows-10-2004"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/availableOSs"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount/availableOSs/Windows-10-2004"), + // Properties: &armtestbase.AvailableOSProperties{ + // InsiderChannel: to.Ptr("Channel 1"), + // OSID: to.Ptr("Windows 10 2004"), + // OSName: to.Ptr("Windows 10 2004"), + // OSPlatform: to.Ptr("Client"), + // OSUpdateType: to.Ptr("Feature update"), + // OSVersion: to.Ptr("Windows 10"), + // }, + // } +} diff --git a/sdk/resourcemanager/testbase/armtestbase/client_factory.go b/sdk/resourcemanager/testbase/armtestbase/client_factory.go new file mode 100644 index 000000000000..7144d51758c7 --- /dev/null +++ b/sdk/resourcemanager/testbase/armtestbase/client_factory.go @@ -0,0 +1,114 @@ +//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 armtestbase + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string. +// - 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) NewSKUsClient() *SKUsClient { + subClient, _ := NewSKUsClient(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) NewUsageClient() *UsageClient { + subClient, _ := NewUsageClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAvailableOSClient() *AvailableOSClient { + subClient, _ := NewAvailableOSClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewFlightingRingsClient() *FlightingRingsClient { + subClient, _ := NewFlightingRingsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewTestTypesClient() *TestTypesClient { + subClient, _ := NewTestTypesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPackagesClient() *PackagesClient { + subClient, _ := NewPackagesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewTestSummariesClient() *TestSummariesClient { + subClient, _ := NewTestSummariesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewTestResultsClient() *TestResultsClient { + subClient, _ := NewTestResultsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOSUpdatesClient() *OSUpdatesClient { + subClient, _ := NewOSUpdatesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewFavoriteProcessesClient() *FavoriteProcessesClient { + subClient, _ := NewFavoriteProcessesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAnalysisResultsClient() *AnalysisResultsClient { + subClient, _ := NewAnalysisResultsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewEmailEventsClient() *EmailEventsClient { + subClient, _ := NewEmailEventsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCustomerEventsClient() *CustomerEventsClient { + subClient, _ := NewCustomerEventsClient(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/testbase/armtestbase/zz_generated_constants.go b/sdk/resourcemanager/testbase/armtestbase/constants.go similarity index 99% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_constants.go rename to sdk/resourcemanager/testbase/armtestbase/constants.go index 90d941846c9a..be522e8a2e3b 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_constants.go +++ b/sdk/resourcemanager/testbase/armtestbase/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 armtestbase const ( moduleName = "armtestbase" - moduleVersion = "v0.5.0" + moduleVersion = "v0.6.0" ) // Action - The action of the command. diff --git a/sdk/resourcemanager/testbase/armtestbase/zz_generated_customerevents_client.go b/sdk/resourcemanager/testbase/armtestbase/customerevents_client.go similarity index 82% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_customerevents_client.go rename to sdk/resourcemanager/testbase/armtestbase/customerevents_client.go index 939250156780..5fa5396e3f1a 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_customerevents_client.go +++ b/sdk/resourcemanager/testbase/armtestbase/customerevents_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 armtestbase @@ -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,67 +24,60 @@ import ( // CustomerEventsClient contains the methods for the CustomerEvents group. // Don't use this type directly, use NewCustomerEventsClient() instead. type CustomerEventsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCustomerEventsClient creates a new instance of CustomerEventsClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewCustomerEventsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CustomerEventsClient, 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+".CustomerEventsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CustomerEventsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create or replace a Test Base Customer Event. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// customerEventName - The resource name of the Test Base Customer event. -// parameters - Parameters supplied to create a Test Base CustomerEvent. -// options - CustomerEventsClientBeginCreateOptions contains the optional parameters for the CustomerEventsClient.BeginCreate -// method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - customerEventName - The resource name of the Test Base Customer event. +// - parameters - Parameters supplied to create a Test Base CustomerEvent. +// - options - CustomerEventsClientBeginCreateOptions contains the optional parameters for the CustomerEventsClient.BeginCreate +// method. func (client *CustomerEventsClient) BeginCreate(ctx context.Context, resourceGroupName string, testBaseAccountName string, customerEventName string, parameters CustomerEventResource, options *CustomerEventsClientBeginCreateOptions) (*runtime.Poller[CustomerEventsClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, testBaseAccountName, customerEventName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CustomerEventsClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CustomerEventsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CustomerEventsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CustomerEventsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create or replace a Test Base Customer Event. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview func (client *CustomerEventsClient) create(ctx context.Context, resourceGroupName string, testBaseAccountName string, customerEventName string, parameters CustomerEventResource, options *CustomerEventsClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, testBaseAccountName, customerEventName, 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 +106,7 @@ func (client *CustomerEventsClient) createCreateRequest(ctx context.Context, res return nil, errors.New("parameter customerEventName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{customerEventName}", url.PathEscape(customerEventName)) - 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,35 +119,37 @@ func (client *CustomerEventsClient) createCreateRequest(ctx context.Context, res // BeginDelete - Deletes a Test Base Customer Event. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// customerEventName - The resource name of the Test Base Customer event. -// options - CustomerEventsClientBeginDeleteOptions contains the optional parameters for the CustomerEventsClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - customerEventName - The resource name of the Test Base Customer event. +// - options - CustomerEventsClientBeginDeleteOptions contains the optional parameters for the CustomerEventsClient.BeginDelete +// method. func (client *CustomerEventsClient) BeginDelete(ctx context.Context, resourceGroupName string, testBaseAccountName string, customerEventName string, options *CustomerEventsClientBeginDeleteOptions) (*runtime.Poller[CustomerEventsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, testBaseAccountName, customerEventName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CustomerEventsClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CustomerEventsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CustomerEventsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CustomerEventsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a Test Base Customer Event. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview func (client *CustomerEventsClient) deleteOperation(ctx context.Context, resourceGroupName string, testBaseAccountName string, customerEventName string, options *CustomerEventsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, testBaseAccountName, customerEventName, 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 +178,7 @@ func (client *CustomerEventsClient) deleteCreateRequest(ctx context.Context, res return nil, errors.New("parameter customerEventName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{customerEventName}", url.PathEscape(customerEventName)) - 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 +191,18 @@ func (client *CustomerEventsClient) deleteCreateRequest(ctx context.Context, res // Get - Gets a Test Base CustomerEvent. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// customerEventName - The resource name of the Test Base Customer event. -// options - CustomerEventsClientGetOptions contains the optional parameters for the CustomerEventsClient.Get method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - customerEventName - The resource name of the Test Base Customer event. +// - options - CustomerEventsClientGetOptions contains the optional parameters for the CustomerEventsClient.Get method. func (client *CustomerEventsClient) Get(ctx context.Context, resourceGroupName string, testBaseAccountName string, customerEventName string, options *CustomerEventsClientGetOptions) (CustomerEventsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, testBaseAccountName, customerEventName, options) if err != nil { return CustomerEventsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomerEventsClientGetResponse{}, err } @@ -236,7 +231,7 @@ func (client *CustomerEventsClient) getCreateRequest(ctx context.Context, resour return nil, errors.New("parameter customerEventName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{customerEventName}", url.PathEscape(customerEventName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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,12 +252,12 @@ func (client *CustomerEventsClient) getHandleResponse(resp *http.Response) (Cust } // NewListByTestBaseAccountPager - Lists all notification events subscribed under a Test Base Account. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// options - CustomerEventsClientListByTestBaseAccountOptions contains the optional parameters for the CustomerEventsClient.ListByTestBaseAccount -// method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - options - CustomerEventsClientListByTestBaseAccountOptions contains the optional parameters for the CustomerEventsClient.NewListByTestBaseAccountPager +// method. func (client *CustomerEventsClient) NewListByTestBaseAccountPager(resourceGroupName string, testBaseAccountName string, options *CustomerEventsClientListByTestBaseAccountOptions) *runtime.Pager[CustomerEventsClientListByTestBaseAccountResponse] { return runtime.NewPager(runtime.PagingHandler[CustomerEventsClientListByTestBaseAccountResponse]{ More: func(page CustomerEventsClientListByTestBaseAccountResponse) bool { @@ -279,7 +274,7 @@ func (client *CustomerEventsClient) NewListByTestBaseAccountPager(resourceGroupN if err != nil { return CustomerEventsClientListByTestBaseAccountResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomerEventsClientListByTestBaseAccountResponse{}, err } @@ -306,7 +301,7 @@ func (client *CustomerEventsClient) listByTestBaseAccountCreateRequest(ctx conte return nil, errors.New("parameter testBaseAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testBaseAccountName}", url.PathEscape(testBaseAccountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/testbase/armtestbase/customerevents_client_example_test.go b/sdk/resourcemanager/testbase/armtestbase/customerevents_client_example_test.go new file mode 100644 index 000000000000..33f07b6e5057 --- /dev/null +++ b/sdk/resourcemanager/testbase/armtestbase/customerevents_client_example_test.go @@ -0,0 +1,249 @@ +//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 armtestbase_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/testbase/armtestbase" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/CustomerEventsList.json +func ExampleCustomerEventsClient_NewListByTestBaseAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewCustomerEventsClient().NewListByTestBaseAccountPager("contoso-rg1", "contoso-testBaseAccount1", 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.CustomerEventListResult = armtestbase.CustomerEventListResult{ + // Value: []*armtestbase.CustomerEventResource{ + // { + // Name: to.Ptr("ExecutionFailure"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/customerEvents"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/customerEvents/ExecutionFailure"), + // Properties: &armtestbase.CustomerEventProperties{ + // EventName: to.Ptr("ExecutionFailure"), + // Receivers: []*armtestbase.NotificationEventReceiver{ + // { + // ReceiverType: to.Ptr("SubscriptionRole"), + // ReceiverValue: &armtestbase.NotificationReceiverValue{ + // SubscriptionReceiverValue: &armtestbase.SubscriptionReceiverValue{ + // Role: to.Ptr("Contributor"), + // SubscriptionID: to.Ptr("test-subscription-id"), + // SubscriptionName: to.Ptr("test-subscription"), + // }, + // }, + // }, + // { + // ReceiverType: to.Ptr("DistributionGroup"), + // ReceiverValue: &armtestbase.NotificationReceiverValue{ + // DistributionGroupListReceiverValue: &armtestbase.DistributionGroupListReceiverValue{ + // DistributionGroups: []*string{ + // to.Ptr("test@microsoft.com")}, + // }, + // }, + // }}, + // }, + // }, + // { + // Name: to.Ptr("WeeklySummary"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/customerEvents"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/customerEvents/WeeklySummary"), + // Properties: &armtestbase.CustomerEventProperties{ + // EventName: to.Ptr("WeeklySummary"), + // Receivers: []*armtestbase.NotificationEventReceiver{ + // { + // ReceiverType: to.Ptr("UserObjects"), + // ReceiverValue: &armtestbase.NotificationReceiverValue{ + // UserObjectReceiverValue: &armtestbase.UserObjectReceiverValue{ + // UserObjectIDs: []*string{ + // to.Ptr("245245245245325"), + // to.Ptr("365365365363565")}, + // }, + // }, + // }}, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/CustomerEventCreate.json +func ExampleCustomerEventsClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewCustomerEventsClient().BeginCreate(ctx, "contoso-rg1", "contoso-testBaseAccount1", "WeeklySummary", armtestbase.CustomerEventResource{ + Properties: &armtestbase.CustomerEventProperties{ + EventName: to.Ptr("WeeklySummary"), + Receivers: []*armtestbase.NotificationEventReceiver{ + { + ReceiverType: to.Ptr("UserObjects"), + ReceiverValue: &armtestbase.NotificationReceiverValue{ + UserObjectReceiverValue: &armtestbase.UserObjectReceiverValue{ + UserObjectIDs: []*string{ + to.Ptr("245245245245325"), + to.Ptr("365365365363565")}, + }, + }, + }, + { + ReceiverType: to.Ptr("DistributionGroup"), + ReceiverValue: &armtestbase.NotificationReceiverValue{ + DistributionGroupListReceiverValue: &armtestbase.DistributionGroupListReceiverValue{ + DistributionGroups: []*string{ + to.Ptr("test@microsoft.com")}, + }, + }, + }}, + }, + }, 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.CustomerEventResource = armtestbase.CustomerEventResource{ + // Name: to.Ptr("WeeklySummary"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/customerEvents"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/customerEvents/WeeklySummary"), + // Properties: &armtestbase.CustomerEventProperties{ + // EventName: to.Ptr("WeeklySummary"), + // Receivers: []*armtestbase.NotificationEventReceiver{ + // { + // ReceiverType: to.Ptr("UserObjects"), + // ReceiverValue: &armtestbase.NotificationReceiverValue{ + // UserObjectReceiverValue: &armtestbase.UserObjectReceiverValue{ + // UserObjectIDs: []*string{ + // to.Ptr("245245245245325"), + // to.Ptr("365365365363565")}, + // }, + // }, + // }, + // { + // ReceiverType: to.Ptr("DistributionGroup"), + // ReceiverValue: &armtestbase.NotificationReceiverValue{ + // DistributionGroupListReceiverValue: &armtestbase.DistributionGroupListReceiverValue{ + // DistributionGroups: []*string{ + // to.Ptr("test@microsoft.com")}, + // }, + // }, + // }}, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/CustomerEventDelete.json +func ExampleCustomerEventsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewCustomerEventsClient().BeginDelete(ctx, "contoso-rg1", "contoso-testBaseAccount1", "WeeklySummary", 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/CustomerEventGet.json +func ExampleCustomerEventsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewCustomerEventsClient().Get(ctx, "contoso-rg1", "contoso-testBaseAccount1", "WeeklySummary", 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.CustomerEventResource = armtestbase.CustomerEventResource{ + // Name: to.Ptr("WeeklySummary"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/customerEvents"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/customerEvents/WeeklySummary"), + // Properties: &armtestbase.CustomerEventProperties{ + // EventName: to.Ptr("WeeklySummary"), + // Receivers: []*armtestbase.NotificationEventReceiver{ + // { + // ReceiverType: to.Ptr("UserObjects"), + // ReceiverValue: &armtestbase.NotificationReceiverValue{ + // UserObjectReceiverValue: &armtestbase.UserObjectReceiverValue{ + // UserObjectIDs: []*string{ + // to.Ptr("245245245245325"), + // to.Ptr("365365365363565")}, + // }, + // }, + // }, + // { + // ReceiverType: to.Ptr("SubscriptionRole"), + // ReceiverValue: &armtestbase.NotificationReceiverValue{ + // SubscriptionReceiverValue: &armtestbase.SubscriptionReceiverValue{ + // Role: to.Ptr("Contributor"), + // SubscriptionID: to.Ptr("test-subscription-id"), + // SubscriptionName: to.Ptr("test-subscription"), + // }, + // }, + // }, + // { + // ReceiverType: to.Ptr("DistributionGroup"), + // ReceiverValue: &armtestbase.NotificationReceiverValue{ + // DistributionGroupListReceiverValue: &armtestbase.DistributionGroupListReceiverValue{ + // DistributionGroups: []*string{ + // to.Ptr("test@microsoft.com")}, + // }, + // }, + // }}, + // }, + // } +} diff --git a/sdk/resourcemanager/testbase/armtestbase/zz_generated_emailevents_client.go b/sdk/resourcemanager/testbase/armtestbase/emailevents_client.go similarity index 81% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_emailevents_client.go rename to sdk/resourcemanager/testbase/armtestbase/emailevents_client.go index 550febc941f8..0585556ef4d6 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_emailevents_client.go +++ b/sdk/resourcemanager/testbase/armtestbase/emailevents_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 armtestbase @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // EmailEventsClient contains the methods for the EmailEvents group. // Don't use this type directly, use NewEmailEventsClient() instead. type EmailEventsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewEmailEventsClient creates a new instance of EmailEventsClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewEmailEventsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EmailEventsClient, 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+".EmailEventsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &EmailEventsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets a email event of a Test Base Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// emailEventResourceName - The resource name of an email event. -// options - EmailEventsClientGetOptions contains the optional parameters for the EmailEventsClient.Get method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - emailEventResourceName - The resource name of an email event. +// - options - EmailEventsClientGetOptions contains the optional parameters for the EmailEventsClient.Get method. func (client *EmailEventsClient) Get(ctx context.Context, resourceGroupName string, testBaseAccountName string, emailEventResourceName string, options *EmailEventsClientGetOptions) (EmailEventsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, testBaseAccountName, emailEventResourceName, options) if err != nil { return EmailEventsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return EmailEventsClientGetResponse{}, err } @@ -95,7 +86,7 @@ func (client *EmailEventsClient) getCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter emailEventResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{emailEventResourceName}", url.PathEscape(emailEventResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -116,11 +107,11 @@ func (client *EmailEventsClient) getHandleResponse(resp *http.Response) (EmailEv } // NewListPager - Lists all the email events of a Test Base Account. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// options - EmailEventsClientListOptions contains the optional parameters for the EmailEventsClient.List method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - options - EmailEventsClientListOptions contains the optional parameters for the EmailEventsClient.NewListPager method. func (client *EmailEventsClient) NewListPager(resourceGroupName string, testBaseAccountName string, options *EmailEventsClientListOptions) *runtime.Pager[EmailEventsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[EmailEventsClientListResponse]{ More: func(page EmailEventsClientListResponse) bool { @@ -137,7 +128,7 @@ func (client *EmailEventsClient) NewListPager(resourceGroupName string, testBase if err != nil { return EmailEventsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return EmailEventsClientListResponse{}, err } @@ -164,7 +155,7 @@ func (client *EmailEventsClient) listCreateRequest(ctx context.Context, resource return nil, errors.New("parameter testBaseAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testBaseAccountName}", url.PathEscape(testBaseAccountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/testbase/armtestbase/emailevents_client_example_test.go b/sdk/resourcemanager/testbase/armtestbase/emailevents_client_example_test.go new file mode 100644 index 000000000000..d6ed80b29124 --- /dev/null +++ b/sdk/resourcemanager/testbase/armtestbase/emailevents_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 armtestbase_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/EmailEventsList.json +func ExampleEmailEventsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewEmailEventsClient().NewListPager("contoso-rg", "contoso-testBaseAccount", 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.EmailEventListResult = armtestbase.EmailEventListResult{ + // Value: []*armtestbase.EmailEventResource{ + // { + // Name: to.Ptr("weekly-summary"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/emailEvents"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount/emailEvents/weekly-summary"), + // Properties: &armtestbase.EmailEventProperties{ + // DisplayName: to.Ptr("Weekly Summary"), + // EventID: to.Ptr("weekly-summary"), + // EventName: to.Ptr("weekly-summary"), + // }, + // }, + // { + // Name: to.Ptr("daily-summary"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/emailEvents"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount/emailEvents/daily-summary"), + // Properties: &armtestbase.EmailEventProperties{ + // DisplayName: to.Ptr("Daily Summary"), + // EventID: to.Ptr("daily-summary"), + // EventName: to.Ptr("daily-summary"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/EmailEventGet.json +func ExampleEmailEventsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEmailEventsClient().Get(ctx, "contoso-rg", "contoso-testBaseAccount", "weekly-summary", 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.EmailEventResource = armtestbase.EmailEventResource{ + // Name: to.Ptr("weekly-summary"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/emailEvents"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount/emailEvents/weekly-summary"), + // Properties: &armtestbase.EmailEventProperties{ + // DisplayName: to.Ptr("Weekly Summary"), + // EventID: to.Ptr("weekly-summary"), + // EventName: to.Ptr("weekly-summary"), + // }, + // } +} diff --git a/sdk/resourcemanager/testbase/armtestbase/zz_generated_favoriteprocesses_client.go b/sdk/resourcemanager/testbase/armtestbase/favoriteprocesses_client.go similarity index 80% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_favoriteprocesses_client.go rename to sdk/resourcemanager/testbase/armtestbase/favoriteprocesses_client.go index cbb67bedca72..94f592281728 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_favoriteprocesses_client.go +++ b/sdk/resourcemanager/testbase/armtestbase/favoriteprocesses_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 armtestbase @@ -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,53 +24,45 @@ import ( // FavoriteProcessesClient contains the methods for the FavoriteProcesses group. // Don't use this type directly, use NewFavoriteProcessesClient() instead. type FavoriteProcessesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewFavoriteProcessesClient creates a new instance of FavoriteProcessesClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewFavoriteProcessesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FavoriteProcessesClient, 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+".FavoriteProcessesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &FavoriteProcessesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Create or replace a favorite process for a Test Base Package. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// packageName - The resource name of the Test Base Package. -// favoriteProcessResourceName - The resource name of a favorite process in a package. If the process name contains characters -// that are not allowed in Azure Resource Name, we use 'actualProcessName' in request body to submit the -// name. -// parameters - Parameters supplied to create a favorite process in a package. -// options - FavoriteProcessesClientCreateOptions contains the optional parameters for the FavoriteProcessesClient.Create -// method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - packageName - The resource name of the Test Base Package. +// - favoriteProcessResourceName - The resource name of a favorite process in a package. If the process name contains characters +// that are not allowed in Azure Resource Name, we use 'actualProcessName' in request body to submit the +// name. +// - parameters - Parameters supplied to create a favorite process in a package. +// - options - FavoriteProcessesClientCreateOptions contains the optional parameters for the FavoriteProcessesClient.Create +// method. func (client *FavoriteProcessesClient) Create(ctx context.Context, resourceGroupName string, testBaseAccountName string, packageName string, favoriteProcessResourceName string, parameters FavoriteProcessResource, options *FavoriteProcessesClientCreateOptions) (FavoriteProcessesClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, testBaseAccountName, packageName, favoriteProcessResourceName, parameters, options) if err != nil { return FavoriteProcessesClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FavoriteProcessesClientCreateResponse{}, err } @@ -104,7 +95,7 @@ func (client *FavoriteProcessesClient) createCreateRequest(ctx context.Context, return nil, errors.New("parameter favoriteProcessResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{favoriteProcessResourceName}", url.PathEscape(favoriteProcessResourceName)) - 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,21 +117,22 @@ func (client *FavoriteProcessesClient) createHandleResponse(resp *http.Response) // Delete - Deletes a favorite process for a specific package. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// packageName - The resource name of the Test Base Package. -// favoriteProcessResourceName - The resource name of a favorite process in a package. If the process name contains characters -// that are not allowed in Azure Resource Name, we use 'actualProcessName' in request body to submit the -// name. -// options - FavoriteProcessesClientDeleteOptions contains the optional parameters for the FavoriteProcessesClient.Delete -// method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - packageName - The resource name of the Test Base Package. +// - favoriteProcessResourceName - The resource name of a favorite process in a package. If the process name contains characters +// that are not allowed in Azure Resource Name, we use 'actualProcessName' in request body to submit the +// name. +// - options - FavoriteProcessesClientDeleteOptions contains the optional parameters for the FavoriteProcessesClient.Delete +// method. func (client *FavoriteProcessesClient) Delete(ctx context.Context, resourceGroupName string, testBaseAccountName string, packageName string, favoriteProcessResourceName string, options *FavoriteProcessesClientDeleteOptions) (FavoriteProcessesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, testBaseAccountName, packageName, favoriteProcessResourceName, options) if err != nil { return FavoriteProcessesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FavoriteProcessesClientDeleteResponse{}, err } @@ -173,7 +165,7 @@ func (client *FavoriteProcessesClient) deleteCreateRequest(ctx context.Context, return nil, errors.New("parameter favoriteProcessResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{favoriteProcessResourceName}", url.PathEscape(favoriteProcessResourceName)) - 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,20 +178,21 @@ func (client *FavoriteProcessesClient) deleteCreateRequest(ctx context.Context, // Get - Gets a favorite process for a Test Base Package. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// packageName - The resource name of the Test Base Package. -// favoriteProcessResourceName - The resource name of a favorite process in a package. If the process name contains characters -// that are not allowed in Azure Resource Name, we use 'actualProcessName' in request body to submit the -// name. -// options - FavoriteProcessesClientGetOptions contains the optional parameters for the FavoriteProcessesClient.Get method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - packageName - The resource name of the Test Base Package. +// - favoriteProcessResourceName - The resource name of a favorite process in a package. If the process name contains characters +// that are not allowed in Azure Resource Name, we use 'actualProcessName' in request body to submit the +// name. +// - options - FavoriteProcessesClientGetOptions contains the optional parameters for the FavoriteProcessesClient.Get method. func (client *FavoriteProcessesClient) Get(ctx context.Context, resourceGroupName string, testBaseAccountName string, packageName string, favoriteProcessResourceName string, options *FavoriteProcessesClientGetOptions) (FavoriteProcessesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, testBaseAccountName, packageName, favoriteProcessResourceName, options) if err != nil { return FavoriteProcessesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FavoriteProcessesClientGetResponse{}, err } @@ -232,7 +225,7 @@ func (client *FavoriteProcessesClient) getCreateRequest(ctx context.Context, res return nil, errors.New("parameter favoriteProcessResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{favoriteProcessResourceName}", url.PathEscape(favoriteProcessResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -253,12 +246,13 @@ func (client *FavoriteProcessesClient) getHandleResponse(resp *http.Response) (F } // NewListPager - Lists the favorite processes for a specific package. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// packageName - The resource name of the Test Base Package. -// options - FavoriteProcessesClientListOptions contains the optional parameters for the FavoriteProcessesClient.List method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - packageName - The resource name of the Test Base Package. +// - options - FavoriteProcessesClientListOptions contains the optional parameters for the FavoriteProcessesClient.NewListPager +// method. func (client *FavoriteProcessesClient) NewListPager(resourceGroupName string, testBaseAccountName string, packageName string, options *FavoriteProcessesClientListOptions) *runtime.Pager[FavoriteProcessesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[FavoriteProcessesClientListResponse]{ More: func(page FavoriteProcessesClientListResponse) bool { @@ -275,7 +269,7 @@ func (client *FavoriteProcessesClient) NewListPager(resourceGroupName string, te if err != nil { return FavoriteProcessesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FavoriteProcessesClientListResponse{}, err } @@ -306,7 +300,7 @@ func (client *FavoriteProcessesClient) listCreateRequest(ctx context.Context, re return nil, errors.New("parameter packageName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{packageName}", url.PathEscape(packageName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/testbase/armtestbase/favoriteprocesses_client_example_test.go b/sdk/resourcemanager/testbase/armtestbase/favoriteprocesses_client_example_test.go new file mode 100644 index 000000000000..4bc19305c560 --- /dev/null +++ b/sdk/resourcemanager/testbase/armtestbase/favoriteprocesses_client_example_test.go @@ -0,0 +1,140 @@ +//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 armtestbase_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/testbase/armtestbase" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/FavoriteProcessesList.json +func ExampleFavoriteProcessesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFavoriteProcessesClient().NewListPager("contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", 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.FavoriteProcessListResult = armtestbase.FavoriteProcessListResult{ + // Value: []*armtestbase.FavoriteProcessResource{ + // { + // Name: to.Ptr("testAppProcess"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages/favoriteProcesses"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/favoriteProcesses/testAppProcess"), + // Properties: &armtestbase.FavoriteProcessProperties{ + // ActualProcessName: to.Ptr("testApp&.exe"), + // }, + // }, + // { + // Name: to.Ptr("anotherProcess"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages/favoriteProcesses"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/favoriteProcesses/anotherProcess"), + // Properties: &armtestbase.FavoriteProcessProperties{ + // ActualProcessName: to.Ptr("anotherProcess&&.exe"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/FavoriteProcessCreate.json +func ExampleFavoriteProcessesClient_Create() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFavoriteProcessesClient().Create(ctx, "contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", "testAppProcess", armtestbase.FavoriteProcessResource{ + Properties: &armtestbase.FavoriteProcessProperties{ + ActualProcessName: to.Ptr("testApp&.exe"), + }, + }, 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.FavoriteProcessResource = armtestbase.FavoriteProcessResource{ + // Name: to.Ptr("testAppProcess"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages/favoriteProcesses"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/favoriteProcesses/testAppProcess"), + // Properties: &armtestbase.FavoriteProcessProperties{ + // ActualProcessName: to.Ptr("testApp&.exe"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/FavoriteProcessDelete.json +func ExampleFavoriteProcessesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewFavoriteProcessesClient().Delete(ctx, "contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", "testAppProcess", 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/FavoriteProcessGet.json +func ExampleFavoriteProcessesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFavoriteProcessesClient().Get(ctx, "contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", "testAppProcess", 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.FavoriteProcessResource = armtestbase.FavoriteProcessResource{ + // Name: to.Ptr("testAppProcess"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages/favoriteProcesses"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/favoriteProcesses/testAppProcess"), + // Properties: &armtestbase.FavoriteProcessProperties{ + // ActualProcessName: to.Ptr("testApp&.exe"), + // }, + // } +} diff --git a/sdk/resourcemanager/testbase/armtestbase/zz_generated_flightingrings_client.go b/sdk/resourcemanager/testbase/armtestbase/flightingrings_client.go similarity index 81% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_flightingrings_client.go rename to sdk/resourcemanager/testbase/armtestbase/flightingrings_client.go index cc69dd5a5c06..c5729100c722 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_flightingrings_client.go +++ b/sdk/resourcemanager/testbase/armtestbase/flightingrings_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 armtestbase @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // FlightingRingsClient contains the methods for the FlightingRings group. // Don't use this type directly, use NewFlightingRingsClient() instead. type FlightingRingsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewFlightingRingsClient creates a new instance of FlightingRingsClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewFlightingRingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FlightingRingsClient, 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+".FlightingRingsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &FlightingRingsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets a flighting ring of a Test Base Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// flightingRingResourceName - The resource name of a flighting ring. -// options - FlightingRingsClientGetOptions contains the optional parameters for the FlightingRingsClient.Get method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - flightingRingResourceName - The resource name of a flighting ring. +// - options - FlightingRingsClientGetOptions contains the optional parameters for the FlightingRingsClient.Get method. func (client *FlightingRingsClient) Get(ctx context.Context, resourceGroupName string, testBaseAccountName string, flightingRingResourceName string, options *FlightingRingsClientGetOptions) (FlightingRingsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, testBaseAccountName, flightingRingResourceName, options) if err != nil { return FlightingRingsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FlightingRingsClientGetResponse{}, err } @@ -95,7 +86,7 @@ func (client *FlightingRingsClient) getCreateRequest(ctx context.Context, resour return nil, errors.New("parameter flightingRingResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{flightingRingResourceName}", url.PathEscape(flightingRingResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -116,11 +107,11 @@ func (client *FlightingRingsClient) getHandleResponse(resp *http.Response) (Flig } // NewListPager - Lists all the flighting rings of a Test Base Account. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// options - FlightingRingsClientListOptions contains the optional parameters for the FlightingRingsClient.List method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - options - FlightingRingsClientListOptions contains the optional parameters for the FlightingRingsClient.NewListPager method. func (client *FlightingRingsClient) NewListPager(resourceGroupName string, testBaseAccountName string, options *FlightingRingsClientListOptions) *runtime.Pager[FlightingRingsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[FlightingRingsClientListResponse]{ More: func(page FlightingRingsClientListResponse) bool { @@ -137,7 +128,7 @@ func (client *FlightingRingsClient) NewListPager(resourceGroupName string, testB if err != nil { return FlightingRingsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FlightingRingsClientListResponse{}, err } @@ -164,7 +155,7 @@ func (client *FlightingRingsClient) listCreateRequest(ctx context.Context, resou return nil, errors.New("parameter testBaseAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testBaseAccountName}", url.PathEscape(testBaseAccountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/testbase/armtestbase/flightingrings_client_example_test.go b/sdk/resourcemanager/testbase/armtestbase/flightingrings_client_example_test.go new file mode 100644 index 000000000000..9f16ac9425be --- /dev/null +++ b/sdk/resourcemanager/testbase/armtestbase/flightingrings_client_example_test.go @@ -0,0 +1,90 @@ +//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 armtestbase_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/FlightingRingsList.json +func ExampleFlightingRingsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFlightingRingsClient().NewListPager("contoso-rg", "contoso-testBaseAccount", 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.FlightingRingListResult = armtestbase.FlightingRingListResult{ + // Value: []*armtestbase.FlightingRingResource{ + // { + // Name: to.Ptr("Insider-Beta-Channel"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/flightingRings"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount/flightingRings/Insider-Beta-Channel"), + // Properties: &armtestbase.FlightingRingProperties{ + // ActualFlightingRingName: to.Ptr("Insider Beta Channel"), + // }, + // }, + // { + // Name: to.Ptr("Another-Channel"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/flightingRings"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount/flightingRings/Another-Channel"), + // Properties: &armtestbase.FlightingRingProperties{ + // ActualFlightingRingName: to.Ptr("Another Channel"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/FlightingRingGet.json +func ExampleFlightingRingsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFlightingRingsClient().Get(ctx, "contoso-rg", "contoso-testBaseAccount", "Insider-Beta-Channel", 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.FlightingRingResource = armtestbase.FlightingRingResource{ + // Name: to.Ptr("Insider-Beta-Channel"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/flightingRings"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount/flightingRings/Insider-Beta-Channel"), + // Properties: &armtestbase.FlightingRingProperties{ + // ActualFlightingRingName: to.Ptr("Insider Beta Channel"), + // }, + // } +} diff --git a/sdk/resourcemanager/testbase/armtestbase/go.mod b/sdk/resourcemanager/testbase/armtestbase/go.mod index f8d1d2ce41a9..3fcb6cc04ec6 100644 --- a/sdk/resourcemanager/testbase/armtestbase/go.mod +++ b/sdk/resourcemanager/testbase/armtestbase/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbas 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/testbase/armtestbase/go.sum b/sdk/resourcemanager/testbase/armtestbase/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/testbase/armtestbase/go.sum +++ b/sdk/resourcemanager/testbase/armtestbase/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/testbase/armtestbase/zz_generated_models.go b/sdk/resourcemanager/testbase/armtestbase/models.go similarity index 98% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_models.go rename to sdk/resourcemanager/testbase/armtestbase/models.go index cef5bc02c263..5d3795b0e88e 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_models.go +++ b/sdk/resourcemanager/testbase/armtestbase/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 armtestbase @@ -188,13 +189,15 @@ type AccountsClientGetOptions 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 { // The flag indicating if we need to include the Test Base Accounts which were soft deleted before. GetDeleted *bool } -// AccountsClientListBySubscriptionOptions contains the optional parameters for the AccountsClient.ListBySubscription method. +// AccountsClientListBySubscriptionOptions contains the optional parameters for the AccountsClient.NewListBySubscriptionPager +// method. type AccountsClientListBySubscriptionOptions struct { // The flag indicating if we need to include the Test Base Accounts which were soft deleted before. GetDeleted *bool @@ -259,7 +262,7 @@ type AnalysisResultsClientGetOptions struct { // placeholder for future optional parameters } -// AnalysisResultsClientListOptions contains the optional parameters for the AnalysisResultsClient.List method. +// AnalysisResultsClientListOptions contains the optional parameters for the AnalysisResultsClient.NewListPager method. type AnalysisResultsClientListOptions struct { // placeholder for future optional parameters } @@ -269,7 +272,7 @@ type AvailableOSClientGetOptions struct { // placeholder for future optional parameters } -// AvailableOSClientListOptions contains the optional parameters for the AvailableOSClient.List method. +// AvailableOSClientListOptions contains the optional parameters for the AvailableOSClient.NewListPager method. type AvailableOSClientListOptions struct { // placeholder for future optional parameters } @@ -462,7 +465,7 @@ type CustomerEventsClientGetOptions struct { // placeholder for future optional parameters } -// CustomerEventsClientListByTestBaseAccountOptions contains the optional parameters for the CustomerEventsClient.ListByTestBaseAccount +// CustomerEventsClientListByTestBaseAccountOptions contains the optional parameters for the CustomerEventsClient.NewListByTestBaseAccountPager // method. type CustomerEventsClientListByTestBaseAccountOptions struct { // placeholder for future optional parameters @@ -527,7 +530,7 @@ type EmailEventsClientGetOptions struct { // placeholder for future optional parameters } -// EmailEventsClientListOptions contains the optional parameters for the EmailEventsClient.List method. +// EmailEventsClientListOptions contains the optional parameters for the EmailEventsClient.NewListPager method. type EmailEventsClientListOptions struct { // placeholder for future optional parameters } @@ -602,7 +605,7 @@ type FavoriteProcessesClientGetOptions struct { // placeholder for future optional parameters } -// FavoriteProcessesClientListOptions contains the optional parameters for the FavoriteProcessesClient.List method. +// FavoriteProcessesClientListOptions contains the optional parameters for the FavoriteProcessesClient.NewListPager method. type FavoriteProcessesClientListOptions struct { // placeholder for future optional parameters } @@ -654,7 +657,7 @@ type FlightingRingsClientGetOptions struct { // placeholder for future optional parameters } -// FlightingRingsClientListOptions contains the optional parameters for the FlightingRingsClient.List method. +// FlightingRingsClientListOptions contains the optional parameters for the FlightingRingsClient.NewListPager method. type FlightingRingsClientListOptions struct { // placeholder for future optional parameters } @@ -835,7 +838,7 @@ type OSUpdatesClientGetOptions struct { // placeholder for future optional parameters } -// OSUpdatesClientListOptions contains the optional parameters for the OSUpdatesClient.List method. +// OSUpdatesClientListOptions contains the optional parameters for the OSUpdatesClient.NewListPager method. type OSUpdatesClientListOptions struct { // placeholder for future optional parameters } @@ -864,7 +867,7 @@ type Operation struct { Display *OperationDisplay `json:"display,omitempty"` // Extra properties of the operation. - Properties interface{} `json:"properties,omitempty"` + Properties any `json:"properties,omitempty"` // READ-ONLY; Indicates whether the operation is a data action IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` @@ -900,7 +903,7 @@ type OperationListResult struct { NextLink *string `json:"nextLink,omitempty" azure:"ro"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -1068,7 +1071,7 @@ type PackagesClientGetOptions struct { // placeholder for future optional parameters } -// PackagesClientListByTestBaseAccountOptions contains the optional parameters for the PackagesClient.ListByTestBaseAccount +// PackagesClientListByTestBaseAccountOptions contains the optional parameters for the PackagesClient.NewListByTestBaseAccountPager // method. type PackagesClientListByTestBaseAccountOptions struct { // placeholder for future optional parameters @@ -1177,7 +1180,7 @@ type Resource struct { Type *string `json:"type,omitempty" azure:"ro"` } -// SKUsClientListOptions contains the optional parameters for the SKUsClient.List method. +// SKUsClientListOptions contains the optional parameters for the SKUsClient.NewListPager method. type SKUsClientListOptions struct { // placeholder for future optional parameters } @@ -1429,7 +1432,7 @@ type TestResultsClientGetVideoDownloadURLOptions struct { // placeholder for future optional parameters } -// TestResultsClientListOptions contains the optional parameters for the TestResultsClient.List method. +// TestResultsClientListOptions contains the optional parameters for the TestResultsClient.NewListPager method. type TestResultsClientListOptions struct { // Odata filter Filter *string @@ -1440,7 +1443,7 @@ type TestSummariesClientGetOptions struct { // placeholder for future optional parameters } -// TestSummariesClientListOptions contains the optional parameters for the TestSummariesClient.List method. +// TestSummariesClientListOptions contains the optional parameters for the TestSummariesClient.NewListPager method. type TestSummariesClientListOptions struct { // placeholder for future optional parameters } @@ -1543,7 +1546,7 @@ type TestTypesClientGetOptions struct { // placeholder for future optional parameters } -// TestTypesClientListOptions contains the optional parameters for the TestTypesClient.List method. +// TestTypesClientListOptions contains the optional parameters for the TestTypesClient.NewListPager method. type TestTypesClientListOptions struct { // placeholder for future optional parameters } @@ -1569,7 +1572,7 @@ type TrackedResource struct { Type *string `json:"type,omitempty" azure:"ro"` } -// UsageClientListOptions contains the optional parameters for the UsageClient.List method. +// UsageClientListOptions contains the optional parameters for the UsageClient.NewListPager method. type UsageClientListOptions struct { // Odata filter Filter *string diff --git a/sdk/resourcemanager/testbase/armtestbase/models_serde.go b/sdk/resourcemanager/testbase/armtestbase/models_serde.go new file mode 100644 index 000000000000..4531927224fb --- /dev/null +++ b/sdk/resourcemanager/testbase/armtestbase/models_serde.go @@ -0,0 +1,3409 @@ +//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 armtestbase + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AccountListResult. +func (a AccountListResult) 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 AccountListResult. +func (a *AccountListResult) UnmarshalJSON(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 AccountResource. +func (a AccountResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", a.Etag) + 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 AccountResource. +func (a *AccountResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "etag": + err = unpopulate(val, "Etag", &a.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "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 AccountResourceProperties. +func (a AccountResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accessLevel", a.AccessLevel) + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "sku", a.SKU) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountResourceProperties. +func (a *AccountResourceProperties) UnmarshalJSON(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 "accessLevel": + err = unpopulate(val, "AccessLevel", &a.AccessLevel) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &a.SKU) + 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 AccountSKU. +func (a AccountSKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "capabilities", a.Capabilities) + populate(objectMap, "locations", a.Locations) + populate(objectMap, "name", a.Name) + populate(objectMap, "resourceType", a.ResourceType) + populate(objectMap, "tier", a.Tier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountSKU. +func (a *AccountSKU) UnmarshalJSON(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 "capabilities": + err = unpopulate(val, "Capabilities", &a.Capabilities) + delete(rawMsg, key) + case "locations": + err = unpopulate(val, "Locations", &a.Locations) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &a.ResourceType) + delete(rawMsg, key) + case "tier": + err = unpopulate(val, "Tier", &a.Tier) + 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 AccountSKUCapability. +func (a AccountSKUCapability) 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 AccountSKUCapability. +func (a *AccountSKUCapability) UnmarshalJSON(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 AccountSKUListResult. +func (a AccountSKUListResult) 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 AccountSKUListResult. +func (a *AccountSKUListResult) UnmarshalJSON(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 AccountUpdateParameterProperties. +func (a AccountUpdateParameterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "sku", a.SKU) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountUpdateParameterProperties. +func (a *AccountUpdateParameterProperties) UnmarshalJSON(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 "sku": + err = unpopulate(val, "SKU", &a.SKU) + 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 AccountUpdateParameters. +func (a AccountUpdateParameters) 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 AccountUpdateParameters. +func (a *AccountUpdateParameters) UnmarshalJSON(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 AccountUsageData. +func (a AccountUsageData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "currentValue", a.CurrentValue) + populate(objectMap, "id", a.ID) + populate(objectMap, "limit", a.Limit) + populate(objectMap, "name", a.Name) + populate(objectMap, "unit", a.Unit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountUsageData. +func (a *AccountUsageData) UnmarshalJSON(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 "currentValue": + err = unpopulate(val, "CurrentValue", &a.CurrentValue) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "limit": + err = unpopulate(val, "Limit", &a.Limit) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "unit": + err = unpopulate(val, "Unit", &a.Unit) + 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 AccountUsageDataList. +func (a AccountUsageDataList) 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 AccountUsageDataList. +func (a *AccountUsageDataList) UnmarshalJSON(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 AccountUsageName. +func (a AccountUsageName) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "localizedValue", a.LocalizedValue) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountUsageName. +func (a *AccountUsageName) UnmarshalJSON(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 "localizedValue": + err = unpopulate(val, "LocalizedValue", &a.LocalizedValue) + 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 AnalysisResultListResult. +func (a AnalysisResultListResult) 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 AnalysisResultListResult. +func (a *AnalysisResultListResult) UnmarshalJSON(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 AnalysisResultSingletonResource. +func (a AnalysisResultSingletonResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AnalysisResultSingletonResource. +func (a *AnalysisResultSingletonResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + a.Properties, err = unmarshalAnalysisResultSingletonResourcePropertiesClassification(val) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AnalysisResultSingletonResourceProperties. +func (a AnalysisResultSingletonResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["analysisResultType"] = a.AnalysisResultType + populate(objectMap, "grade", a.Grade) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AnalysisResultSingletonResourceProperties. +func (a *AnalysisResultSingletonResourceProperties) UnmarshalJSON(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 "analysisResultType": + err = unpopulate(val, "AnalysisResultType", &a.AnalysisResultType) + delete(rawMsg, key) + case "grade": + err = unpopulate(val, "Grade", &a.Grade) + 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 AvailableOSListResult. +func (a AvailableOSListResult) 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 AvailableOSListResult. +func (a *AvailableOSListResult) UnmarshalJSON(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 AvailableOSProperties. +func (a AvailableOSProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "insiderChannel", a.InsiderChannel) + populate(objectMap, "osId", a.OSID) + populate(objectMap, "osName", a.OSName) + populate(objectMap, "osPlatform", a.OSPlatform) + populate(objectMap, "osUpdateType", a.OSUpdateType) + populate(objectMap, "osVersion", a.OSVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvailableOSProperties. +func (a *AvailableOSProperties) UnmarshalJSON(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 "insiderChannel": + err = unpopulate(val, "InsiderChannel", &a.InsiderChannel) + delete(rawMsg, key) + case "osId": + err = unpopulate(val, "OSID", &a.OSID) + delete(rawMsg, key) + case "osName": + err = unpopulate(val, "OSName", &a.OSName) + delete(rawMsg, key) + case "osPlatform": + err = unpopulate(val, "OSPlatform", &a.OSPlatform) + delete(rawMsg, key) + case "osUpdateType": + err = unpopulate(val, "OSUpdateType", &a.OSUpdateType) + delete(rawMsg, key) + case "osVersion": + err = unpopulate(val, "OSVersion", &a.OSVersion) + 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 AvailableOSResource. +func (a AvailableOSResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvailableOSResource. +func (a *AvailableOSResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CPURegressionResultSingletonResourceProperties. +func (c CPURegressionResultSingletonResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["analysisResultType"] = AnalysisResultTypeCPURegression + populate(objectMap, "cpuRegressionResults", c.CPURegressionResults) + populate(objectMap, "grade", c.Grade) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CPURegressionResultSingletonResourceProperties. +func (c *CPURegressionResultSingletonResourceProperties) UnmarshalJSON(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 "analysisResultType": + err = unpopulate(val, "AnalysisResultType", &c.AnalysisResultType) + delete(rawMsg, key) + case "cpuRegressionResults": + err = unpopulate(val, "CPURegressionResults", &c.CPURegressionResults) + delete(rawMsg, key) + case "grade": + err = unpopulate(val, "Grade", &c.Grade) + 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 CPUUtilizationResultSingletonResourceProperties. +func (c CPUUtilizationResultSingletonResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["analysisResultType"] = AnalysisResultTypeCPUUtilization + populate(objectMap, "cpuUtilizationResults", c.CPUUtilizationResults) + populate(objectMap, "grade", c.Grade) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CPUUtilizationResultSingletonResourceProperties. +func (c *CPUUtilizationResultSingletonResourceProperties) UnmarshalJSON(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 "analysisResultType": + err = unpopulate(val, "AnalysisResultType", &c.AnalysisResultType) + delete(rawMsg, key) + case "cpuUtilizationResults": + err = unpopulate(val, "CPUUtilizationResults", &c.CPUUtilizationResults) + delete(rawMsg, key) + case "grade": + err = unpopulate(val, "Grade", &c.Grade) + 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 CheckNameAvailabilityResult. +func (c CheckNameAvailabilityResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", c.Message) + populate(objectMap, "nameAvailable", c.NameAvailable) + populate(objectMap, "reason", c.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityResult. +func (c *CheckNameAvailabilityResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &c.Message) + delete(rawMsg, key) + case "nameAvailable": + err = unpopulate(val, "NameAvailable", &c.NameAvailable) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &c.Reason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Command. +func (c Command) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "action", c.Action) + populate(objectMap, "alwaysRun", c.AlwaysRun) + populate(objectMap, "applyUpdateBefore", c.ApplyUpdateBefore) + populate(objectMap, "content", c.Content) + populate(objectMap, "contentType", c.ContentType) + populate(objectMap, "maxRunTime", c.MaxRunTime) + populate(objectMap, "name", c.Name) + populate(objectMap, "restartAfter", c.RestartAfter) + populate(objectMap, "runAsInteractive", c.RunAsInteractive) + populate(objectMap, "runElevated", c.RunElevated) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Command. +func (c *Command) UnmarshalJSON(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 "action": + err = unpopulate(val, "Action", &c.Action) + delete(rawMsg, key) + case "alwaysRun": + err = unpopulate(val, "AlwaysRun", &c.AlwaysRun) + delete(rawMsg, key) + case "applyUpdateBefore": + err = unpopulate(val, "ApplyUpdateBefore", &c.ApplyUpdateBefore) + delete(rawMsg, key) + case "content": + err = unpopulate(val, "Content", &c.Content) + delete(rawMsg, key) + case "contentType": + err = unpopulate(val, "ContentType", &c.ContentType) + delete(rawMsg, key) + case "maxRunTime": + err = unpopulate(val, "MaxRunTime", &c.MaxRunTime) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "restartAfter": + err = unpopulate(val, "RestartAfter", &c.RestartAfter) + delete(rawMsg, key) + case "runAsInteractive": + err = unpopulate(val, "RunAsInteractive", &c.RunAsInteractive) + delete(rawMsg, key) + case "runElevated": + err = unpopulate(val, "RunElevated", &c.RunElevated) + 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 CustomerEventListResult. +func (c CustomerEventListResult) 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 CustomerEventListResult. +func (c *CustomerEventListResult) UnmarshalJSON(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 CustomerEventProperties. +func (c CustomerEventProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eventName", c.EventName) + populate(objectMap, "receivers", c.Receivers) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomerEventProperties. +func (c *CustomerEventProperties) UnmarshalJSON(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 "eventName": + err = unpopulate(val, "EventName", &c.EventName) + delete(rawMsg, key) + case "receivers": + err = unpopulate(val, "Receivers", &c.Receivers) + 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 CustomerEventResource. +func (c CustomerEventResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomerEventResource. +func (c *CustomerEventResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DistributionGroupListReceiverValue. +func (d DistributionGroupListReceiverValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "distributionGroups", d.DistributionGroups) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DistributionGroupListReceiverValue. +func (d *DistributionGroupListReceiverValue) UnmarshalJSON(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 "distributionGroups": + err = unpopulate(val, "DistributionGroups", &d.DistributionGroups) + 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 DownloadURLResponse. +func (d DownloadURLResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "downloadUrl", d.DownloadURL) + populateTimeRFC3339(objectMap, "expirationTime", d.ExpirationTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DownloadURLResponse. +func (d *DownloadURLResponse) UnmarshalJSON(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 "downloadUrl": + err = unpopulate(val, "DownloadURL", &d.DownloadURL) + delete(rawMsg, key) + case "expirationTime": + err = unpopulateTimeRFC3339(val, "ExpirationTime", &d.ExpirationTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EmailEventListResult. +func (e EmailEventListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EmailEventListResult. +func (e *EmailEventListResult) UnmarshalJSON(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 "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + 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 EmailEventProperties. +func (e EmailEventProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", e.DisplayName) + populate(objectMap, "eventId", e.EventID) + populate(objectMap, "eventName", e.EventName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EmailEventProperties. +func (e *EmailEventProperties) UnmarshalJSON(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 "displayName": + err = unpopulate(val, "DisplayName", &e.DisplayName) + delete(rawMsg, key) + case "eventId": + err = unpopulate(val, "EventID", &e.EventID) + delete(rawMsg, 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 EmailEventResource. +func (e EmailEventResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EmailEventResource. +func (e *EmailEventResource) UnmarshalJSON(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) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + 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 ErrorDefinition. +func (e ErrorDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 ErrorDefinition. +func (e *ErrorDefinition) UnmarshalJSON(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) + 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 FavoriteProcessListResult. +func (f FavoriteProcessListResult) 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 FavoriteProcessListResult. +func (f *FavoriteProcessListResult) UnmarshalJSON(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 FavoriteProcessProperties. +func (f FavoriteProcessProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actualProcessName", f.ActualProcessName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FavoriteProcessProperties. +func (f *FavoriteProcessProperties) UnmarshalJSON(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 "actualProcessName": + err = unpopulate(val, "ActualProcessName", &f.ActualProcessName) + 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 FavoriteProcessResource. +func (f FavoriteProcessResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", f.ID) + populate(objectMap, "name", f.Name) + populate(objectMap, "properties", f.Properties) + populate(objectMap, "systemData", f.SystemData) + populate(objectMap, "type", f.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FavoriteProcessResource. +func (f *FavoriteProcessResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &f.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &f.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &f.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &f.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FileUploadURLResponse. +func (f FileUploadURLResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "blobPath", f.BlobPath) + populate(objectMap, "uploadUrl", f.UploadURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FileUploadURLResponse. +func (f *FileUploadURLResponse) UnmarshalJSON(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 "blobPath": + err = unpopulate(val, "BlobPath", &f.BlobPath) + delete(rawMsg, key) + case "uploadUrl": + err = unpopulate(val, "UploadURL", &f.UploadURL) + 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 FlightingRingListResult. +func (f FlightingRingListResult) 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 FlightingRingListResult. +func (f *FlightingRingListResult) UnmarshalJSON(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 FlightingRingProperties. +func (f FlightingRingProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actualFlightingRingName", f.ActualFlightingRingName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FlightingRingProperties. +func (f *FlightingRingProperties) UnmarshalJSON(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 "actualFlightingRingName": + err = unpopulate(val, "ActualFlightingRingName", &f.ActualFlightingRingName) + 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 FlightingRingResource. +func (f FlightingRingResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", f.ID) + populate(objectMap, "name", f.Name) + populate(objectMap, "properties", f.Properties) + populate(objectMap, "systemData", f.SystemData) + populate(objectMap, "type", f.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FlightingRingResource. +func (f *FlightingRingResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &f.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &f.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &f.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &f.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GetFileUploadURLParameters. +func (g GetFileUploadURLParameters) 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 GetFileUploadURLParameters. +func (g *GetFileUploadURLParameters) UnmarshalJSON(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 IdentifiedFailure. +func (i IdentifiedFailure) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "category", i.Category) + populate(objectMap, "errorMessage", i.ErrorMessage) + populate(objectMap, "failureId", i.FailureID) + populate(objectMap, "guidance", i.Guidance) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IdentifiedFailure. +func (i *IdentifiedFailure) UnmarshalJSON(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 "category": + err = unpopulate(val, "Category", &i.Category) + delete(rawMsg, key) + case "errorMessage": + err = unpopulate(val, "ErrorMessage", &i.ErrorMessage) + delete(rawMsg, key) + case "failureId": + err = unpopulate(val, "FailureID", &i.FailureID) + delete(rawMsg, key) + case "guidance": + err = unpopulate(val, "Guidance", &i.Guidance) + 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 MemoryRegressionResultSingletonResourceProperties. +func (m MemoryRegressionResultSingletonResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["analysisResultType"] = AnalysisResultTypeMemoryRegression + populate(objectMap, "grade", m.Grade) + populate(objectMap, "memoryRegressionResults", m.MemoryRegressionResults) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MemoryRegressionResultSingletonResourceProperties. +func (m *MemoryRegressionResultSingletonResourceProperties) UnmarshalJSON(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 "analysisResultType": + err = unpopulate(val, "AnalysisResultType", &m.AnalysisResultType) + delete(rawMsg, key) + case "grade": + err = unpopulate(val, "Grade", &m.Grade) + delete(rawMsg, key) + case "memoryRegressionResults": + err = unpopulate(val, "MemoryRegressionResults", &m.MemoryRegressionResults) + 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 MemoryUtilizationResultSingletonResourceProperties. +func (m MemoryUtilizationResultSingletonResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["analysisResultType"] = AnalysisResultTypeMemoryUtilization + populate(objectMap, "grade", m.Grade) + populate(objectMap, "memoryUtilizationResults", m.MemoryUtilizationResults) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MemoryUtilizationResultSingletonResourceProperties. +func (m *MemoryUtilizationResultSingletonResourceProperties) UnmarshalJSON(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 "analysisResultType": + err = unpopulate(val, "AnalysisResultType", &m.AnalysisResultType) + delete(rawMsg, key) + case "grade": + err = unpopulate(val, "Grade", &m.Grade) + delete(rawMsg, key) + case "memoryUtilizationResults": + err = unpopulate(val, "MemoryUtilizationResults", &m.MemoryUtilizationResults) + 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 NotificationEventReceiver. +func (n NotificationEventReceiver) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "receiverType", n.ReceiverType) + populate(objectMap, "receiverValue", n.ReceiverValue) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NotificationEventReceiver. +func (n *NotificationEventReceiver) UnmarshalJSON(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 "receiverType": + err = unpopulate(val, "ReceiverType", &n.ReceiverType) + delete(rawMsg, key) + case "receiverValue": + err = unpopulate(val, "ReceiverValue", &n.ReceiverValue) + 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 NotificationReceiverValue. +func (n NotificationReceiverValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "distributionGroupListReceiverValue", n.DistributionGroupListReceiverValue) + populate(objectMap, "subscriptionReceiverValue", n.SubscriptionReceiverValue) + populate(objectMap, "userObjectReceiverValue", n.UserObjectReceiverValue) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NotificationReceiverValue. +func (n *NotificationReceiverValue) UnmarshalJSON(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 "distributionGroupListReceiverValue": + err = unpopulate(val, "DistributionGroupListReceiverValue", &n.DistributionGroupListReceiverValue) + delete(rawMsg, key) + case "subscriptionReceiverValue": + err = unpopulate(val, "SubscriptionReceiverValue", &n.SubscriptionReceiverValue) + delete(rawMsg, key) + case "userObjectReceiverValue": + err = unpopulate(val, "UserObjectReceiverValue", &n.UserObjectReceiverValue) + 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 OSUpdateListResult. +func (o OSUpdateListResult) 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 OSUpdateListResult. +func (o *OSUpdateListResult) UnmarshalJSON(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 OSUpdateProperties. +func (o OSUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "buildRevision", o.BuildRevision) + populate(objectMap, "buildVersion", o.BuildVersion) + populate(objectMap, "flightingRing", o.FlightingRing) + populate(objectMap, "osName", o.OSName) + populate(objectMap, "release", o.Release) + populateTimeRFC3339(objectMap, "releaseVersionDate", o.ReleaseVersionDate) + populate(objectMap, "type", o.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OSUpdateProperties. +func (o *OSUpdateProperties) UnmarshalJSON(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 "buildRevision": + err = unpopulate(val, "BuildRevision", &o.BuildRevision) + delete(rawMsg, key) + case "buildVersion": + err = unpopulate(val, "BuildVersion", &o.BuildVersion) + delete(rawMsg, key) + case "flightingRing": + err = unpopulate(val, "FlightingRing", &o.FlightingRing) + delete(rawMsg, key) + case "osName": + err = unpopulate(val, "OSName", &o.OSName) + delete(rawMsg, key) + case "release": + err = unpopulate(val, "Release", &o.Release) + delete(rawMsg, key) + case "releaseVersionDate": + err = unpopulateTimeRFC3339(val, "ReleaseVersionDate", &o.ReleaseVersionDate) + 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 OSUpdateResource. +func (o OSUpdateResource) 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 OSUpdateResource. +func (o *OSUpdateResource) UnmarshalJSON(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 OSUpdateTestSummary. +func (o OSUpdateTestSummary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "buildRevision", o.BuildRevision) + populate(objectMap, "buildVersion", o.BuildVersion) + populate(objectMap, "executionStatus", o.ExecutionStatus) + populate(objectMap, "flightingRing", o.FlightingRing) + populate(objectMap, "grade", o.Grade) + populate(objectMap, "osName", o.OSName) + populate(objectMap, "releaseName", o.ReleaseName) + populateTimeRFC3339(objectMap, "releaseVersionDate", o.ReleaseVersionDate) + populate(objectMap, "testRunTime", o.TestRunTime) + populate(objectMap, "testStatus", o.TestStatus) + populate(objectMap, "testType", o.TestType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OSUpdateTestSummary. +func (o *OSUpdateTestSummary) UnmarshalJSON(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 "buildRevision": + err = unpopulate(val, "BuildRevision", &o.BuildRevision) + delete(rawMsg, key) + case "buildVersion": + err = unpopulate(val, "BuildVersion", &o.BuildVersion) + delete(rawMsg, key) + case "executionStatus": + err = unpopulate(val, "ExecutionStatus", &o.ExecutionStatus) + delete(rawMsg, key) + case "flightingRing": + err = unpopulate(val, "FlightingRing", &o.FlightingRing) + delete(rawMsg, key) + case "grade": + err = unpopulate(val, "Grade", &o.Grade) + delete(rawMsg, key) + case "osName": + err = unpopulate(val, "OSName", &o.OSName) + delete(rawMsg, key) + case "releaseName": + err = unpopulate(val, "ReleaseName", &o.ReleaseName) + delete(rawMsg, key) + case "releaseVersionDate": + err = unpopulateTimeRFC3339(val, "ReleaseVersionDate", &o.ReleaseVersionDate) + delete(rawMsg, key) + case "testRunTime": + err = unpopulate(val, "TestRunTime", &o.TestRunTime) + delete(rawMsg, key) + case "testStatus": + err = unpopulate(val, "TestStatus", &o.TestStatus) + delete(rawMsg, key) + case "testType": + err = unpopulate(val, "TestType", &o.TestType) + 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 OSUpdatesTestSummary. +func (o OSUpdatesTestSummary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "executionStatus", o.ExecutionStatus) + populate(objectMap, "grade", o.Grade) + populate(objectMap, "osUpdateTestSummaries", o.OSUpdateTestSummaries) + populate(objectMap, "testRunTime", o.TestRunTime) + populate(objectMap, "testStatus", o.TestStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OSUpdatesTestSummary. +func (o *OSUpdatesTestSummary) UnmarshalJSON(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 "executionStatus": + err = unpopulate(val, "ExecutionStatus", &o.ExecutionStatus) + delete(rawMsg, key) + case "grade": + err = unpopulate(val, "Grade", &o.Grade) + delete(rawMsg, key) + case "osUpdateTestSummaries": + err = unpopulate(val, "OSUpdateTestSummaries", &o.OSUpdateTestSummaries) + delete(rawMsg, key) + case "testRunTime": + err = unpopulate(val, "TestRunTime", &o.TestRunTime) + delete(rawMsg, key) + case "testStatus": + err = unpopulate(val, "TestStatus", &o.TestStatus) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + populate(objectMap, "properties", &o.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type 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 PackageCheckNameAvailabilityParameters. +func (p PackageCheckNameAvailabilityParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "applicationName", p.ApplicationName) + populate(objectMap, "name", p.Name) + populate(objectMap, "type", p.Type) + populate(objectMap, "version", p.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PackageCheckNameAvailabilityParameters. +func (p *PackageCheckNameAvailabilityParameters) UnmarshalJSON(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 "applicationName": + err = unpopulate(val, "ApplicationName", &p.ApplicationName) + 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) + case "version": + err = unpopulate(val, "Version", &p.Version) + 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 PackageListResult. +func (p PackageListResult) 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 PackageListResult. +func (p *PackageListResult) UnmarshalJSON(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 PackageProperties. +func (p PackageProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "applicationName", p.ApplicationName) + populate(objectMap, "blobPath", p.BlobPath) + populate(objectMap, "flightingRing", p.FlightingRing) + populate(objectMap, "isEnabled", p.IsEnabled) + populateTimeRFC3339(objectMap, "lastModifiedTime", p.LastModifiedTime) + populate(objectMap, "packageStatus", p.PackageStatus) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "targetOSList", p.TargetOSList) + populate(objectMap, "testTypes", p.TestTypes) + populate(objectMap, "tests", p.Tests) + populate(objectMap, "validationResults", p.ValidationResults) + populate(objectMap, "version", p.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PackageProperties. +func (p *PackageProperties) UnmarshalJSON(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 "applicationName": + err = unpopulate(val, "ApplicationName", &p.ApplicationName) + delete(rawMsg, key) + case "blobPath": + err = unpopulate(val, "BlobPath", &p.BlobPath) + delete(rawMsg, key) + case "flightingRing": + err = unpopulate(val, "FlightingRing", &p.FlightingRing) + delete(rawMsg, key) + case "isEnabled": + err = unpopulate(val, "IsEnabled", &p.IsEnabled) + delete(rawMsg, key) + case "lastModifiedTime": + err = unpopulateTimeRFC3339(val, "LastModifiedTime", &p.LastModifiedTime) + delete(rawMsg, key) + case "packageStatus": + err = unpopulate(val, "PackageStatus", &p.PackageStatus) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + case "targetOSList": + err = unpopulate(val, "TargetOSList", &p.TargetOSList) + delete(rawMsg, key) + case "testTypes": + err = unpopulate(val, "TestTypes", &p.TestTypes) + delete(rawMsg, key) + case "tests": + err = unpopulate(val, "Tests", &p.Tests) + delete(rawMsg, key) + case "validationResults": + err = unpopulate(val, "ValidationResults", &p.ValidationResults) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &p.Version) + 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 PackageResource. +func (p PackageResource) 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, "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 PackageResource. +func (p *PackageResource) UnmarshalJSON(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 "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 PackageUpdateParameterProperties. +func (p PackageUpdateParameterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "blobPath", p.BlobPath) + populate(objectMap, "flightingRing", p.FlightingRing) + populate(objectMap, "isEnabled", p.IsEnabled) + populate(objectMap, "targetOSList", p.TargetOSList) + populate(objectMap, "tests", p.Tests) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PackageUpdateParameterProperties. +func (p *PackageUpdateParameterProperties) UnmarshalJSON(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 "blobPath": + err = unpopulate(val, "BlobPath", &p.BlobPath) + delete(rawMsg, key) + case "flightingRing": + err = unpopulate(val, "FlightingRing", &p.FlightingRing) + delete(rawMsg, key) + case "isEnabled": + err = unpopulate(val, "IsEnabled", &p.IsEnabled) + delete(rawMsg, key) + case "targetOSList": + err = unpopulate(val, "TargetOSList", &p.TargetOSList) + delete(rawMsg, key) + case "tests": + err = unpopulate(val, "Tests", &p.Tests) + 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 PackageUpdateParameters. +func (p PackageUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PackageUpdateParameters. +func (p *PackageUpdateParameters) UnmarshalJSON(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) + 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 PackageValidationResult. +func (p PackageValidationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "errors", p.Errors) + populate(objectMap, "isValid", p.IsValid) + populate(objectMap, "validationName", p.ValidationName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PackageValidationResult. +func (p *PackageValidationResult) UnmarshalJSON(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 "errors": + err = unpopulate(val, "Errors", &p.Errors) + delete(rawMsg, key) + case "isValid": + err = unpopulate(val, "IsValid", &p.IsValid) + delete(rawMsg, key) + case "validationName": + err = unpopulate(val, "ValidationName", &p.ValidationName) + 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 RegressionResult. +func (r RegressionResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "details", r.Details) + populate(objectMap, "diff", r.Diff) + populate(objectMap, "fileName", r.FileName) + populate(objectMap, "grade", r.Grade) + populate(objectMap, "isRegressed", r.IsRegressed) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RegressionResult. +func (r *RegressionResult) UnmarshalJSON(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 "details": + err = unpopulate(val, "Details", &r.Details) + delete(rawMsg, key) + case "diff": + err = unpopulate(val, "Diff", &r.Diff) + delete(rawMsg, key) + case "fileName": + err = unpopulate(val, "FileName", &r.FileName) + delete(rawMsg, key) + case "grade": + err = unpopulate(val, "Grade", &r.Grade) + delete(rawMsg, key) + case "isRegressed": + err = unpopulate(val, "IsRegressed", &r.IsRegressed) + 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 RegressionTestDetails. +func (r RegressionTestDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "diff", r.Diff) + populate(objectMap, "isRegressed", r.IsRegressed) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RegressionTestDetails. +func (r *RegressionTestDetails) UnmarshalJSON(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 "diff": + err = unpopulate(val, "Diff", &r.Diff) + delete(rawMsg, key) + case "isRegressed": + err = unpopulate(val, "IsRegressed", &r.IsRegressed) + 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 ReliabilityResult. +func (r ReliabilityResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "crashCount", r.CrashCount) + populate(objectMap, "crashRegressionGrade", r.CrashRegressionGrade) + populate(objectMap, "crashRegressionTestDetails", r.CrashRegressionTestDetails) + populate(objectMap, "fileName", r.FileName) + populate(objectMap, "hangCount", r.HangCount) + populate(objectMap, "hangRegressionGrade", r.HangRegressionGrade) + populate(objectMap, "hangRegressionTestDetails", r.HangRegressionTestDetails) + populate(objectMap, "launchCount", r.LaunchCount) + populate(objectMap, "regressionGrade", r.RegressionGrade) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReliabilityResult. +func (r *ReliabilityResult) UnmarshalJSON(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 "crashCount": + err = unpopulate(val, "CrashCount", &r.CrashCount) + delete(rawMsg, key) + case "crashRegressionGrade": + err = unpopulate(val, "CrashRegressionGrade", &r.CrashRegressionGrade) + delete(rawMsg, key) + case "crashRegressionTestDetails": + err = unpopulate(val, "CrashRegressionTestDetails", &r.CrashRegressionTestDetails) + delete(rawMsg, key) + case "fileName": + err = unpopulate(val, "FileName", &r.FileName) + delete(rawMsg, key) + case "hangCount": + err = unpopulate(val, "HangCount", &r.HangCount) + delete(rawMsg, key) + case "hangRegressionGrade": + err = unpopulate(val, "HangRegressionGrade", &r.HangRegressionGrade) + delete(rawMsg, key) + case "hangRegressionTestDetails": + err = unpopulate(val, "HangRegressionTestDetails", &r.HangRegressionTestDetails) + delete(rawMsg, key) + case "launchCount": + err = unpopulate(val, "LaunchCount", &r.LaunchCount) + delete(rawMsg, key) + case "regressionGrade": + err = unpopulate(val, "RegressionGrade", &r.RegressionGrade) + 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 ReliabilityResultSingletonResourceProperties. +func (r ReliabilityResultSingletonResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["analysisResultType"] = AnalysisResultTypeReliability + populate(objectMap, "grade", r.Grade) + populate(objectMap, "reliabilityResults", r.ReliabilityResults) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReliabilityResultSingletonResourceProperties. +func (r *ReliabilityResultSingletonResourceProperties) UnmarshalJSON(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 "analysisResultType": + err = unpopulate(val, "AnalysisResultType", &r.AnalysisResultType) + delete(rawMsg, key) + case "grade": + err = unpopulate(val, "Grade", &r.Grade) + delete(rawMsg, key) + case "reliabilityResults": + err = unpopulate(val, "ReliabilityResults", &r.ReliabilityResults) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ScriptExecutionResult. +func (s ScriptExecutionResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "endTime", s.EndTime) + populate(objectMap, "exitCode", s.ExitCode) + populate(objectMap, "scriptName", s.ScriptName) + populateTimeRFC3339(objectMap, "startTime", s.StartTime) + populate(objectMap, "timedOut", s.TimedOut) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScriptExecutionResult. +func (s *ScriptExecutionResult) UnmarshalJSON(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 "endTime": + err = unpopulateTimeRFC3339(val, "EndTime", &s.EndTime) + delete(rawMsg, key) + case "exitCode": + err = unpopulate(val, "ExitCode", &s.ExitCode) + delete(rawMsg, key) + case "scriptName": + err = unpopulate(val, "ScriptName", &s.ScriptName) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &s.StartTime) + delete(rawMsg, key) + case "timedOut": + err = unpopulate(val, "TimedOut", &s.TimedOut) + 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 ScriptExecutionResultSingletonResourceProperties. +func (s ScriptExecutionResultSingletonResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["analysisResultType"] = AnalysisResultTypeScriptExecution + populate(objectMap, "grade", s.Grade) + populate(objectMap, "scriptExecutionResults", s.ScriptExecutionResults) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScriptExecutionResultSingletonResourceProperties. +func (s *ScriptExecutionResultSingletonResourceProperties) UnmarshalJSON(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 "analysisResultType": + err = unpopulate(val, "AnalysisResultType", &s.AnalysisResultType) + delete(rawMsg, key) + case "grade": + err = unpopulate(val, "Grade", &s.Grade) + delete(rawMsg, key) + case "scriptExecutionResults": + err = unpopulate(val, "ScriptExecutionResults", &s.ScriptExecutionResults) + 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 SubscriptionReceiverValue. +func (s SubscriptionReceiverValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "role", s.Role) + populate(objectMap, "subscriptionId", s.SubscriptionID) + populate(objectMap, "subscriptionName", s.SubscriptionName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionReceiverValue. +func (s *SubscriptionReceiverValue) UnmarshalJSON(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 "role": + err = unpopulate(val, "Role", &s.Role) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &s.SubscriptionID) + delete(rawMsg, key) + case "subscriptionName": + err = unpopulate(val, "SubscriptionName", &s.SubscriptionName) + 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 TargetOSInfo. +func (t TargetOSInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "osUpdateType", t.OSUpdateType) + populate(objectMap, "targetOSs", t.TargetOSs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TargetOSInfo. +func (t *TargetOSInfo) UnmarshalJSON(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 "osUpdateType": + err = unpopulate(val, "OSUpdateType", &t.OSUpdateType) + delete(rawMsg, key) + case "targetOSs": + err = unpopulate(val, "TargetOSs", &t.TargetOSs) + 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 Test. +func (t Test) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "commands", t.Commands) + populate(objectMap, "isActive", t.IsActive) + populate(objectMap, "testType", t.TestType) + populate(objectMap, "validationRunStatus", t.ValidationRunStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Test. +func (t *Test) UnmarshalJSON(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 "commands": + err = unpopulate(val, "Commands", &t.Commands) + delete(rawMsg, key) + case "isActive": + err = unpopulate(val, "IsActive", &t.IsActive) + delete(rawMsg, key) + case "testType": + err = unpopulate(val, "TestType", &t.TestType) + delete(rawMsg, key) + case "validationRunStatus": + err = unpopulate(val, "ValidationRunStatus", &t.ValidationRunStatus) + 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 TestAnalysisResult. +func (t TestAnalysisResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "blobData", t.BlobData) + populate(objectMap, "identifiedFailures", t.IdentifiedFailures) + populate(objectMap, "testAnalysisStatus", t.TestAnalysisStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TestAnalysisResult. +func (t *TestAnalysisResult) UnmarshalJSON(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 "blobData": + err = unpopulate(val, "BlobData", &t.BlobData) + delete(rawMsg, key) + case "identifiedFailures": + err = unpopulate(val, "IdentifiedFailures", &t.IdentifiedFailures) + delete(rawMsg, key) + case "testAnalysisStatus": + err = unpopulate(val, "TestAnalysisStatus", &t.TestAnalysisStatus) + 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 TestAnalysisResultSingletonResourceProperties. +func (t TestAnalysisResultSingletonResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["analysisResultType"] = AnalysisResultTypeTestAnalysis + populate(objectMap, "grade", t.Grade) + populate(objectMap, "testAnalysisResult", t.TestAnalysisResult) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TestAnalysisResultSingletonResourceProperties. +func (t *TestAnalysisResultSingletonResourceProperties) UnmarshalJSON(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 "analysisResultType": + err = unpopulate(val, "AnalysisResultType", &t.AnalysisResultType) + delete(rawMsg, key) + case "grade": + err = unpopulate(val, "Grade", &t.Grade) + delete(rawMsg, key) + case "testAnalysisResult": + err = unpopulate(val, "TestAnalysisResult", &t.TestAnalysisResult) + 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 TestResultAnalysisSummary. +func (t TestResultAnalysisSummary) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "analysisStatus", t.AnalysisStatus) + populate(objectMap, "grade", t.Grade) + populate(objectMap, "name", t.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TestResultAnalysisSummary. +func (t *TestResultAnalysisSummary) UnmarshalJSON(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 "analysisStatus": + err = unpopulate(val, "AnalysisStatus", &t.AnalysisStatus) + delete(rawMsg, key) + case "grade": + err = unpopulate(val, "Grade", &t.Grade) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + 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 TestResultListResult. +func (t TestResultListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TestResultListResult. +func (t *TestResultListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &t.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TestResultProperties. +func (t TestResultProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "analysisSummaries", t.AnalysisSummaries) + populate(objectMap, "applicationName", t.ApplicationName) + populate(objectMap, "applicationVersion", t.ApplicationVersion) + populate(objectMap, "baselineTestResultId", t.BaselineTestResultID) + populate(objectMap, "buildRevision", t.BuildRevision) + populate(objectMap, "buildVersion", t.BuildVersion) + populate(objectMap, "executionStatus", t.ExecutionStatus) + populate(objectMap, "flightingRing", t.FlightingRing) + populate(objectMap, "grade", t.Grade) + populate(objectMap, "isDownloadDataAvailable", t.IsDownloadDataAvailable) + populate(objectMap, "isVideoAvailable", t.IsVideoAvailable) + populate(objectMap, "kbNumber", t.KbNumber) + populate(objectMap, "osName", t.OSName) + populate(objectMap, "packageId", t.PackageID) + populate(objectMap, "packageVersion", t.PackageVersion) + populate(objectMap, "releaseName", t.ReleaseName) + populateTimeRFC3339(objectMap, "releaseVersionDate", t.ReleaseVersionDate) + populate(objectMap, "testRunTime", t.TestRunTime) + populate(objectMap, "testStatus", t.TestStatus) + populate(objectMap, "testType", t.TestType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TestResultProperties. +func (t *TestResultProperties) UnmarshalJSON(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 "analysisSummaries": + err = unpopulate(val, "AnalysisSummaries", &t.AnalysisSummaries) + delete(rawMsg, key) + case "applicationName": + err = unpopulate(val, "ApplicationName", &t.ApplicationName) + delete(rawMsg, key) + case "applicationVersion": + err = unpopulate(val, "ApplicationVersion", &t.ApplicationVersion) + delete(rawMsg, key) + case "baselineTestResultId": + err = unpopulate(val, "BaselineTestResultID", &t.BaselineTestResultID) + delete(rawMsg, key) + case "buildRevision": + err = unpopulate(val, "BuildRevision", &t.BuildRevision) + delete(rawMsg, key) + case "buildVersion": + err = unpopulate(val, "BuildVersion", &t.BuildVersion) + delete(rawMsg, key) + case "executionStatus": + err = unpopulate(val, "ExecutionStatus", &t.ExecutionStatus) + delete(rawMsg, key) + case "flightingRing": + err = unpopulate(val, "FlightingRing", &t.FlightingRing) + delete(rawMsg, key) + case "grade": + err = unpopulate(val, "Grade", &t.Grade) + delete(rawMsg, key) + case "isDownloadDataAvailable": + err = unpopulate(val, "IsDownloadDataAvailable", &t.IsDownloadDataAvailable) + delete(rawMsg, key) + case "isVideoAvailable": + err = unpopulate(val, "IsVideoAvailable", &t.IsVideoAvailable) + delete(rawMsg, key) + case "kbNumber": + err = unpopulate(val, "KbNumber", &t.KbNumber) + delete(rawMsg, key) + case "osName": + err = unpopulate(val, "OSName", &t.OSName) + delete(rawMsg, key) + case "packageId": + err = unpopulate(val, "PackageID", &t.PackageID) + delete(rawMsg, key) + case "packageVersion": + err = unpopulate(val, "PackageVersion", &t.PackageVersion) + delete(rawMsg, key) + case "releaseName": + err = unpopulate(val, "ReleaseName", &t.ReleaseName) + delete(rawMsg, key) + case "releaseVersionDate": + err = unpopulateTimeRFC3339(val, "ReleaseVersionDate", &t.ReleaseVersionDate) + delete(rawMsg, key) + case "testRunTime": + err = unpopulate(val, "TestRunTime", &t.TestRunTime) + delete(rawMsg, key) + case "testStatus": + err = unpopulate(val, "TestStatus", &t.TestStatus) + delete(rawMsg, key) + case "testType": + err = unpopulate(val, "TestType", &t.TestType) + 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 TestResultResource. +func (t TestResultResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TestResultResource. +func (t *TestResultResource) UnmarshalJSON(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 "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + 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 TestSummaryListResult. +func (t TestSummaryListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TestSummaryListResult. +func (t *TestSummaryListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &t.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TestSummaryProperties. +func (t TestSummaryProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "applicationName", t.ApplicationName) + populate(objectMap, "applicationVersion", t.ApplicationVersion) + populate(objectMap, "executionStatus", t.ExecutionStatus) + populate(objectMap, "featureUpdatesTestSummary", t.FeatureUpdatesTestSummary) + populate(objectMap, "grade", t.Grade) + populate(objectMap, "packageId", t.PackageID) + populate(objectMap, "securityUpdatesTestSummary", t.SecurityUpdatesTestSummary) + populate(objectMap, "testRunTime", t.TestRunTime) + populate(objectMap, "testStatus", t.TestStatus) + populate(objectMap, "testSummaryId", t.TestSummaryID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TestSummaryProperties. +func (t *TestSummaryProperties) UnmarshalJSON(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 "applicationName": + err = unpopulate(val, "ApplicationName", &t.ApplicationName) + delete(rawMsg, key) + case "applicationVersion": + err = unpopulate(val, "ApplicationVersion", &t.ApplicationVersion) + delete(rawMsg, key) + case "executionStatus": + err = unpopulate(val, "ExecutionStatus", &t.ExecutionStatus) + delete(rawMsg, key) + case "featureUpdatesTestSummary": + err = unpopulate(val, "FeatureUpdatesTestSummary", &t.FeatureUpdatesTestSummary) + delete(rawMsg, key) + case "grade": + err = unpopulate(val, "Grade", &t.Grade) + delete(rawMsg, key) + case "packageId": + err = unpopulate(val, "PackageID", &t.PackageID) + delete(rawMsg, key) + case "securityUpdatesTestSummary": + err = unpopulate(val, "SecurityUpdatesTestSummary", &t.SecurityUpdatesTestSummary) + delete(rawMsg, key) + case "testRunTime": + err = unpopulate(val, "TestRunTime", &t.TestRunTime) + delete(rawMsg, key) + case "testStatus": + err = unpopulate(val, "TestStatus", &t.TestStatus) + delete(rawMsg, key) + case "testSummaryId": + err = unpopulate(val, "TestSummaryID", &t.TestSummaryID) + 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 TestSummaryResource. +func (t TestSummaryResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TestSummaryResource. +func (t *TestSummaryResource) UnmarshalJSON(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 "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + 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 TestTypeListResult. +func (t TestTypeListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TestTypeListResult. +func (t *TestTypeListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &t.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TestTypeProperties. +func (t TestTypeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actualTestTypeName", t.ActualTestTypeName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TestTypeProperties. +func (t *TestTypeProperties) UnmarshalJSON(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 "actualTestTypeName": + err = unpopulate(val, "ActualTestTypeName", &t.ActualTestTypeName) + 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 TestTypeResource. +func (t TestTypeResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TestTypeResource. +func (t *TestTypeResource) UnmarshalJSON(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 "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + 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 TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", t.Etag) + 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 "etag": + err = unpopulate(val, "Etag", &t.Etag) + delete(rawMsg, 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 UserObjectReceiverValue. +func (u UserObjectReceiverValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "userObjectIds", u.UserObjectIDs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserObjectReceiverValue. +func (u *UserObjectReceiverValue) UnmarshalJSON(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 "userObjectIds": + err = unpopulate(val, "UserObjectIDs", &u.UserObjectIDs) + 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 UtilizationBound. +func (u UtilizationBound) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "percentile", u.Percentile) + populate(objectMap, "value", u.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UtilizationBound. +func (u *UtilizationBound) UnmarshalJSON(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 "percentile": + err = unpopulate(val, "Percentile", &u.Percentile) + 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 UtilizationEntry. +func (u UtilizationEntry) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "timestamp", u.Timestamp) + populate(objectMap, "value", u.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UtilizationEntry. +func (u *UtilizationEntry) UnmarshalJSON(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 "timestamp": + err = unpopulateTimeRFC3339(val, "Timestamp", &u.Timestamp) + 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 UtilizationResult. +func (u UtilizationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "lowerBound", u.LowerBound) + populate(objectMap, "process", u.Process) + populate(objectMap, "upperBound", u.UpperBound) + populate(objectMap, "utilization", u.Utilization) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UtilizationResult. +func (u *UtilizationResult) UnmarshalJSON(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 "lowerBound": + err = unpopulate(val, "LowerBound", &u.LowerBound) + delete(rawMsg, key) + case "process": + err = unpopulate(val, "Process", &u.Process) + delete(rawMsg, key) + case "upperBound": + err = unpopulate(val, "UpperBound", &u.UpperBound) + delete(rawMsg, key) + case "utilization": + err = unpopulate(val, "Utilization", &u.Utilization) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, 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/testbase/armtestbase/zz_generated_operations_client.go b/sdk/resourcemanager/testbase/armtestbase/operations_client.go similarity index 77% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_operations_client.go rename to sdk/resourcemanager/testbase/armtestbase/operations_client.go index 4246747c52d3..ebb4b0a4284d 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_operations_client.go +++ b/sdk/resourcemanager/testbase/armtestbase/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 armtestbase @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,36 +21,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Lists all of the available REST API operations of the Microsoft.TestBase provider. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-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.TestBase/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/testbase/armtestbase/operations_client_example_test.go b/sdk/resourcemanager/testbase/armtestbase/operations_client_example_test.go new file mode 100644 index 000000000000..1280407e19e4 --- /dev/null +++ b/sdk/resourcemanager/testbase/armtestbase/operations_client_example_test.go @@ -0,0 +1,73 @@ +//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 armtestbase_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/OperationsList.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.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 = armtestbase.OperationListResult{ + // Value: []*armtestbase.Operation{ + // { + // Name: to.Ptr("Microsoft.TestBase/testBaseAccounts/read"), + // Display: &armtestbase.OperationDisplay{ + // Description: to.Ptr("View the properties of a Test Base Account."), + // Operation: to.Ptr("View Test Base Account"), + // Provider: to.Ptr("Microsoft Test Base"), + // Resource: to.Ptr("Test Base Account"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.TestBase/testBaseAccounts/write"), + // Display: &armtestbase.OperationDisplay{ + // Description: to.Ptr("Create a new Test Base Account or update the properties of an existing Test Base Account."), + // Operation: to.Ptr("Update Test Base Account"), + // Provider: to.Ptr("Microsoft Test Base"), + // Resource: to.Ptr("Test Base Account"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.TestBase/testBaseAccounts/delete"), + // Display: &armtestbase.OperationDisplay{ + // Description: to.Ptr("Delete a Test Base Account."), + // Operation: to.Ptr("Delete Test Base Account"), + // Provider: to.Ptr("Microsoft Test Base"), + // Resource: to.Ptr("Test Base Account"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/testbase/armtestbase/zz_generated_osupdates_client.go b/sdk/resourcemanager/testbase/armtestbase/osupdates_client.go similarity index 81% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_osupdates_client.go rename to sdk/resourcemanager/testbase/armtestbase/osupdates_client.go index 30aae3ad7814..d914c9bc1545 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_osupdates_client.go +++ b/sdk/resourcemanager/testbase/armtestbase/osupdates_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 armtestbase @@ -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 ( // OSUpdatesClient contains the methods for the OSUpdates group. // Don't use this type directly, use NewOSUpdatesClient() instead. type OSUpdatesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewOSUpdatesClient creates a new instance of OSUpdatesClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOSUpdatesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OSUpdatesClient, 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+".OSUpdatesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OSUpdatesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets an OS Update by name in which the package was tested before. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// packageName - The resource name of the Test Base Package. -// osUpdateResourceName - The resource name of an OS Update. -// options - OSUpdatesClientGetOptions contains the optional parameters for the OSUpdatesClient.Get method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - packageName - The resource name of the Test Base Package. +// - osUpdateResourceName - The resource name of an OS Update. +// - options - OSUpdatesClientGetOptions contains the optional parameters for the OSUpdatesClient.Get method. func (client *OSUpdatesClient) Get(ctx context.Context, resourceGroupName string, testBaseAccountName string, packageName string, osUpdateResourceName string, options *OSUpdatesClientGetOptions) (OSUpdatesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, testBaseAccountName, packageName, osUpdateResourceName, options) if err != nil { return OSUpdatesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OSUpdatesClientGetResponse{}, err } @@ -100,7 +91,7 @@ func (client *OSUpdatesClient) getCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter osUpdateResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{osUpdateResourceName}", url.PathEscape(osUpdateResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -121,13 +112,13 @@ func (client *OSUpdatesClient) getHandleResponse(resp *http.Response) (OSUpdates } // NewListPager - Lists the OS Updates in which the package were tested before. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// packageName - The resource name of the Test Base Package. -// osUpdateType - The type of the OS Update. -// options - OSUpdatesClientListOptions contains the optional parameters for the OSUpdatesClient.List method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - packageName - The resource name of the Test Base Package. +// - osUpdateType - The type of the OS Update. +// - options - OSUpdatesClientListOptions contains the optional parameters for the OSUpdatesClient.NewListPager method. func (client *OSUpdatesClient) NewListPager(resourceGroupName string, testBaseAccountName string, packageName string, osUpdateType OsUpdateType, options *OSUpdatesClientListOptions) *runtime.Pager[OSUpdatesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OSUpdatesClientListResponse]{ More: func(page OSUpdatesClientListResponse) bool { @@ -144,7 +135,7 @@ func (client *OSUpdatesClient) NewListPager(resourceGroupName string, testBaseAc if err != nil { return OSUpdatesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OSUpdatesClientListResponse{}, err } @@ -175,7 +166,7 @@ func (client *OSUpdatesClient) listCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter packageName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{packageName}", url.PathEscape(packageName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/testbase/armtestbase/osupdates_client_example_test.go b/sdk/resourcemanager/testbase/armtestbase/osupdates_client_example_test.go new file mode 100644 index 000000000000..f76cdc62671e --- /dev/null +++ b/sdk/resourcemanager/testbase/armtestbase/osupdates_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 armtestbase_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/OSUpdatesList.json +func ExampleOSUpdatesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOSUpdatesClient().NewListPager("contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", armtestbase.OsUpdateTypeSecurityUpdate, 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.OSUpdateListResult = armtestbase.OSUpdateListResult{ + // Value: []*armtestbase.OSUpdateResource{ + // { + // Name: to.Ptr("Windows-10-2004-2020-12-B-505"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages/osUpdates"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/osUpdates/Windows-10-2004-2020-12-B-505"), + // Properties: &armtestbase.OSUpdateProperties{ + // Type: to.Ptr(armtestbase.TypeSecurityUpdate), + // BuildRevision: to.Ptr("505"), + // OSName: to.Ptr("Windows 10 2004"), + // Release: to.Ptr("2020.12B"), + // }, + // }, + // { + // Name: to.Ptr("Windows-10-2004-2020-10-B-413"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages/osUpdates"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/osUpdates/Windows-10-2004-2020-10-B-413"), + // Properties: &armtestbase.OSUpdateProperties{ + // Type: to.Ptr(armtestbase.TypeSecurityUpdate), + // BuildRevision: to.Ptr("413"), + // OSName: to.Ptr("Windows 10 2004"), + // Release: to.Ptr("2020.10B"), + // }, + // }, + // { + // Name: to.Ptr("Windows-10-2004-2020-08-B-226"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages/osUpdates"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/osUpdates/Windows-10-2004-2020-08-B-226"), + // Properties: &armtestbase.OSUpdateProperties{ + // Type: to.Ptr(armtestbase.TypeSecurityUpdate), + // BuildRevision: to.Ptr("226"), + // OSName: to.Ptr("Windows 10 2004"), + // Release: to.Ptr("2020.08B"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/OSUpdateGet.json +func ExampleOSUpdatesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewOSUpdatesClient().Get(ctx, "contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", "Windows-10-2004-2020-12-B-505", 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.OSUpdateResource = armtestbase.OSUpdateResource{ + // Name: to.Ptr("Windows-10-2004-2020-12-B-505"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages/osUpdates"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/osUpdates/Windows-10-2004-2020-12-B-505"), + // Properties: &armtestbase.OSUpdateProperties{ + // Type: to.Ptr(armtestbase.TypeSecurityUpdate), + // BuildRevision: to.Ptr("505"), + // OSName: to.Ptr("Windows 10 2004"), + // Release: to.Ptr("2020.12B"), + // }, + // } +} diff --git a/sdk/resourcemanager/testbase/armtestbase/zz_generated_packages_client.go b/sdk/resourcemanager/testbase/armtestbase/packages_client.go similarity index 83% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_packages_client.go rename to sdk/resourcemanager/testbase/armtestbase/packages_client.go index 75aeaccaa576..be3b52971604 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_packages_client.go +++ b/sdk/resourcemanager/testbase/armtestbase/packages_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 armtestbase @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,66 +24,59 @@ import ( // PackagesClient contains the methods for the Packages group. // Don't use this type directly, use NewPackagesClient() instead. type PackagesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPackagesClient creates a new instance of PackagesClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewPackagesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PackagesClient, 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+".PackagesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PackagesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create or replace (overwrite/recreate, with potential downtime) a Test Base Package. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// packageName - The resource name of the Test Base Package. -// parameters - Parameters supplied to create a Test Base Package. -// options - PackagesClientBeginCreateOptions contains the optional parameters for the PackagesClient.BeginCreate method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - packageName - The resource name of the Test Base Package. +// - parameters - Parameters supplied to create a Test Base Package. +// - options - PackagesClientBeginCreateOptions contains the optional parameters for the PackagesClient.BeginCreate method. func (client *PackagesClient) BeginCreate(ctx context.Context, resourceGroupName string, testBaseAccountName string, packageName string, parameters PackageResource, options *PackagesClientBeginCreateOptions) (*runtime.Poller[PackagesClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, testBaseAccountName, packageName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[PackagesClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PackagesClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[PackagesClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PackagesClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create or replace (overwrite/recreate, with potential downtime) a Test Base Package. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview func (client *PackagesClient) create(ctx context.Context, resourceGroupName string, testBaseAccountName string, packageName string, parameters PackageResource, options *PackagesClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, testBaseAccountName, packageName, 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 } @@ -113,7 +105,7 @@ func (client *PackagesClient) createCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter packageName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{packageName}", url.PathEscape(packageName)) - 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,34 +118,36 @@ func (client *PackagesClient) createCreateRequest(ctx context.Context, resourceG // BeginDelete - Deletes a Test Base Package. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// packageName - The resource name of the Test Base Package. -// options - PackagesClientBeginDeleteOptions contains the optional parameters for the PackagesClient.BeginDelete method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - packageName - The resource name of the Test Base Package. +// - options - PackagesClientBeginDeleteOptions contains the optional parameters for the PackagesClient.BeginDelete method. func (client *PackagesClient) BeginDelete(ctx context.Context, resourceGroupName string, testBaseAccountName string, packageName string, options *PackagesClientBeginDeleteOptions) (*runtime.Poller[PackagesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, testBaseAccountName, packageName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[PackagesClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PackagesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[PackagesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PackagesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a Test Base Package. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview func (client *PackagesClient) deleteOperation(ctx context.Context, resourceGroupName string, testBaseAccountName string, packageName string, options *PackagesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, testBaseAccountName, packageName, 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 *PackagesClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter packageName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{packageName}", url.PathEscape(packageName)) - 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 } @@ -195,17 +189,18 @@ func (client *PackagesClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Gets a Test Base Package. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// packageName - The resource name of the Test Base Package. -// options - PackagesClientGetOptions contains the optional parameters for the PackagesClient.Get method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - packageName - The resource name of the Test Base Package. +// - options - PackagesClientGetOptions contains the optional parameters for the PackagesClient.Get method. func (client *PackagesClient) Get(ctx context.Context, resourceGroupName string, testBaseAccountName string, packageName string, options *PackagesClientGetOptions) (PackagesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, testBaseAccountName, packageName, options) if err != nil { return PackagesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PackagesClientGetResponse{}, err } @@ -234,7 +229,7 @@ func (client *PackagesClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter packageName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{packageName}", url.PathEscape(packageName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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 +251,18 @@ func (client *PackagesClient) getHandleResponse(resp *http.Response) (PackagesCl // GetDownloadURL - Gets the download URL of a package. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// packageName - The resource name of the Test Base Package. -// options - PackagesClientGetDownloadURLOptions contains the optional parameters for the PackagesClient.GetDownloadURL method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - packageName - The resource name of the Test Base Package. +// - options - PackagesClientGetDownloadURLOptions contains the optional parameters for the PackagesClient.GetDownloadURL method. func (client *PackagesClient) GetDownloadURL(ctx context.Context, resourceGroupName string, testBaseAccountName string, packageName string, options *PackagesClientGetDownloadURLOptions) (PackagesClientGetDownloadURLResponse, error) { req, err := client.getDownloadURLCreateRequest(ctx, resourceGroupName, testBaseAccountName, packageName, options) if err != nil { return PackagesClientGetDownloadURLResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PackagesClientGetDownloadURLResponse{}, err } @@ -295,7 +291,7 @@ func (client *PackagesClient) getDownloadURLCreateRequest(ctx context.Context, r return nil, errors.New("parameter packageName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{packageName}", url.PathEscape(packageName)) - 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 } @@ -317,35 +313,37 @@ func (client *PackagesClient) getDownloadURLHandleResponse(resp *http.Response) // BeginHardDelete - Hard Delete a Test Base Package. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// packageName - The resource name of the Test Base Package. -// options - PackagesClientBeginHardDeleteOptions contains the optional parameters for the PackagesClient.BeginHardDelete -// method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - packageName - The resource name of the Test Base Package. +// - options - PackagesClientBeginHardDeleteOptions contains the optional parameters for the PackagesClient.BeginHardDelete +// method. func (client *PackagesClient) BeginHardDelete(ctx context.Context, resourceGroupName string, testBaseAccountName string, packageName string, options *PackagesClientBeginHardDeleteOptions) (*runtime.Poller[PackagesClientHardDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.hardDelete(ctx, resourceGroupName, testBaseAccountName, packageName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[PackagesClientHardDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PackagesClientHardDeleteResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[PackagesClientHardDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PackagesClientHardDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // HardDelete - Hard Delete a Test Base Package. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview func (client *PackagesClient) hardDelete(ctx context.Context, resourceGroupName string, testBaseAccountName string, packageName string, options *PackagesClientBeginHardDeleteOptions) (*http.Response, error) { req, err := client.hardDeleteCreateRequest(ctx, resourceGroupName, testBaseAccountName, packageName, 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 } @@ -374,7 +372,7 @@ func (client *PackagesClient) hardDeleteCreateRequest(ctx context.Context, resou return nil, errors.New("parameter packageName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{packageName}", url.PathEscape(packageName)) - 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 } @@ -386,12 +384,12 @@ func (client *PackagesClient) hardDeleteCreateRequest(ctx context.Context, resou } // NewListByTestBaseAccountPager - Lists all the packages under a Test Base Account. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// options - PackagesClientListByTestBaseAccountOptions contains the optional parameters for the PackagesClient.ListByTestBaseAccount -// method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - options - PackagesClientListByTestBaseAccountOptions contains the optional parameters for the PackagesClient.NewListByTestBaseAccountPager +// method. func (client *PackagesClient) NewListByTestBaseAccountPager(resourceGroupName string, testBaseAccountName string, options *PackagesClientListByTestBaseAccountOptions) *runtime.Pager[PackagesClientListByTestBaseAccountResponse] { return runtime.NewPager(runtime.PagingHandler[PackagesClientListByTestBaseAccountResponse]{ More: func(page PackagesClientListByTestBaseAccountResponse) bool { @@ -408,7 +406,7 @@ func (client *PackagesClient) NewListByTestBaseAccountPager(resourceGroupName st if err != nil { return PackagesClientListByTestBaseAccountResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PackagesClientListByTestBaseAccountResponse{}, err } @@ -435,7 +433,7 @@ func (client *PackagesClient) listByTestBaseAccountCreateRequest(ctx context.Con return nil, errors.New("parameter testBaseAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testBaseAccountName}", url.PathEscape(testBaseAccountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -457,35 +455,37 @@ func (client *PackagesClient) listByTestBaseAccountHandleResponse(resp *http.Res // BeginUpdate - Update an existing Test Base Package. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// packageName - The resource name of the Test Base Package. -// parameters - Parameters supplied to update a Test Base Package. -// options - PackagesClientBeginUpdateOptions contains the optional parameters for the PackagesClient.BeginUpdate method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - packageName - The resource name of the Test Base Package. +// - parameters - Parameters supplied to update a Test Base Package. +// - options - PackagesClientBeginUpdateOptions contains the optional parameters for the PackagesClient.BeginUpdate method. func (client *PackagesClient) BeginUpdate(ctx context.Context, resourceGroupName string, testBaseAccountName string, packageName string, parameters PackageUpdateParameters, options *PackagesClientBeginUpdateOptions) (*runtime.Poller[PackagesClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, testBaseAccountName, packageName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[PackagesClientUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PackagesClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[PackagesClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PackagesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Update an existing Test Base Package. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview func (client *PackagesClient) update(ctx context.Context, resourceGroupName string, testBaseAccountName string, packageName string, parameters PackageUpdateParameters, options *PackagesClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, testBaseAccountName, packageName, 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 } @@ -514,7 +514,7 @@ func (client *PackagesClient) updateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter packageName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{packageName}", url.PathEscape(packageName)) - 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/testbase/armtestbase/packages_client_example_test.go b/sdk/resourcemanager/testbase/armtestbase/packages_client_example_test.go new file mode 100644 index 000000000000..7b1fe634fb76 --- /dev/null +++ b/sdk/resourcemanager/testbase/armtestbase/packages_client_example_test.go @@ -0,0 +1,812 @@ +//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 armtestbase_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/testbase/armtestbase" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/PackagesList.json +func ExamplePackagesClient_NewListByTestBaseAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPackagesClient().NewListByTestBaseAccountPager("contoso-rg1", "contoso-testBaseAccount1", 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.PackageListResult = armtestbase.PackageListResult{ + // Value: []*armtestbase.PackageResource{ + // { + // Name: to.Ptr("contoso-package1"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package1"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // }, + // Properties: &armtestbase.PackageProperties{ + // ApplicationName: to.Ptr("contoso-package1"), + // BlobPath: to.Ptr("storageAccountPath/package.zip"), + // FlightingRing: to.Ptr("Insider Beta Channel"), + // IsEnabled: to.Ptr(true), + // LastModifiedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:30:00Z"); return t}()), + // PackageStatus: to.Ptr(armtestbase.PackageStatusReady), + // ProvisioningState: to.Ptr(armtestbase.ProvisioningStateSucceeded), + // TargetOSList: []*armtestbase.TargetOSInfo{ + // { + // OSUpdateType: to.Ptr("Security updates"), + // TargetOSs: []*string{ + // to.Ptr("Windows 10 2004"), + // to.Ptr("Windows 10 1903")}, + // }, + // { + // OSUpdateType: to.Ptr("Feature updates"), + // TargetOSs: []*string{ + // to.Ptr("Windows 10 2004"), + // to.Ptr("Windows 10 1903"), + // to.Ptr("Windows 10 1809")}, + // }}, + // TestTypes: []*armtestbase.TestType{ + // to.Ptr(armtestbase.TestTypeOutOfBoxTest), + // to.Ptr(armtestbase.TestTypeFunctionalTest)}, + // Tests: []*armtestbase.Test{ + // { + // IsActive: to.Ptr(true), + // TestType: to.Ptr(armtestbase.TestTypeOutOfBoxTest), + // ValidationRunStatus: to.Ptr(armtestbase.ValidationRunStatusPassed), + // Commands: []*armtestbase.Command{ + // { + // Name: to.Ptr("Install"), + // Action: to.Ptr(armtestbase.ActionInstall), + // AlwaysRun: to.Ptr(true), + // ApplyUpdateBefore: to.Ptr(false), + // Content: to.Ptr("app/scripts/install/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(true), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }, + // { + // Name: to.Ptr("Launch"), + // Action: to.Ptr(armtestbase.ActionLaunch), + // AlwaysRun: to.Ptr(false), + // ApplyUpdateBefore: to.Ptr(true), + // Content: to.Ptr("app/scripts/launch/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(false), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }, + // { + // Name: to.Ptr("Close"), + // Action: to.Ptr(armtestbase.ActionClose), + // AlwaysRun: to.Ptr(false), + // ApplyUpdateBefore: to.Ptr(false), + // Content: to.Ptr("app/scripts/close/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(false), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }, + // { + // Name: to.Ptr("Uninstall"), + // Action: to.Ptr(armtestbase.ActionUninstall), + // AlwaysRun: to.Ptr(true), + // ApplyUpdateBefore: to.Ptr(false), + // Content: to.Ptr("app/scripts/uninstall/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(false), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }}, + // }, + // { + // IsActive: to.Ptr(true), + // TestType: to.Ptr(armtestbase.TestTypeFunctionalTest), + // ValidationRunStatus: to.Ptr(armtestbase.ValidationRunStatusPassed), + // Commands: []*armtestbase.Command{ + // { + // Name: to.Ptr("Custom1"), + // Action: to.Ptr(armtestbase.ActionCustom), + // AlwaysRun: to.Ptr(true), + // ApplyUpdateBefore: to.Ptr(false), + // Content: to.Ptr("app/scripts/custom/custom1.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(false), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }, + // { + // Name: to.Ptr("Custom2"), + // Action: to.Ptr(armtestbase.ActionCustom), + // AlwaysRun: to.Ptr(true), + // ApplyUpdateBefore: to.Ptr(true), + // Content: to.Ptr("app/scripts/custom/custom2.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(false), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }}, + // }}, + // ValidationResults: []*armtestbase.PackageValidationResult{ + // { + // IsValid: to.Ptr(true), + // ValidationName: to.Ptr("Syntax Validation"), + // }, + // { + // IsValid: to.Ptr(true), + // ValidationName: to.Ptr("Package Run Validation"), + // }}, + // Version: to.Ptr("1.0.0"), + // }, + // }, + // { + // Name: to.Ptr("contoso-package2"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // }, + // Properties: &armtestbase.PackageProperties{ + // ApplicationName: to.Ptr("contoso-package2"), + // BlobPath: to.Ptr("storageAccountPath/package.zip"), + // FlightingRing: to.Ptr("Insider Beta Channel"), + // IsEnabled: to.Ptr(true), + // LastModifiedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:30:00Z"); return t}()), + // PackageStatus: to.Ptr(armtestbase.PackageStatusReady), + // ProvisioningState: to.Ptr(armtestbase.ProvisioningStateSucceeded), + // TargetOSList: []*armtestbase.TargetOSInfo{ + // { + // OSUpdateType: to.Ptr("Security updates"), + // TargetOSs: []*string{ + // to.Ptr("Windows 10 2004"), + // to.Ptr("Windows 10 1903")}, + // }}, + // TestTypes: []*armtestbase.TestType{ + // to.Ptr(armtestbase.TestTypeOutOfBoxTest)}, + // Tests: []*armtestbase.Test{ + // { + // IsActive: to.Ptr(true), + // TestType: to.Ptr(armtestbase.TestTypeOutOfBoxTest), + // ValidationRunStatus: to.Ptr(armtestbase.ValidationRunStatusPassed), + // Commands: []*armtestbase.Command{ + // { + // Name: to.Ptr("Install"), + // Action: to.Ptr(armtestbase.ActionInstall), + // AlwaysRun: to.Ptr(true), + // ApplyUpdateBefore: to.Ptr(false), + // Content: to.Ptr("app/scripts/install/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(true), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }, + // { + // Name: to.Ptr("Launch"), + // Action: to.Ptr(armtestbase.ActionLaunch), + // AlwaysRun: to.Ptr(false), + // ApplyUpdateBefore: to.Ptr(true), + // Content: to.Ptr("app/scripts/launch/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(false), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }, + // { + // Name: to.Ptr("Close"), + // Action: to.Ptr(armtestbase.ActionClose), + // AlwaysRun: to.Ptr(false), + // ApplyUpdateBefore: to.Ptr(false), + // Content: to.Ptr("app/scripts/close/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(false), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }, + // { + // Name: to.Ptr("Uninstall"), + // Action: to.Ptr(armtestbase.ActionUninstall), + // AlwaysRun: to.Ptr(true), + // ApplyUpdateBefore: to.Ptr(false), + // Content: to.Ptr("app/scripts/uninstall/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(false), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }}, + // }}, + // ValidationResults: []*armtestbase.PackageValidationResult{ + // { + // IsValid: to.Ptr(true), + // ValidationName: to.Ptr("Syntax Validation"), + // }, + // { + // IsValid: to.Ptr(true), + // ValidationName: to.Ptr("Package Run Validation"), + // }}, + // Version: to.Ptr("1.0.0"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/PackageCreate.json +func ExamplePackagesClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewPackagesClient().BeginCreate(ctx, "contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", armtestbase.PackageResource{ + Location: to.Ptr("westus"), + Tags: map[string]*string{}, + Properties: &armtestbase.PackageProperties{ + ApplicationName: to.Ptr("contoso-package2"), + BlobPath: to.Ptr("storageAccountPath/package.zip"), + FlightingRing: to.Ptr("Insider Beta Channel"), + TargetOSList: []*armtestbase.TargetOSInfo{ + { + OSUpdateType: to.Ptr("Security updates"), + TargetOSs: []*string{ + to.Ptr("Windows 10 2004"), + to.Ptr("Windows 10 1903")}, + }}, + Tests: []*armtestbase.Test{ + { + IsActive: to.Ptr(true), + TestType: to.Ptr(armtestbase.TestTypeOutOfBoxTest), + Commands: []*armtestbase.Command{ + { + Name: to.Ptr("Install"), + Action: to.Ptr(armtestbase.ActionInstall), + AlwaysRun: to.Ptr(true), + ApplyUpdateBefore: to.Ptr(false), + Content: to.Ptr("app/scripts/install/job.ps1"), + ContentType: to.Ptr(armtestbase.ContentTypePath), + MaxRunTime: to.Ptr[int32](1800), + RestartAfter: to.Ptr(true), + RunAsInteractive: to.Ptr(true), + RunElevated: to.Ptr(true), + }, + { + Name: to.Ptr("Launch"), + Action: to.Ptr(armtestbase.ActionLaunch), + AlwaysRun: to.Ptr(false), + ApplyUpdateBefore: to.Ptr(true), + Content: to.Ptr("app/scripts/launch/job.ps1"), + ContentType: to.Ptr(armtestbase.ContentTypePath), + MaxRunTime: to.Ptr[int32](1800), + RestartAfter: to.Ptr(false), + RunAsInteractive: to.Ptr(true), + RunElevated: to.Ptr(true), + }, + { + Name: to.Ptr("Close"), + Action: to.Ptr(armtestbase.ActionClose), + AlwaysRun: to.Ptr(false), + ApplyUpdateBefore: to.Ptr(false), + Content: to.Ptr("app/scripts/close/job.ps1"), + ContentType: to.Ptr(armtestbase.ContentTypePath), + MaxRunTime: to.Ptr[int32](1800), + RestartAfter: to.Ptr(false), + RunAsInteractive: to.Ptr(true), + RunElevated: to.Ptr(true), + }, + { + Name: to.Ptr("Uninstall"), + Action: to.Ptr(armtestbase.ActionUninstall), + AlwaysRun: to.Ptr(true), + ApplyUpdateBefore: to.Ptr(false), + Content: to.Ptr("app/scripts/uninstall/job.ps1"), + ContentType: to.Ptr(armtestbase.ContentTypePath), + MaxRunTime: to.Ptr[int32](1800), + RestartAfter: to.Ptr(false), + RunAsInteractive: to.Ptr(true), + RunElevated: to.Ptr(true), + }}, + }}, + Version: to.Ptr("1.0.0"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.PackageResource = armtestbase.PackageResource{ + // Name: to.Ptr("contoso-package2"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // }, + // Properties: &armtestbase.PackageProperties{ + // ApplicationName: to.Ptr("contoso-package2"), + // BlobPath: to.Ptr("storageAccountPath/package.zip"), + // FlightingRing: to.Ptr("Insider Beta Channel"), + // IsEnabled: to.Ptr(true), + // LastModifiedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:30:00Z"); return t}()), + // PackageStatus: to.Ptr(armtestbase.PackageStatusReady), + // ProvisioningState: to.Ptr(armtestbase.ProvisioningStateSucceeded), + // TargetOSList: []*armtestbase.TargetOSInfo{ + // { + // OSUpdateType: to.Ptr("Security updates"), + // TargetOSs: []*string{ + // to.Ptr("Windows 10 2004"), + // to.Ptr("Windows 10 1903")}, + // }}, + // TestTypes: []*armtestbase.TestType{ + // to.Ptr(armtestbase.TestTypeOutOfBoxTest)}, + // Tests: []*armtestbase.Test{ + // { + // IsActive: to.Ptr(true), + // TestType: to.Ptr(armtestbase.TestTypeOutOfBoxTest), + // ValidationRunStatus: to.Ptr(armtestbase.ValidationRunStatusPassed), + // Commands: []*armtestbase.Command{ + // { + // Name: to.Ptr("Install"), + // Action: to.Ptr(armtestbase.ActionInstall), + // AlwaysRun: to.Ptr(true), + // ApplyUpdateBefore: to.Ptr(false), + // Content: to.Ptr("app/scripts/install/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(true), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }, + // { + // Name: to.Ptr("Launch"), + // Action: to.Ptr(armtestbase.ActionLaunch), + // AlwaysRun: to.Ptr(false), + // ApplyUpdateBefore: to.Ptr(true), + // Content: to.Ptr("app/scripts/launch/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(false), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }, + // { + // Name: to.Ptr("Close"), + // Action: to.Ptr(armtestbase.ActionClose), + // AlwaysRun: to.Ptr(false), + // ApplyUpdateBefore: to.Ptr(false), + // Content: to.Ptr("app/scripts/close/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(false), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }, + // { + // Name: to.Ptr("Uninstall"), + // Action: to.Ptr(armtestbase.ActionUninstall), + // AlwaysRun: to.Ptr(true), + // ApplyUpdateBefore: to.Ptr(false), + // Content: to.Ptr("app/scripts/uninstall/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(false), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }}, + // }}, + // ValidationResults: []*armtestbase.PackageValidationResult{ + // { + // IsValid: to.Ptr(true), + // ValidationName: to.Ptr("Syntax Validation"), + // }, + // { + // IsValid: to.Ptr(true), + // ValidationName: to.Ptr("Package Run Validation"), + // }}, + // Version: to.Ptr("1.0.0"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/PackageUpdate.json +func ExamplePackagesClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewPackagesClient().BeginUpdate(ctx, "contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", armtestbase.PackageUpdateParameters{ + Properties: &armtestbase.PackageUpdateParameterProperties{ + BlobPath: to.Ptr("storageAccountPath/package.zip"), + FlightingRing: to.Ptr("Insider Beta Channel"), + IsEnabled: to.Ptr(false), + TargetOSList: []*armtestbase.TargetOSInfo{ + { + OSUpdateType: to.Ptr("Security updates"), + TargetOSs: []*string{ + to.Ptr("Windows 10 2004"), + to.Ptr("Windows 10 1903")}, + }}, + Tests: []*armtestbase.Test{ + { + IsActive: to.Ptr(true), + TestType: to.Ptr(armtestbase.TestTypeOutOfBoxTest), + Commands: []*armtestbase.Command{ + { + Name: to.Ptr("Install"), + Action: to.Ptr(armtestbase.ActionInstall), + AlwaysRun: to.Ptr(true), + ApplyUpdateBefore: to.Ptr(false), + Content: to.Ptr("app/scripts/install/job.ps1"), + ContentType: to.Ptr(armtestbase.ContentTypePath), + MaxRunTime: to.Ptr[int32](1800), + RestartAfter: to.Ptr(true), + RunAsInteractive: to.Ptr(true), + RunElevated: to.Ptr(true), + }, + { + Name: to.Ptr("Launch"), + Action: to.Ptr(armtestbase.ActionLaunch), + AlwaysRun: to.Ptr(false), + ApplyUpdateBefore: to.Ptr(true), + Content: to.Ptr("app/scripts/launch/job.ps1"), + ContentType: to.Ptr(armtestbase.ContentTypePath), + MaxRunTime: to.Ptr[int32](1800), + RestartAfter: to.Ptr(false), + RunAsInteractive: to.Ptr(true), + RunElevated: to.Ptr(true), + }, + { + Name: to.Ptr("Close"), + Action: to.Ptr(armtestbase.ActionClose), + AlwaysRun: to.Ptr(false), + ApplyUpdateBefore: to.Ptr(false), + Content: to.Ptr("app/scripts/close/job.ps1"), + ContentType: to.Ptr(armtestbase.ContentTypePath), + MaxRunTime: to.Ptr[int32](1800), + RestartAfter: to.Ptr(false), + RunAsInteractive: to.Ptr(true), + RunElevated: to.Ptr(true), + }, + { + Name: to.Ptr("Uninstall"), + Action: to.Ptr(armtestbase.ActionUninstall), + AlwaysRun: to.Ptr(true), + ApplyUpdateBefore: to.Ptr(false), + Content: to.Ptr("app/scripts/uninstall/job.ps1"), + ContentType: to.Ptr(armtestbase.ContentTypePath), + MaxRunTime: to.Ptr[int32](1800), + RestartAfter: to.Ptr(false), + RunAsInteractive: to.Ptr(true), + RunElevated: to.Ptr(true), + }}, + }}, + }, + Tags: map[string]*string{}, + }, 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.PackageResource = armtestbase.PackageResource{ + // Name: to.Ptr("contoso-package2"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // }, + // Properties: &armtestbase.PackageProperties{ + // ApplicationName: to.Ptr("contoso-package2"), + // BlobPath: to.Ptr("storageAccountPath/package.zip"), + // FlightingRing: to.Ptr("Insider Beta Channel"), + // IsEnabled: to.Ptr(false), + // LastModifiedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:30:00Z"); return t}()), + // PackageStatus: to.Ptr(armtestbase.PackageStatusReady), + // ProvisioningState: to.Ptr(armtestbase.ProvisioningStateSucceeded), + // TargetOSList: []*armtestbase.TargetOSInfo{ + // { + // OSUpdateType: to.Ptr("Security updates"), + // TargetOSs: []*string{ + // to.Ptr("Windows 10 2004"), + // to.Ptr("Windows 10 1903")}, + // }}, + // TestTypes: []*armtestbase.TestType{ + // to.Ptr(armtestbase.TestTypeOutOfBoxTest)}, + // Tests: []*armtestbase.Test{ + // { + // IsActive: to.Ptr(true), + // TestType: to.Ptr(armtestbase.TestTypeOutOfBoxTest), + // ValidationRunStatus: to.Ptr(armtestbase.ValidationRunStatusPassed), + // Commands: []*armtestbase.Command{ + // { + // Name: to.Ptr("Install"), + // Action: to.Ptr(armtestbase.ActionInstall), + // AlwaysRun: to.Ptr(true), + // ApplyUpdateBefore: to.Ptr(false), + // Content: to.Ptr("app/scripts/install/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(true), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }, + // { + // Name: to.Ptr("Launch"), + // Action: to.Ptr(armtestbase.ActionLaunch), + // AlwaysRun: to.Ptr(false), + // ApplyUpdateBefore: to.Ptr(true), + // Content: to.Ptr("app/scripts/launch/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(false), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }, + // { + // Name: to.Ptr("Close"), + // Action: to.Ptr(armtestbase.ActionClose), + // AlwaysRun: to.Ptr(false), + // ApplyUpdateBefore: to.Ptr(false), + // Content: to.Ptr("app/scripts/close/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(false), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }, + // { + // Name: to.Ptr("Uninstall"), + // Action: to.Ptr(armtestbase.ActionUninstall), + // AlwaysRun: to.Ptr(true), + // ApplyUpdateBefore: to.Ptr(false), + // Content: to.Ptr("app/scripts/uninstall/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(false), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }}, + // }}, + // ValidationResults: []*armtestbase.PackageValidationResult{ + // { + // IsValid: to.Ptr(true), + // ValidationName: to.Ptr("Syntax Validation"), + // }, + // { + // IsValid: to.Ptr(true), + // ValidationName: to.Ptr("Package Run Validation"), + // }}, + // Version: to.Ptr("1.0.0"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/PackageDelete.json +func ExamplePackagesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewPackagesClient().BeginDelete(ctx, "contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/PackageGet.json +func ExamplePackagesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPackagesClient().Get(ctx, "contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", 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.PackageResource = armtestbase.PackageResource{ + // Name: to.Ptr("contoso-package2"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // }, + // Properties: &armtestbase.PackageProperties{ + // ApplicationName: to.Ptr("contoso-package2"), + // BlobPath: to.Ptr("storageAccountPath/package.zip"), + // FlightingRing: to.Ptr("Insider Beta Channel"), + // IsEnabled: to.Ptr(true), + // LastModifiedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:30:00Z"); return t}()), + // PackageStatus: to.Ptr(armtestbase.PackageStatusReady), + // ProvisioningState: to.Ptr(armtestbase.ProvisioningStateSucceeded), + // TargetOSList: []*armtestbase.TargetOSInfo{ + // { + // OSUpdateType: to.Ptr("Security updates"), + // TargetOSs: []*string{ + // to.Ptr("Windows 10 2004"), + // to.Ptr("Windows 10 1903")}, + // }}, + // TestTypes: []*armtestbase.TestType{ + // to.Ptr(armtestbase.TestTypeOutOfBoxTest)}, + // Tests: []*armtestbase.Test{ + // { + // IsActive: to.Ptr(true), + // TestType: to.Ptr(armtestbase.TestTypeOutOfBoxTest), + // ValidationRunStatus: to.Ptr(armtestbase.ValidationRunStatusPassed), + // Commands: []*armtestbase.Command{ + // { + // Name: to.Ptr("Install"), + // Action: to.Ptr(armtestbase.ActionInstall), + // AlwaysRun: to.Ptr(true), + // ApplyUpdateBefore: to.Ptr(false), + // Content: to.Ptr("app/scripts/install/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(true), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }, + // { + // Name: to.Ptr("Launch"), + // Action: to.Ptr(armtestbase.ActionLaunch), + // AlwaysRun: to.Ptr(false), + // ApplyUpdateBefore: to.Ptr(true), + // Content: to.Ptr("app/scripts/launch/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(false), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }, + // { + // Name: to.Ptr("Close"), + // Action: to.Ptr(armtestbase.ActionClose), + // AlwaysRun: to.Ptr(false), + // ApplyUpdateBefore: to.Ptr(false), + // Content: to.Ptr("app/scripts/close/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(false), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }, + // { + // Name: to.Ptr("Uninstall"), + // Action: to.Ptr(armtestbase.ActionUninstall), + // AlwaysRun: to.Ptr(true), + // ApplyUpdateBefore: to.Ptr(false), + // Content: to.Ptr("app/scripts/uninstall/job.ps1"), + // ContentType: to.Ptr(armtestbase.ContentTypePath), + // MaxRunTime: to.Ptr[int32](1800), + // RestartAfter: to.Ptr(false), + // RunAsInteractive: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }}, + // }}, + // ValidationResults: []*armtestbase.PackageValidationResult{ + // { + // IsValid: to.Ptr(true), + // ValidationName: to.Ptr("Syntax Validation"), + // }, + // { + // IsValid: to.Ptr(true), + // ValidationName: to.Ptr("Package Run Validation"), + // }}, + // Version: to.Ptr("1.0.0"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/PackageHardDelete.json +func ExamplePackagesClient_BeginHardDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewPackagesClient().BeginHardDelete(ctx, "contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/PackageGetDownloadURL.json +func ExamplePackagesClient_GetDownloadURL() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPackagesClient().GetDownloadURL(ctx, "contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", 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.DownloadURLResponse = armtestbase.DownloadURLResponse{ + // DownloadURL: to.Ptr("some URL"), + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-10T06:00:00Z"); return t}()), + // } +} diff --git a/sdk/resourcemanager/testbase/armtestbase/zz_generated_polymorphic_helpers.go b/sdk/resourcemanager/testbase/armtestbase/polymorphic_helpers.go similarity index 97% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_polymorphic_helpers.go rename to sdk/resourcemanager/testbase/armtestbase/polymorphic_helpers.go index b279c2b64083..6ce1935bb832 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_polymorphic_helpers.go +++ b/sdk/resourcemanager/testbase/armtestbase/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 armtestbase @@ -14,7 +15,7 @@ func unmarshalAnalysisResultSingletonResourcePropertiesClassification(rawMsg jso 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/testbase/armtestbase/zz_generated_response_types.go b/sdk/resourcemanager/testbase/armtestbase/response_types.go similarity index 87% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_response_types.go rename to sdk/resourcemanager/testbase/armtestbase/response_types.go index e9efbbc28ef6..340c6bc4d728 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_response_types.go +++ b/sdk/resourcemanager/testbase/armtestbase/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 armtestbase @@ -13,12 +14,12 @@ type AccountsClientCheckPackageNameAvailabilityResponse struct { CheckNameAvailabilityResult } -// AccountsClientCreateResponse contains the response from method AccountsClient.Create. +// AccountsClientCreateResponse contains the response from method AccountsClient.BeginCreate. type AccountsClientCreateResponse struct { AccountResource } -// AccountsClientDeleteResponse contains the response from method AccountsClient.Delete. +// AccountsClientDeleteResponse contains the response from method AccountsClient.BeginDelete. type AccountsClientDeleteResponse struct { // placeholder for future response values } @@ -33,22 +34,22 @@ type AccountsClientGetResponse struct { AccountResource } -// AccountsClientListByResourceGroupResponse contains the response from method AccountsClient.ListByResourceGroup. +// AccountsClientListByResourceGroupResponse contains the response from method AccountsClient.NewListByResourceGroupPager. type AccountsClientListByResourceGroupResponse struct { AccountListResult } -// AccountsClientListBySubscriptionResponse contains the response from method AccountsClient.ListBySubscription. +// AccountsClientListBySubscriptionResponse contains the response from method AccountsClient.NewListBySubscriptionPager. type AccountsClientListBySubscriptionResponse struct { AccountListResult } -// AccountsClientOffboardResponse contains the response from method AccountsClient.Offboard. +// AccountsClientOffboardResponse contains the response from method AccountsClient.BeginOffboard. type AccountsClientOffboardResponse struct { // placeholder for future response values } -// AccountsClientUpdateResponse contains the response from method AccountsClient.Update. +// AccountsClientUpdateResponse contains the response from method AccountsClient.BeginUpdate. type AccountsClientUpdateResponse struct { AccountResource } @@ -58,7 +59,7 @@ type AnalysisResultsClientGetResponse struct { AnalysisResultSingletonResource } -// AnalysisResultsClientListResponse contains the response from method AnalysisResultsClient.List. +// AnalysisResultsClientListResponse contains the response from method AnalysisResultsClient.NewListPager. type AnalysisResultsClientListResponse struct { AnalysisResultListResult } @@ -68,17 +69,17 @@ type AvailableOSClientGetResponse struct { AvailableOSResource } -// AvailableOSClientListResponse contains the response from method AvailableOSClient.List. +// AvailableOSClientListResponse contains the response from method AvailableOSClient.NewListPager. type AvailableOSClientListResponse struct { AvailableOSListResult } -// CustomerEventsClientCreateResponse contains the response from method CustomerEventsClient.Create. +// CustomerEventsClientCreateResponse contains the response from method CustomerEventsClient.BeginCreate. type CustomerEventsClientCreateResponse struct { CustomerEventResource } -// CustomerEventsClientDeleteResponse contains the response from method CustomerEventsClient.Delete. +// CustomerEventsClientDeleteResponse contains the response from method CustomerEventsClient.BeginDelete. type CustomerEventsClientDeleteResponse struct { // placeholder for future response values } @@ -88,7 +89,7 @@ type CustomerEventsClientGetResponse struct { CustomerEventResource } -// CustomerEventsClientListByTestBaseAccountResponse contains the response from method CustomerEventsClient.ListByTestBaseAccount. +// CustomerEventsClientListByTestBaseAccountResponse contains the response from method CustomerEventsClient.NewListByTestBaseAccountPager. type CustomerEventsClientListByTestBaseAccountResponse struct { CustomerEventListResult } @@ -98,7 +99,7 @@ type EmailEventsClientGetResponse struct { EmailEventResource } -// EmailEventsClientListResponse contains the response from method EmailEventsClient.List. +// EmailEventsClientListResponse contains the response from method EmailEventsClient.NewListPager. type EmailEventsClientListResponse struct { EmailEventListResult } @@ -118,7 +119,7 @@ type FavoriteProcessesClientGetResponse struct { FavoriteProcessResource } -// FavoriteProcessesClientListResponse contains the response from method FavoriteProcessesClient.List. +// FavoriteProcessesClientListResponse contains the response from method FavoriteProcessesClient.NewListPager. type FavoriteProcessesClientListResponse struct { FavoriteProcessListResult } @@ -128,7 +129,7 @@ type FlightingRingsClientGetResponse struct { FlightingRingResource } -// FlightingRingsClientListResponse contains the response from method FlightingRingsClient.List. +// FlightingRingsClientListResponse contains the response from method FlightingRingsClient.NewListPager. type FlightingRingsClientListResponse struct { FlightingRingListResult } @@ -138,22 +139,22 @@ type OSUpdatesClientGetResponse struct { OSUpdateResource } -// OSUpdatesClientListResponse contains the response from method OSUpdatesClient.List. +// OSUpdatesClientListResponse contains the response from method OSUpdatesClient.NewListPager. type OSUpdatesClientListResponse struct { OSUpdateListResult } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationListResult } -// PackagesClientCreateResponse contains the response from method PackagesClient.Create. +// PackagesClientCreateResponse contains the response from method PackagesClient.BeginCreate. type PackagesClientCreateResponse struct { PackageResource } -// PackagesClientDeleteResponse contains the response from method PackagesClient.Delete. +// PackagesClientDeleteResponse contains the response from method PackagesClient.BeginDelete. type PackagesClientDeleteResponse struct { // placeholder for future response values } @@ -168,22 +169,22 @@ type PackagesClientGetResponse struct { PackageResource } -// PackagesClientHardDeleteResponse contains the response from method PackagesClient.HardDelete. +// PackagesClientHardDeleteResponse contains the response from method PackagesClient.BeginHardDelete. type PackagesClientHardDeleteResponse struct { // placeholder for future response values } -// PackagesClientListByTestBaseAccountResponse contains the response from method PackagesClient.ListByTestBaseAccount. +// PackagesClientListByTestBaseAccountResponse contains the response from method PackagesClient.NewListByTestBaseAccountPager. type PackagesClientListByTestBaseAccountResponse struct { PackageListResult } -// PackagesClientUpdateResponse contains the response from method PackagesClient.Update. +// PackagesClientUpdateResponse contains the response from method PackagesClient.BeginUpdate. type PackagesClientUpdateResponse struct { PackageResource } -// SKUsClientListResponse contains the response from method SKUsClient.List. +// SKUsClientListResponse contains the response from method SKUsClient.NewListPager. type SKUsClientListResponse struct { AccountSKUListResult } @@ -203,7 +204,7 @@ type TestResultsClientGetVideoDownloadURLResponse struct { DownloadURLResponse } -// TestResultsClientListResponse contains the response from method TestResultsClient.List. +// TestResultsClientListResponse contains the response from method TestResultsClient.NewListPager. type TestResultsClientListResponse struct { TestResultListResult } @@ -213,7 +214,7 @@ type TestSummariesClientGetResponse struct { TestSummaryResource } -// TestSummariesClientListResponse contains the response from method TestSummariesClient.List. +// TestSummariesClientListResponse contains the response from method TestSummariesClient.NewListPager. type TestSummariesClientListResponse struct { TestSummaryListResult } @@ -223,12 +224,12 @@ type TestTypesClientGetResponse struct { TestTypeResource } -// TestTypesClientListResponse contains the response from method TestTypesClient.List. +// TestTypesClientListResponse contains the response from method TestTypesClient.NewListPager. type TestTypesClientListResponse struct { TestTypeListResult } -// UsageClientListResponse contains the response from method UsageClient.List. +// UsageClientListResponse contains the response from method UsageClient.NewListPager. type UsageClientListResponse struct { AccountUsageDataList } diff --git a/sdk/resourcemanager/testbase/armtestbase/zz_generated_skus_client.go b/sdk/resourcemanager/testbase/armtestbase/skus_client.go similarity index 76% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_skus_client.go rename to sdk/resourcemanager/testbase/armtestbase/skus_client.go index 373cb58854d2..56d51db602e7 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_skus_client.go +++ b/sdk/resourcemanager/testbase/armtestbase/skus_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 armtestbase @@ -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,39 +24,30 @@ import ( // SKUsClient contains the methods for the SKUs group. // Don't use this type directly, use NewSKUsClient() instead. type SKUsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSKUsClient creates a new instance of SKUsClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSKUsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SKUsClient, 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+".SKUsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SKUsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Lists the available SKUs of Test Base Account in a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// options - SKUsClientListOptions contains the optional parameters for the SKUsClient.List method. +// - options - SKUsClientListOptions contains the optional parameters for the SKUsClient.NewListPager method. func (client *SKUsClient) NewListPager(options *SKUsClientListOptions) *runtime.Pager[SKUsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[SKUsClientListResponse]{ More: func(page SKUsClientListResponse) bool { @@ -74,7 +64,7 @@ func (client *SKUsClient) NewListPager(options *SKUsClientListOptions) *runtime. if err != nil { return SKUsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SKUsClientListResponse{}, err } @@ -93,7 +83,7 @@ func (client *SKUsClient) listCreateRequest(ctx context.Context, options *SKUsCl return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/testbase/armtestbase/skus_client_example_test.go b/sdk/resourcemanager/testbase/armtestbase/skus_client_example_test.go new file mode 100644 index 000000000000..930eb7ad91d2 --- /dev/null +++ b/sdk/resourcemanager/testbase/armtestbase/skus_client_example_test.go @@ -0,0 +1,64 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armtestbase_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestBaseAccountSKUsList.json +func ExampleSKUsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSKUsClient().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.AccountSKUListResult = armtestbase.AccountSKUListResult{ + // Value: []*armtestbase.AccountSKU{ + // { + // Name: to.Ptr("S0"), + // Capabilities: []*armtestbase.AccountSKUCapability{ + // }, + // Locations: []*string{ + // to.Ptr("global")}, + // ResourceType: to.Ptr("testBaseAccounts"), + // Tier: to.Ptr(armtestbase.TierStandard), + // }, + // { + // Name: to.Ptr("S0"), + // Capabilities: []*armtestbase.AccountSKUCapability{ + // }, + // Locations: []*string{ + // to.Ptr("global")}, + // ResourceType: to.Ptr("testBaseAccounts"), + // Tier: to.Ptr(armtestbase.TierStandard), + // }}, + // } + } +} diff --git a/sdk/resourcemanager/testbase/armtestbase/zz_generated_testresults_client.go b/sdk/resourcemanager/testbase/armtestbase/testresults_client.go similarity index 83% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_testresults_client.go rename to sdk/resourcemanager/testbase/armtestbase/testresults_client.go index eadab44fe67c..22b350a82b4b 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_testresults_client.go +++ b/sdk/resourcemanager/testbase/armtestbase/testresults_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 armtestbase @@ -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 ( // TestResultsClient contains the methods for the TestResults group. // Don't use this type directly, use NewTestResultsClient() instead. type TestResultsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewTestResultsClient creates a new instance of TestResultsClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewTestResultsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TestResultsClient, 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+".TestResultsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &TestResultsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get the Test Result by Id with specified OS Update type for a Test Base Package. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// packageName - The resource name of the Test Base Package. -// testResultName - The Test Result Name. It equals to {osName}-{TestResultId} string. -// options - TestResultsClientGetOptions contains the optional parameters for the TestResultsClient.Get method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - packageName - The resource name of the Test Base Package. +// - testResultName - The Test Result Name. It equals to {osName}-{TestResultId} string. +// - options - TestResultsClientGetOptions contains the optional parameters for the TestResultsClient.Get method. func (client *TestResultsClient) Get(ctx context.Context, resourceGroupName string, testBaseAccountName string, packageName string, testResultName string, options *TestResultsClientGetOptions) (TestResultsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, testBaseAccountName, packageName, testResultName, options) if err != nil { return TestResultsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TestResultsClientGetResponse{}, err } @@ -100,7 +91,7 @@ func (client *TestResultsClient) getCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter testResultName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testResultName}", url.PathEscape(testResultName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -122,19 +113,20 @@ func (client *TestResultsClient) getHandleResponse(resp *http.Response) (TestRes // GetDownloadURL - Gets the download URL of the test result. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// packageName - The resource name of the Test Base Package. -// testResultName - The Test Result Name. It equals to {osName}-{TestResultId} string. -// options - TestResultsClientGetDownloadURLOptions contains the optional parameters for the TestResultsClient.GetDownloadURL -// method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - packageName - The resource name of the Test Base Package. +// - testResultName - The Test Result Name. It equals to {osName}-{TestResultId} string. +// - options - TestResultsClientGetDownloadURLOptions contains the optional parameters for the TestResultsClient.GetDownloadURL +// method. func (client *TestResultsClient) GetDownloadURL(ctx context.Context, resourceGroupName string, testBaseAccountName string, packageName string, testResultName string, options *TestResultsClientGetDownloadURLOptions) (TestResultsClientGetDownloadURLResponse, error) { req, err := client.getDownloadURLCreateRequest(ctx, resourceGroupName, testBaseAccountName, packageName, testResultName, options) if err != nil { return TestResultsClientGetDownloadURLResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TestResultsClientGetDownloadURLResponse{}, err } @@ -167,7 +159,7 @@ func (client *TestResultsClient) getDownloadURLCreateRequest(ctx context.Context return nil, errors.New("parameter testResultName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testResultName}", url.PathEscape(testResultName)) - 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 } @@ -189,19 +181,20 @@ func (client *TestResultsClient) getDownloadURLHandleResponse(resp *http.Respons // GetVideoDownloadURL - Gets the download URL of the test execution screen recording. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// packageName - The resource name of the Test Base Package. -// testResultName - The Test Result Name. It equals to {osName}-{TestResultId} string. -// options - TestResultsClientGetVideoDownloadURLOptions contains the optional parameters for the TestResultsClient.GetVideoDownloadURL -// method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - packageName - The resource name of the Test Base Package. +// - testResultName - The Test Result Name. It equals to {osName}-{TestResultId} string. +// - options - TestResultsClientGetVideoDownloadURLOptions contains the optional parameters for the TestResultsClient.GetVideoDownloadURL +// method. func (client *TestResultsClient) GetVideoDownloadURL(ctx context.Context, resourceGroupName string, testBaseAccountName string, packageName string, testResultName string, options *TestResultsClientGetVideoDownloadURLOptions) (TestResultsClientGetVideoDownloadURLResponse, error) { req, err := client.getVideoDownloadURLCreateRequest(ctx, resourceGroupName, testBaseAccountName, packageName, testResultName, options) if err != nil { return TestResultsClientGetVideoDownloadURLResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TestResultsClientGetVideoDownloadURLResponse{}, err } @@ -234,7 +227,7 @@ func (client *TestResultsClient) getVideoDownloadURLCreateRequest(ctx context.Co return nil, errors.New("parameter testResultName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testResultName}", url.PathEscape(testResultName)) - 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,13 +249,13 @@ func (client *TestResultsClient) getVideoDownloadURLHandleResponse(resp *http.Re // NewListPager - Lists all the Test Results with specified OS Update type for a Test Base Package. Can be filtered by osName, // releaseName, flightingRing, buildVersion, buildRevision. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// packageName - The resource name of the Test Base Package. -// osUpdateType - The type of the OS Update. -// options - TestResultsClientListOptions contains the optional parameters for the TestResultsClient.List method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - packageName - The resource name of the Test Base Package. +// - osUpdateType - The type of the OS Update. +// - options - TestResultsClientListOptions contains the optional parameters for the TestResultsClient.NewListPager method. func (client *TestResultsClient) NewListPager(resourceGroupName string, testBaseAccountName string, packageName string, osUpdateType OsUpdateType, options *TestResultsClientListOptions) *runtime.Pager[TestResultsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[TestResultsClientListResponse]{ More: func(page TestResultsClientListResponse) bool { @@ -279,7 +272,7 @@ func (client *TestResultsClient) NewListPager(resourceGroupName string, testBase if err != nil { return TestResultsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TestResultsClientListResponse{}, err } @@ -310,7 +303,7 @@ func (client *TestResultsClient) listCreateRequest(ctx context.Context, resource return nil, errors.New("parameter packageName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{packageName}", url.PathEscape(packageName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/testbase/armtestbase/testresults_client_example_test.go b/sdk/resourcemanager/testbase/armtestbase/testresults_client_example_test.go new file mode 100644 index 000000000000..dc2f842e6cd5 --- /dev/null +++ b/sdk/resourcemanager/testbase/armtestbase/testresults_client_example_test.go @@ -0,0 +1,247 @@ +//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 armtestbase_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/testbase/armtestbase" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestResultsList.json +func ExampleTestResultsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewTestResultsClient().NewListPager("contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", armtestbase.OsUpdateTypeSecurityUpdate, &armtestbase.TestResultsClientListOptions{Filter: to.Ptr("osName eq 'Windows 10 2004' and releaseName eq '2020.11B'")}) + 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.TestResultListResult = armtestbase.TestResultListResult{ + // Value: []*armtestbase.TestResultResource{ + // { + // Name: to.Ptr("Windows-10-2004-8e8e3200-284b-4a99-8c30-cb46c54d4c1e"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages/testResults"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/testResults/Windows-10-2004-8e8e3200-284b-4a99-8c30-cb46c54d4c1e"), + // Properties: &armtestbase.TestResultProperties{ + // AnalysisSummaries: []*armtestbase.TestResultAnalysisSummary{ + // { + // Name: to.Ptr("Memory Regression Analysis Result"), + // AnalysisStatus: to.Ptr(armtestbase.AnalysisStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // }, + // { + // Name: to.Ptr("CPU Regression Analysis Result"), + // AnalysisStatus: to.Ptr(armtestbase.AnalysisStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // }, + // { + // Name: to.Ptr("Memory Utilization Analysis Result"), + // AnalysisStatus: to.Ptr(armtestbase.AnalysisStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // }, + // { + // Name: to.Ptr("CPU Utilization Analysis Result"), + // AnalysisStatus: to.Ptr(armtestbase.AnalysisStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // }}, + // ApplicationName: to.Ptr("contoso-package2"), + // ApplicationVersion: to.Ptr("1.0.0"), + // BaselineTestResultID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/testResults/anotherId"), + // BuildRevision: to.Ptr("478"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // IsDownloadDataAvailable: to.Ptr(true), + // KbNumber: to.Ptr("KB1984839"), + // OSName: to.Ptr("Windows 10 2004"), + // PackageID: to.Ptr("b5ed1bcc-e74c-40d8-82f2-1773f616f93e"), + // PackageVersion: to.Ptr("3.0.1"), + // ReleaseName: to.Ptr("2020.11B"), + // ReleaseVersionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-28T17:30:00Z"); return t}()), + // TestRunTime: to.Ptr("00:21:30"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("Out of box test"), + // }, + // }, + // { + // Name: to.Ptr("Windows-10-2004-d19baae0-9ab4-432b-a752-878343fa4481"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages/testResults"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/testResults/Windows-10-2004-d19baae0-9ab4-432b-a752-878343fa4481"), + // Properties: &armtestbase.TestResultProperties{ + // AnalysisSummaries: []*armtestbase.TestResultAnalysisSummary{ + // { + // Name: to.Ptr("Memory Regression Analysis Result"), + // AnalysisStatus: to.Ptr(armtestbase.AnalysisStatusNotAvailable), + // Grade: to.Ptr(armtestbase.GradeNotAvailable), + // }, + // { + // Name: to.Ptr("CPU Regression Analysis Result"), + // AnalysisStatus: to.Ptr(armtestbase.AnalysisStatusNotAvailable), + // Grade: to.Ptr(armtestbase.GradeNotAvailable), + // }, + // { + // Name: to.Ptr("Memory Utilization Analysis Result"), + // AnalysisStatus: to.Ptr(armtestbase.AnalysisStatusNotAvailable), + // Grade: to.Ptr(armtestbase.GradeNotAvailable), + // }, + // { + // Name: to.Ptr("CPU Utilization Analysis Result"), + // AnalysisStatus: to.Ptr(armtestbase.AnalysisStatusNotAvailable), + // Grade: to.Ptr(armtestbase.GradeNotAvailable), + // }}, + // ApplicationName: to.Ptr("contoso-package2"), + // ApplicationVersion: to.Ptr("1.0.0"), + // BaselineTestResultID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/testResults/anotherId"), + // BuildRevision: to.Ptr("309"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusFailed), + // Grade: to.Ptr(armtestbase.GradeFail), + // IsDownloadDataAvailable: to.Ptr(false), + // KbNumber: to.Ptr("KB1784831"), + // OSName: to.Ptr("Windows 10 2004"), + // PackageID: to.Ptr("b5ed1bcc-e74c-40d8-82f2-1773f616f93e"), + // PackageVersion: to.Ptr("3.0.1"), + // ReleaseName: to.Ptr("2020.11B"), + // ReleaseVersionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-28T17:30:00Z"); return t}()), + // TestRunTime: to.Ptr("01:00:00"), + // TestStatus: to.Ptr(armtestbase.TestStatusTestFailure), + // TestType: to.Ptr("Out of box test"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestResultGet.json +func ExampleTestResultsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTestResultsClient().Get(ctx, "contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", "Windows-10-1909-99b1f80d-03a9-4148-997f-806ba5bac8e0", 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.TestResultResource = armtestbase.TestResultResource{ + // Name: to.Ptr("Windows-10-1909-99b1f80d-03a9-4148-997f-806ba5bac8e0"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages/testResults"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/testResults/Windows-10-1909-99b1f80d-03a9-4148-997f-806ba5bac8e0"), + // Properties: &armtestbase.TestResultProperties{ + // AnalysisSummaries: []*armtestbase.TestResultAnalysisSummary{ + // { + // Name: to.Ptr("Memory Regression Analysis Result"), + // AnalysisStatus: to.Ptr(armtestbase.AnalysisStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // }, + // { + // Name: to.Ptr("CPU Regression Analysis Result"), + // AnalysisStatus: to.Ptr(armtestbase.AnalysisStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // }, + // { + // Name: to.Ptr("Memory Utilization Analysis Result"), + // AnalysisStatus: to.Ptr(armtestbase.AnalysisStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // }, + // { + // Name: to.Ptr("CPU Utilization Analysis Result"), + // AnalysisStatus: to.Ptr(armtestbase.AnalysisStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // }}, + // ApplicationName: to.Ptr("contoso-package2"), + // ApplicationVersion: to.Ptr("1.0.0"), + // BaselineTestResultID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/packages/contoso-package2/testResults/anotherId"), + // BuildRevision: to.Ptr("505"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // IsDownloadDataAvailable: to.Ptr(true), + // KbNumber: to.Ptr("KB1984839"), + // OSName: to.Ptr("Windows 10 1909"), + // PackageID: to.Ptr("b5ed1bcc-e74c-40d8-82f2-1773f616f93e"), + // PackageVersion: to.Ptr("3.0.1"), + // ReleaseName: to.Ptr("2020.12B"), + // ReleaseVersionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-28T17:30:00Z"); return t}()), + // TestRunTime: to.Ptr("00:21:30"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("Out of box test"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestResultGetDownloadURL.json +func ExampleTestResultsClient_GetDownloadURL() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTestResultsClient().GetDownloadURL(ctx, "contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", "Windows-10-1909-99b1f80d-03a9-4148-997f-806ba5bac8e0", 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.DownloadURLResponse = armtestbase.DownloadURLResponse{ + // DownloadURL: to.Ptr("test result download URL"), + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-10T06:00:00Z"); return t}()), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestResultGetVideoDownloadURL.json +func ExampleTestResultsClient_GetVideoDownloadURL() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTestResultsClient().GetVideoDownloadURL(ctx, "contoso-rg1", "contoso-testBaseAccount1", "contoso-package2", "Windows-10-1909-99b1f80d-03a9-4148-997f-806ba5bac8e0", 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.DownloadURLResponse = armtestbase.DownloadURLResponse{ + // DownloadURL: to.Ptr("test result video download URL"), + // ExpirationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-01-10T06:00:00Z"); return t}()), + // } +} diff --git a/sdk/resourcemanager/testbase/armtestbase/zz_generated_testsummaries_client.go b/sdk/resourcemanager/testbase/armtestbase/testsummaries_client.go similarity index 81% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_testsummaries_client.go rename to sdk/resourcemanager/testbase/armtestbase/testsummaries_client.go index 3e3879b8a262..30547b947770 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_testsummaries_client.go +++ b/sdk/resourcemanager/testbase/armtestbase/testsummaries_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 armtestbase @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // TestSummariesClient contains the methods for the TestSummaries group. // Don't use this type directly, use NewTestSummariesClient() instead. type TestSummariesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewTestSummariesClient creates a new instance of TestSummariesClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewTestSummariesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TestSummariesClient, 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+".TestSummariesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &TestSummariesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets a Test Summary with specific name from all the Test Summaries of all the packages under a Test Base Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// testSummaryName - The name of the Test Summary. -// options - TestSummariesClientGetOptions contains the optional parameters for the TestSummariesClient.Get method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - testSummaryName - The name of the Test Summary. +// - options - TestSummariesClientGetOptions contains the optional parameters for the TestSummariesClient.Get method. func (client *TestSummariesClient) Get(ctx context.Context, resourceGroupName string, testBaseAccountName string, testSummaryName string, options *TestSummariesClientGetOptions) (TestSummariesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, testBaseAccountName, testSummaryName, options) if err != nil { return TestSummariesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TestSummariesClientGetResponse{}, err } @@ -95,7 +86,7 @@ func (client *TestSummariesClient) getCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter testSummaryName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testSummaryName}", url.PathEscape(testSummaryName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -116,11 +107,11 @@ func (client *TestSummariesClient) getHandleResponse(resp *http.Response) (TestS } // NewListPager - Lists the Test Summaries of all the packages under a Test Base Account. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// options - TestSummariesClientListOptions contains the optional parameters for the TestSummariesClient.List method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - options - TestSummariesClientListOptions contains the optional parameters for the TestSummariesClient.NewListPager method. func (client *TestSummariesClient) NewListPager(resourceGroupName string, testBaseAccountName string, options *TestSummariesClientListOptions) *runtime.Pager[TestSummariesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[TestSummariesClientListResponse]{ More: func(page TestSummariesClientListResponse) bool { @@ -137,7 +128,7 @@ func (client *TestSummariesClient) NewListPager(resourceGroupName string, testBa if err != nil { return TestSummariesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TestSummariesClientListResponse{}, err } @@ -164,7 +155,7 @@ func (client *TestSummariesClient) listCreateRequest(ctx context.Context, resour return nil, errors.New("parameter testBaseAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testBaseAccountName}", url.PathEscape(testBaseAccountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/testbase/armtestbase/testsummaries_client_example_test.go b/sdk/resourcemanager/testbase/armtestbase/testsummaries_client_example_test.go new file mode 100644 index 000000000000..675add2edaa2 --- /dev/null +++ b/sdk/resourcemanager/testbase/armtestbase/testsummaries_client_example_test.go @@ -0,0 +1,333 @@ +//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 armtestbase_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestSummariesList.json +func ExampleTestSummariesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewTestSummariesClient().NewListPager("contoso-rg1", "contoso-testBaseAccount1", 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.TestSummaryListResult = armtestbase.TestSummaryListResult{ + // Value: []*armtestbase.TestSummaryResource{ + // { + // Name: to.Ptr("contoso-package1-38960b32-3541-4cf1-8ccc-fd22774395cc"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/testSummaries"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/testSummaries/contoso-package1-38960b32-3541-4cf1-8ccc-fd22774395cc"), + // Properties: &armtestbase.TestSummaryProperties{ + // ApplicationName: to.Ptr("contoso-package1"), + // ApplicationVersion: to.Ptr("1.0.0"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // FeatureUpdatesTestSummary: &armtestbase.OSUpdatesTestSummary{ + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSUpdateTestSummaries: []*armtestbase.OSUpdateTestSummary{ + // { + // BuildVersion: to.Ptr("513"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSName: to.Ptr("Windows 10 1909"), + // ReleaseName: to.Ptr("2020.12.B"), + // TestRunTime: to.Ptr("00:43:21"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("OutOfBoxTest"), + // }, + // { + // BuildVersion: to.Ptr("765"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSName: to.Ptr("Windows 10 1903"), + // ReleaseName: to.Ptr("2020.11.B"), + // TestRunTime: to.Ptr("00:13:28"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("OutOfBoxTest"), + // }, + // { + // BuildVersion: to.Ptr("313"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSName: to.Ptr("Windows 10 1809"), + // ReleaseName: to.Ptr("2020.11.B"), + // TestRunTime: to.Ptr("00:42:08"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("OutOfBoxTest"), + // }}, + // TestRunTime: to.Ptr("00:33:21"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // }, + // Grade: to.Ptr(armtestbase.GradePass), + // PackageID: to.Ptr("57199102-9738-42e0-9fec-db7709d62a71"), + // SecurityUpdatesTestSummary: &armtestbase.OSUpdatesTestSummary{ + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSUpdateTestSummaries: []*armtestbase.OSUpdateTestSummary{ + // { + // BuildVersion: to.Ptr("513"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSName: to.Ptr("Windows 10 1909"), + // ReleaseName: to.Ptr("2020.12.B"), + // TestRunTime: to.Ptr("00:43:21"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("OutOfBoxTest"), + // }, + // { + // BuildVersion: to.Ptr("765"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSName: to.Ptr("Windows 10 1903"), + // ReleaseName: to.Ptr("2020.11.B"), + // TestRunTime: to.Ptr("00:13:28"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("OutOfBoxTest"), + // }, + // { + // BuildVersion: to.Ptr("313"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSName: to.Ptr("Windows 10 1809"), + // ReleaseName: to.Ptr("2020.11.B"), + // TestRunTime: to.Ptr("00:42:08"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("OutOfBoxTest"), + // }}, + // TestRunTime: to.Ptr("00:43:21"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // }, + // TestRunTime: to.Ptr("00:43:21"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestSummaryID: to.Ptr("38960b32-3541-4cf1-8ccc-fd22774395cc"), + // }, + // }, + // { + // Name: to.Ptr("contoso-package2-096bffb5-5d3d-4305-a66a-953372ed6e88"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/testSummaries"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/testSummaries/contoso-package2-096bffb5-5d3d-4305-a66a-953372ed6e88"), + // Properties: &armtestbase.TestSummaryProperties{ + // ApplicationName: to.Ptr("contoso-package2"), + // ApplicationVersion: to.Ptr("1.0.0"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // FeatureUpdatesTestSummary: &armtestbase.OSUpdatesTestSummary{ + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSUpdateTestSummaries: []*armtestbase.OSUpdateTestSummary{ + // { + // BuildVersion: to.Ptr("513"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSName: to.Ptr("Windows 10 1909"), + // ReleaseName: to.Ptr("2020.12.B"), + // TestRunTime: to.Ptr("00:43:21"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("FunctionalTest"), + // }, + // { + // BuildVersion: to.Ptr("765"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSName: to.Ptr("Windows 10 1903"), + // ReleaseName: to.Ptr("2020.11.B"), + // TestRunTime: to.Ptr("00:13:28"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("FunctionalTest"), + // }, + // { + // BuildVersion: to.Ptr("313"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSName: to.Ptr("Windows 10 1809"), + // ReleaseName: to.Ptr("2020.11.B"), + // TestRunTime: to.Ptr("00:42:08"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("FunctionalTest"), + // }}, + // TestRunTime: to.Ptr("00:33:21"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // }, + // Grade: to.Ptr(armtestbase.GradePass), + // PackageID: to.Ptr("b5ed1bcc-e74c-40d8-82f2-1773f616f93e"), + // SecurityUpdatesTestSummary: &armtestbase.OSUpdatesTestSummary{ + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSUpdateTestSummaries: []*armtestbase.OSUpdateTestSummary{ + // { + // BuildVersion: to.Ptr("513"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSName: to.Ptr("Windows 10 1909"), + // ReleaseName: to.Ptr("2020.12.B"), + // TestRunTime: to.Ptr("00:43:21"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("FunctionalTest"), + // }, + // { + // BuildVersion: to.Ptr("765"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSName: to.Ptr("Windows 10 1903"), + // ReleaseName: to.Ptr("2020.11.B"), + // TestRunTime: to.Ptr("00:13:28"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("FunctionalTest"), + // }, + // { + // BuildVersion: to.Ptr("313"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSName: to.Ptr("Windows 10 1809"), + // ReleaseName: to.Ptr("2020.11.B"), + // TestRunTime: to.Ptr("00:42:08"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("FunctionalTest"), + // }}, + // TestRunTime: to.Ptr("00:43:21"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // }, + // TestRunTime: to.Ptr("00:43:21"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestSummaryID: to.Ptr("096bffb5-5d3d-4305-a66a-953372ed6e88"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestSummaryGet.json +func ExampleTestSummariesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTestSummariesClient().Get(ctx, "contoso-rg1", "contoso-testBaseAccount1", "contoso-package2-096bffb5-5d3d-4305-a66a-953372ed6e88", 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.TestSummaryResource = armtestbase.TestSummaryResource{ + // Name: to.Ptr("contoso-package2-096bffb5-5d3d-4305-a66a-953372ed6e88"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/testSummaries"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/testSummaries/contoso-package2-096bffb5-5d3d-4305-a66a-953372ed6e88"), + // Properties: &armtestbase.TestSummaryProperties{ + // ApplicationName: to.Ptr("contoso-package2"), + // ApplicationVersion: to.Ptr("1.0.0"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // FeatureUpdatesTestSummary: &armtestbase.OSUpdatesTestSummary{ + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSUpdateTestSummaries: []*armtestbase.OSUpdateTestSummary{ + // { + // BuildVersion: to.Ptr("513"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSName: to.Ptr("Windows 10 1909"), + // ReleaseName: to.Ptr("2020.12.B"), + // TestRunTime: to.Ptr("00:43:21"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("OutOfBoxTest"), + // }, + // { + // BuildVersion: to.Ptr("765"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSName: to.Ptr("Windows 10 1903"), + // ReleaseName: to.Ptr("2020.11.B"), + // TestRunTime: to.Ptr("00:13:28"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("OutOfBoxTest"), + // }, + // { + // BuildVersion: to.Ptr("313"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSName: to.Ptr("Windows 10 1809"), + // ReleaseName: to.Ptr("2020.11.B"), + // TestRunTime: to.Ptr("00:42:08"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("OutOfBoxTest"), + // }}, + // TestRunTime: to.Ptr("00:33:21"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // }, + // Grade: to.Ptr(armtestbase.GradePass), + // PackageID: to.Ptr("b5ed1bcc-e74c-40d8-82f2-1773f616f93e"), + // SecurityUpdatesTestSummary: &armtestbase.OSUpdatesTestSummary{ + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSUpdateTestSummaries: []*armtestbase.OSUpdateTestSummary{ + // { + // BuildVersion: to.Ptr("513"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSName: to.Ptr("Windows 10 1909"), + // ReleaseName: to.Ptr("2020.12.B"), + // TestRunTime: to.Ptr("00:43:21"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("OutOfBoxTest"), + // }, + // { + // BuildVersion: to.Ptr("765"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSName: to.Ptr("Windows 10 1903"), + // ReleaseName: to.Ptr("2020.11.B"), + // TestRunTime: to.Ptr("00:13:28"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("OutOfBoxTest"), + // }, + // { + // BuildVersion: to.Ptr("313"), + // ExecutionStatus: to.Ptr(armtestbase.ExecutionStatusSucceeded), + // Grade: to.Ptr(armtestbase.GradePass), + // OSName: to.Ptr("Windows 10 1809"), + // ReleaseName: to.Ptr("2020.11.B"), + // TestRunTime: to.Ptr("00:42:08"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestType: to.Ptr("OutOfBoxTest"), + // }}, + // TestRunTime: to.Ptr("00:43:21"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // }, + // TestRunTime: to.Ptr("00:43:21"), + // TestStatus: to.Ptr(armtestbase.TestStatusCompleted), + // TestSummaryID: to.Ptr("096bffb5-5d3d-4305-a66a-953372ed6e88"), + // }, + // } +} diff --git a/sdk/resourcemanager/testbase/armtestbase/zz_generated_testtypes_client.go b/sdk/resourcemanager/testbase/armtestbase/testtypes_client.go similarity index 81% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_testtypes_client.go rename to sdk/resourcemanager/testbase/armtestbase/testtypes_client.go index aa6b582cdafd..778781d1f0aa 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_testtypes_client.go +++ b/sdk/resourcemanager/testbase/armtestbase/testtypes_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 armtestbase @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // TestTypesClient contains the methods for the TestTypes group. // Don't use this type directly, use NewTestTypesClient() instead. type TestTypesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewTestTypesClient creates a new instance of TestTypesClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewTestTypesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TestTypesClient, 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+".TestTypesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &TestTypesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets a test type of a Test Base Account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// testTypeResourceName - The resource name of a test type. -// options - TestTypesClientGetOptions contains the optional parameters for the TestTypesClient.Get method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - testTypeResourceName - The resource name of a test type. +// - options - TestTypesClientGetOptions contains the optional parameters for the TestTypesClient.Get method. func (client *TestTypesClient) Get(ctx context.Context, resourceGroupName string, testBaseAccountName string, testTypeResourceName string, options *TestTypesClientGetOptions) (TestTypesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, testBaseAccountName, testTypeResourceName, options) if err != nil { return TestTypesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TestTypesClientGetResponse{}, err } @@ -95,7 +86,7 @@ func (client *TestTypesClient) getCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter testTypeResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testTypeResourceName}", url.PathEscape(testTypeResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -116,11 +107,11 @@ func (client *TestTypesClient) getHandleResponse(resp *http.Response) (TestTypes } // NewListPager - Lists all the test types of a Test Base Account. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// options - TestTypesClientListOptions contains the optional parameters for the TestTypesClient.List method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - options - TestTypesClientListOptions contains the optional parameters for the TestTypesClient.NewListPager method. func (client *TestTypesClient) NewListPager(resourceGroupName string, testBaseAccountName string, options *TestTypesClientListOptions) *runtime.Pager[TestTypesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[TestTypesClientListResponse]{ More: func(page TestTypesClientListResponse) bool { @@ -137,7 +128,7 @@ func (client *TestTypesClient) NewListPager(resourceGroupName string, testBaseAc if err != nil { return TestTypesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TestTypesClientListResponse{}, err } @@ -164,7 +155,7 @@ func (client *TestTypesClient) listCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter testBaseAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testBaseAccountName}", url.PathEscape(testBaseAccountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/testbase/armtestbase/testtypes_client_example_test.go b/sdk/resourcemanager/testbase/armtestbase/testtypes_client_example_test.go new file mode 100644 index 000000000000..d1dd06fa1a1f --- /dev/null +++ b/sdk/resourcemanager/testbase/armtestbase/testtypes_client_example_test.go @@ -0,0 +1,90 @@ +//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 armtestbase_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestTypesList.json +func ExampleTestTypesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewTestTypesClient().NewListPager("contoso-rg", "contoso-testBaseAccount", 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.TestTypeListResult = armtestbase.TestTypeListResult{ + // Value: []*armtestbase.TestTypeResource{ + // { + // Name: to.Ptr("Functional-Test"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/testTypes"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount/testTypes/Functional-Test"), + // Properties: &armtestbase.TestTypeProperties{ + // ActualTestTypeName: to.Ptr("Functional Test"), + // }, + // }, + // { + // Name: to.Ptr("Out-of-Box-Test"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/testTypes"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount/testTypes/Out-of-Box-Test"), + // Properties: &armtestbase.TestTypeProperties{ + // ActualTestTypeName: to.Ptr("Out of Box Test"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestTypeGet.json +func ExampleTestTypesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewTestTypesClient().Get(ctx, "contoso-rg", "contoso-testBaseAccount", "Functional-Test", 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.TestTypeResource = armtestbase.TestTypeResource{ + // Name: to.Ptr("Functional-Test"), + // Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/testTypes"), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount/testTypes/Functional-Test"), + // Properties: &armtestbase.TestTypeProperties{ + // ActualTestTypeName: to.Ptr("Functional Test"), + // }, + // } +} diff --git a/sdk/resourcemanager/testbase/armtestbase/zz_generated_time_rfc3339.go b/sdk/resourcemanager/testbase/armtestbase/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/testbase/armtestbase/time_rfc3339.go index 05286d832709..b370d95244c6 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/testbase/armtestbase/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 armtestbase @@ -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/testbase/armtestbase/zz_generated_usage_client.go b/sdk/resourcemanager/testbase/armtestbase/usage_client.go similarity index 77% rename from sdk/resourcemanager/testbase/armtestbase/zz_generated_usage_client.go rename to sdk/resourcemanager/testbase/armtestbase/usage_client.go index cae62fb44a8c..59a6c8152852 100644 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_usage_client.go +++ b/sdk/resourcemanager/testbase/armtestbase/usage_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 armtestbase @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,41 +24,32 @@ import ( // UsageClient contains the methods for the Usage group. // Don't use this type directly, use NewUsageClient() instead. type UsageClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewUsageClient creates a new instance of UsageClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewUsageClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*UsageClient, 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+".UsageClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &UsageClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Lists the usage data of a Test Base Account. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-16-preview -// resourceGroupName - The name of the resource group that contains the resource. -// testBaseAccountName - The resource name of the Test Base Account. -// options - UsageClientListOptions contains the optional parameters for the UsageClient.List method. +// - resourceGroupName - The name of the resource group that contains the resource. +// - testBaseAccountName - The resource name of the Test Base Account. +// - options - UsageClientListOptions contains the optional parameters for the UsageClient.NewListPager method. func (client *UsageClient) NewListPager(resourceGroupName string, testBaseAccountName string, options *UsageClientListOptions) *runtime.Pager[UsageClientListResponse] { return runtime.NewPager(runtime.PagingHandler[UsageClientListResponse]{ More: func(page UsageClientListResponse) bool { @@ -76,7 +66,7 @@ func (client *UsageClient) NewListPager(resourceGroupName string, testBaseAccoun if err != nil { return UsageClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return UsageClientListResponse{}, err } @@ -103,7 +93,7 @@ func (client *UsageClient) listCreateRequest(ctx context.Context, resourceGroupN return nil, errors.New("parameter testBaseAccountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{testBaseAccountName}", url.PathEscape(testBaseAccountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/testbase/armtestbase/usage_client_example_test.go b/sdk/resourcemanager/testbase/armtestbase/usage_client_example_test.go new file mode 100644 index 000000000000..86adca849c9a --- /dev/null +++ b/sdk/resourcemanager/testbase/armtestbase/usage_client_example_test.go @@ -0,0 +1,66 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armtestbase_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestBaseAccountUsagesList.json +func ExampleUsageClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtestbase.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewUsageClient().NewListPager("contoso-rg1", "contoso-testBaseAccount1", &armtestbase.UsageClientListOptions{Filter: 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.AccountUsageDataList = armtestbase.AccountUsageDataList{ + // Value: []*armtestbase.AccountUsageData{ + // { + // Name: &armtestbase.AccountUsageName{ + // LocalizedValue: to.Ptr("contoso-package1-usage"), + // Value: to.Ptr("contoso-package1-usage"), + // }, + // CurrentValue: to.Ptr[int64](7531), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/usages/contoso-package1-usage"), + // Limit: to.Ptr[int64](-1), + // Unit: to.Ptr("Seconds"), + // }, + // { + // Name: &armtestbase.AccountUsageName{ + // LocalizedValue: to.Ptr("contoso-package2-usage"), + // Value: to.Ptr("contoso-package2-usage"), + // }, + // CurrentValue: to.Ptr[int64](3157), + // ID: to.Ptr("/subscriptions/476f61a4-952c-422a-b4db-568a828f35df/resourceGroups/contoso-rg1/providers/Microsoft.TestBase/testBaseAccounts/contoso-testBaseAccount1/usages/contoso-package2-usage"), + // Limit: to.Ptr[int64](-1), + // Unit: to.Ptr("Seconds"), + // }}, + // } + } +} diff --git a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_analysisresults_client_test.go b/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_analysisresults_client_test.go deleted file mode 100644 index 018d1eccc0cd..000000000000 --- a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_analysisresults_client_test.go +++ /dev/null @@ -1,71 +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 armtestbase_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/CPURegressionAnalysisResultsList.json -func ExampleAnalysisResultsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewAnalysisResultsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("contoso-rg1", - "contoso-testBaseAccount1", - "contoso-package2", - "Windows-10-1909-Test-Id", - armtestbase.AnalysisResultTypeCPURegression, - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/CPURegressionAnalysisResultGet.json -func ExampleAnalysisResultsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewAnalysisResultsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - "contoso-package2", - "Windows-10-1909-Test-Id", - armtestbase.AnalysisResultNameCPURegression, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_availableos_client_test.go b/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_availableos_client_test.go deleted file mode 100644 index bc6ce5e10242..000000000000 --- a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_availableos_client_test.go +++ /dev/null @@ -1,67 +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 armtestbase_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/AvailableOSsList.json -func ExampleAvailableOSClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewAvailableOSClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("contoso-rg", - "contoso-testBaseAccount", - armtestbase.OsUpdateTypeSecurityUpdate, - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/AvailableOSGet.json -func ExampleAvailableOSClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewAvailableOSClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "contoso-rg", - "contoso-testBaseAccount", - "Windows-10-2004", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_customerevents_client_test.go b/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_customerevents_client_test.go deleted file mode 100644 index 96c49f1c5d1f..000000000000 --- a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_customerevents_client_test.go +++ /dev/null @@ -1,144 +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 armtestbase_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/testbase/armtestbase" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/CustomerEventsList.json -func ExampleCustomerEventsClient_NewListByTestBaseAccountPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewCustomerEventsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByTestBaseAccountPager("contoso-rg1", - "contoso-testBaseAccount1", - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/CustomerEventCreate.json -func ExampleCustomerEventsClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewCustomerEventsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - "WeeklySummary", - armtestbase.CustomerEventResource{ - Properties: &armtestbase.CustomerEventProperties{ - EventName: to.Ptr("WeeklySummary"), - Receivers: []*armtestbase.NotificationEventReceiver{ - { - ReceiverType: to.Ptr("UserObjects"), - ReceiverValue: &armtestbase.NotificationReceiverValue{ - UserObjectReceiverValue: &armtestbase.UserObjectReceiverValue{ - UserObjectIDs: []*string{ - to.Ptr("245245245245325"), - to.Ptr("365365365363565")}, - }, - }, - }, - { - ReceiverType: to.Ptr("DistributionGroup"), - ReceiverValue: &armtestbase.NotificationReceiverValue{ - DistributionGroupListReceiverValue: &armtestbase.DistributionGroupListReceiverValue{ - DistributionGroups: []*string{ - to.Ptr("test@microsoft.com")}, - }, - }, - }}, - }, - }, - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/CustomerEventDelete.json -func ExampleCustomerEventsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewCustomerEventsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - "WeeklySummary", - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/CustomerEventGet.json -func ExampleCustomerEventsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewCustomerEventsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - "WeeklySummary", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_emailevents_client_test.go b/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_emailevents_client_test.go deleted file mode 100644 index dbd6e743924a..000000000000 --- a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_emailevents_client_test.go +++ /dev/null @@ -1,66 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armtestbase_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/EmailEventsList.json -func ExampleEmailEventsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewEmailEventsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("contoso-rg", - "contoso-testBaseAccount", - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/EmailEventGet.json -func ExampleEmailEventsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewEmailEventsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "contoso-rg", - "contoso-testBaseAccount", - "weekly-summary", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_favoriteprocesses_client_test.go b/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_favoriteprocesses_client_test.go deleted file mode 100644 index e6e42f5ed704..000000000000 --- a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_favoriteprocesses_client_test.go +++ /dev/null @@ -1,120 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armtestbase_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/testbase/armtestbase" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/FavoriteProcessesList.json -func ExampleFavoriteProcessesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewFavoriteProcessesClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("contoso-rg1", - "contoso-testBaseAccount1", - "contoso-package2", - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/FavoriteProcessCreate.json -func ExampleFavoriteProcessesClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewFavoriteProcessesClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - "contoso-package2", - "testAppProcess", - armtestbase.FavoriteProcessResource{ - Properties: &armtestbase.FavoriteProcessProperties{ - ActualProcessName: to.Ptr("testApp&.exe"), - }, - }, - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/FavoriteProcessDelete.json -func ExampleFavoriteProcessesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewFavoriteProcessesClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - "contoso-package2", - "testAppProcess", - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/FavoriteProcessGet.json -func ExampleFavoriteProcessesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewFavoriteProcessesClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - "contoso-package2", - "testAppProcess", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_flightingrings_client_test.go b/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_flightingrings_client_test.go deleted file mode 100644 index 78bd2e612882..000000000000 --- a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_flightingrings_client_test.go +++ /dev/null @@ -1,66 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armtestbase_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/FlightingRingsList.json -func ExampleFlightingRingsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewFlightingRingsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("contoso-rg", - "contoso-testBaseAccount", - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/FlightingRingGet.json -func ExampleFlightingRingsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewFlightingRingsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "contoso-rg", - "contoso-testBaseAccount", - "Insider-Beta-Channel", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_operations_client_test.go deleted file mode 100644 index 452bf04e4d08..000000000000 --- a/sdk/resourcemanager/testbase/armtestbase/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 armtestbase_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/OperationsList.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.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/testbase/armtestbase/ze_generated_example_osupdates_client_test.go b/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_osupdates_client_test.go deleted file mode 100644 index 9fbd9620dd51..000000000000 --- a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_osupdates_client_test.go +++ /dev/null @@ -1,69 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armtestbase_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/OSUpdatesList.json -func ExampleOSUpdatesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewOSUpdatesClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("contoso-rg1", - "contoso-testBaseAccount1", - "contoso-package2", - armtestbase.OsUpdateTypeSecurityUpdate, - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/OSUpdateGet.json -func ExampleOSUpdatesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewOSUpdatesClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - "contoso-package2", - "Windows-10-2004-2020-12-B-505", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_packages_client_test.go b/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_packages_client_test.go deleted file mode 100644 index 1101df0c3bd8..000000000000 --- a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_packages_client_test.go +++ /dev/null @@ -1,334 +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 armtestbase_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/testbase/armtestbase" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/PackagesList.json -func ExamplePackagesClient_NewListByTestBaseAccountPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewPackagesClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByTestBaseAccountPager("contoso-rg1", - "contoso-testBaseAccount1", - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/PackageCreate.json -func ExamplePackagesClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewPackagesClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - "contoso-package2", - armtestbase.PackageResource{ - Location: to.Ptr("westus"), - Tags: map[string]*string{}, - Properties: &armtestbase.PackageProperties{ - ApplicationName: to.Ptr("contoso-package2"), - BlobPath: to.Ptr("storageAccountPath/package.zip"), - FlightingRing: to.Ptr("Insider Beta Channel"), - TargetOSList: []*armtestbase.TargetOSInfo{ - { - OSUpdateType: to.Ptr("Security updates"), - TargetOSs: []*string{ - to.Ptr("Windows 10 2004"), - to.Ptr("Windows 10 1903")}, - }}, - Tests: []*armtestbase.Test{ - { - IsActive: to.Ptr(true), - TestType: to.Ptr(armtestbase.TestTypeOutOfBoxTest), - Commands: []*armtestbase.Command{ - { - Name: to.Ptr("Install"), - Action: to.Ptr(armtestbase.ActionInstall), - AlwaysRun: to.Ptr(true), - ApplyUpdateBefore: to.Ptr(false), - Content: to.Ptr("app/scripts/install/job.ps1"), - ContentType: to.Ptr(armtestbase.ContentTypePath), - MaxRunTime: to.Ptr[int32](1800), - RestartAfter: to.Ptr(true), - RunAsInteractive: to.Ptr(true), - RunElevated: to.Ptr(true), - }, - { - Name: to.Ptr("Launch"), - Action: to.Ptr(armtestbase.ActionLaunch), - AlwaysRun: to.Ptr(false), - ApplyUpdateBefore: to.Ptr(true), - Content: to.Ptr("app/scripts/launch/job.ps1"), - ContentType: to.Ptr(armtestbase.ContentTypePath), - MaxRunTime: to.Ptr[int32](1800), - RestartAfter: to.Ptr(false), - RunAsInteractive: to.Ptr(true), - RunElevated: to.Ptr(true), - }, - { - Name: to.Ptr("Close"), - Action: to.Ptr(armtestbase.ActionClose), - AlwaysRun: to.Ptr(false), - ApplyUpdateBefore: to.Ptr(false), - Content: to.Ptr("app/scripts/close/job.ps1"), - ContentType: to.Ptr(armtestbase.ContentTypePath), - MaxRunTime: to.Ptr[int32](1800), - RestartAfter: to.Ptr(false), - RunAsInteractive: to.Ptr(true), - RunElevated: to.Ptr(true), - }, - { - Name: to.Ptr("Uninstall"), - Action: to.Ptr(armtestbase.ActionUninstall), - AlwaysRun: to.Ptr(true), - ApplyUpdateBefore: to.Ptr(false), - Content: to.Ptr("app/scripts/uninstall/job.ps1"), - ContentType: to.Ptr(armtestbase.ContentTypePath), - MaxRunTime: to.Ptr[int32](1800), - RestartAfter: to.Ptr(false), - RunAsInteractive: to.Ptr(true), - RunElevated: to.Ptr(true), - }}, - }}, - Version: to.Ptr("1.0.0"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/PackageUpdate.json -func ExamplePackagesClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewPackagesClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - "contoso-package2", - armtestbase.PackageUpdateParameters{ - Properties: &armtestbase.PackageUpdateParameterProperties{ - BlobPath: to.Ptr("storageAccountPath/package.zip"), - FlightingRing: to.Ptr("Insider Beta Channel"), - IsEnabled: to.Ptr(false), - TargetOSList: []*armtestbase.TargetOSInfo{ - { - OSUpdateType: to.Ptr("Security updates"), - TargetOSs: []*string{ - to.Ptr("Windows 10 2004"), - to.Ptr("Windows 10 1903")}, - }}, - Tests: []*armtestbase.Test{ - { - IsActive: to.Ptr(true), - TestType: to.Ptr(armtestbase.TestTypeOutOfBoxTest), - Commands: []*armtestbase.Command{ - { - Name: to.Ptr("Install"), - Action: to.Ptr(armtestbase.ActionInstall), - AlwaysRun: to.Ptr(true), - ApplyUpdateBefore: to.Ptr(false), - Content: to.Ptr("app/scripts/install/job.ps1"), - ContentType: to.Ptr(armtestbase.ContentTypePath), - MaxRunTime: to.Ptr[int32](1800), - RestartAfter: to.Ptr(true), - RunAsInteractive: to.Ptr(true), - RunElevated: to.Ptr(true), - }, - { - Name: to.Ptr("Launch"), - Action: to.Ptr(armtestbase.ActionLaunch), - AlwaysRun: to.Ptr(false), - ApplyUpdateBefore: to.Ptr(true), - Content: to.Ptr("app/scripts/launch/job.ps1"), - ContentType: to.Ptr(armtestbase.ContentTypePath), - MaxRunTime: to.Ptr[int32](1800), - RestartAfter: to.Ptr(false), - RunAsInteractive: to.Ptr(true), - RunElevated: to.Ptr(true), - }, - { - Name: to.Ptr("Close"), - Action: to.Ptr(armtestbase.ActionClose), - AlwaysRun: to.Ptr(false), - ApplyUpdateBefore: to.Ptr(false), - Content: to.Ptr("app/scripts/close/job.ps1"), - ContentType: to.Ptr(armtestbase.ContentTypePath), - MaxRunTime: to.Ptr[int32](1800), - RestartAfter: to.Ptr(false), - RunAsInteractive: to.Ptr(true), - RunElevated: to.Ptr(true), - }, - { - Name: to.Ptr("Uninstall"), - Action: to.Ptr(armtestbase.ActionUninstall), - AlwaysRun: to.Ptr(true), - ApplyUpdateBefore: to.Ptr(false), - Content: to.Ptr("app/scripts/uninstall/job.ps1"), - ContentType: to.Ptr(armtestbase.ContentTypePath), - MaxRunTime: to.Ptr[int32](1800), - RestartAfter: to.Ptr(false), - RunAsInteractive: to.Ptr(true), - RunElevated: to.Ptr(true), - }}, - }}, - }, - Tags: map[string]*string{}, - }, - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/PackageDelete.json -func ExamplePackagesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewPackagesClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - "contoso-package2", - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/PackageGet.json -func ExamplePackagesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewPackagesClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - "contoso-package2", - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/PackageHardDelete.json -func ExamplePackagesClient_BeginHardDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewPackagesClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginHardDelete(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - "contoso-package2", - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/PackageGetDownloadURL.json -func ExamplePackagesClient_GetDownloadURL() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewPackagesClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetDownloadURL(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - "contoso-package2", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_skus_client_test.go b/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_skus_client_test.go deleted file mode 100644 index 4b66a2651cfd..000000000000 --- a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_skus_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 armtestbase_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestBaseAccountSKUsList.json -func ExampleSKUsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewSKUsClient("476f61a4-952c-422a-b4db-568a828f35df", 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/testbase/armtestbase/ze_generated_example_testbaseaccounts_client_test.go b/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_testbaseaccounts_client_test.go deleted file mode 100644 index 7df140b10c53..000000000000 --- a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_testbaseaccounts_client_test.go +++ /dev/null @@ -1,234 +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 armtestbase_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/testbase/armtestbase" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestBaseAccountsListBySubscription.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 := armtestbase.NewAccountsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(&armtestbase.AccountsClientListBySubscriptionOptions{GetDeleted: 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestBaseAccountsList.json -func ExampleAccountsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewAccountsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("contoso-rg1", - &armtestbase.AccountsClientListByResourceGroupOptions{GetDeleted: 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestBaseAccountCreate.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 := armtestbase.NewAccountsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - armtestbase.AccountResource{ - Location: to.Ptr("westus"), - Properties: &armtestbase.AccountResourceProperties{ - SKU: &armtestbase.AccountSKU{ - Name: to.Ptr("S0"), - Tier: to.Ptr(armtestbase.TierStandard), - }, - }, - }, - &armtestbase.AccountsClientBeginCreateOptions{Restore: 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestBaseAccountUpdate.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 := armtestbase.NewAccountsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - armtestbase.AccountUpdateParameters{ - Properties: &armtestbase.AccountUpdateParameterProperties{ - SKU: &armtestbase.AccountSKU{ - Name: to.Ptr("S0"), - Tier: to.Ptr(armtestbase.TierStandard), - }, - }, - }, - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestBaseAccountDelete.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 := armtestbase.NewAccountsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestBaseAccountGet.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 := armtestbase.NewAccountsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestBaseAccountOffboard.json -func ExampleAccountsClient_BeginOffboard() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewAccountsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginOffboard(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/CheckPackageNameAvailability.json -func ExampleAccountsClient_CheckPackageNameAvailability() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewAccountsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CheckPackageNameAvailability(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - armtestbase.PackageCheckNameAvailabilityParameters{ - Name: to.Ptr("testApp"), - Type: to.Ptr("Microsoft.TestBase/testBaseAccounts/packages"), - ApplicationName: to.Ptr("testApp"), - Version: to.Ptr("1.0.0"), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_testresults_client_test.go b/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_testresults_client_test.go deleted file mode 100644 index 96e6fe97e25d..000000000000 --- a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_testresults_client_test.go +++ /dev/null @@ -1,118 +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 armtestbase_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/testbase/armtestbase" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestResultsList.json -func ExampleTestResultsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewTestResultsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("contoso-rg1", - "contoso-testBaseAccount1", - "contoso-package2", - armtestbase.OsUpdateTypeSecurityUpdate, - &armtestbase.TestResultsClientListOptions{Filter: to.Ptr("osName eq 'Windows 10 2004' and releaseName eq '2020.11B'")}) - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestResultGet.json -func ExampleTestResultsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewTestResultsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - "contoso-package2", - "Windows-10-1909-99b1f80d-03a9-4148-997f-806ba5bac8e0", - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestResultGetDownloadURL.json -func ExampleTestResultsClient_GetDownloadURL() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewTestResultsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetDownloadURL(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - "contoso-package2", - "Windows-10-1909-99b1f80d-03a9-4148-997f-806ba5bac8e0", - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestResultGetVideoDownloadURL.json -func ExampleTestResultsClient_GetVideoDownloadURL() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewTestResultsClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetVideoDownloadURL(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - "contoso-package2", - "Windows-10-1909-99b1f80d-03a9-4148-997f-806ba5bac8e0", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_testsummaries_client_test.go b/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_testsummaries_client_test.go deleted file mode 100644 index 30c55eac21e3..000000000000 --- a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_testsummaries_client_test.go +++ /dev/null @@ -1,66 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armtestbase_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestSummariesList.json -func ExampleTestSummariesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewTestSummariesClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("contoso-rg1", - "contoso-testBaseAccount1", - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestSummaryGet.json -func ExampleTestSummariesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewTestSummariesClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "contoso-rg1", - "contoso-testBaseAccount1", - "contoso-package2-096bffb5-5d3d-4305-a66a-953372ed6e88", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_testtypes_client_test.go b/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_testtypes_client_test.go deleted file mode 100644 index 193c3dfee1cf..000000000000 --- a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_testtypes_client_test.go +++ /dev/null @@ -1,66 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armtestbase_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestTypesList.json -func ExampleTestTypesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewTestTypesClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("contoso-rg", - "contoso-testBaseAccount", - 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/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestTypeGet.json -func ExampleTestTypesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewTestTypesClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "contoso-rg", - "contoso-testBaseAccount", - "Functional-Test", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_usage_client_test.go b/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_usage_client_test.go deleted file mode 100644 index 48648f2ef79f..000000000000 --- a/sdk/resourcemanager/testbase/armtestbase/ze_generated_example_usage_client_test.go +++ /dev/null @@ -1,43 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armtestbase_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/testbase/armtestbase" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/testbase/resource-manager/Microsoft.TestBase/preview/2020-12-16-preview/examples/TestBaseAccountUsagesList.json -func ExampleUsageClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtestbase.NewUsageClient("476f61a4-952c-422a-b4db-568a828f35df", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("contoso-rg1", - "contoso-testBaseAccount1", - &armtestbase.UsageClientListOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/testbase/armtestbase/zz_generated_models_serde.go b/sdk/resourcemanager/testbase/armtestbase/zz_generated_models_serde.go deleted file mode 100644 index e572f0480023..000000000000 --- a/sdk/resourcemanager/testbase/armtestbase/zz_generated_models_serde.go +++ /dev/null @@ -1,917 +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 armtestbase - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type AccountResource. -func (a AccountResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "etag", a.Etag) - 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 AccountSKU. -func (a AccountSKU) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "capabilities", a.Capabilities) - populate(objectMap, "locations", a.Locations) - populate(objectMap, "name", a.Name) - populate(objectMap, "resourceType", a.ResourceType) - populate(objectMap, "tier", a.Tier) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type AccountUpdateParameters. -func (a AccountUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "properties", a.Properties) - populate(objectMap, "tags", a.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type AnalysisResultSingletonResource. -func (a AnalysisResultSingletonResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", a.ID) - populate(objectMap, "name", a.Name) - populate(objectMap, "properties", a.Properties) - populate(objectMap, "systemData", a.SystemData) - populate(objectMap, "type", a.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AnalysisResultSingletonResource. -func (a *AnalysisResultSingletonResource) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &a.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &a.Name) - delete(rawMsg, key) - case "properties": - a.Properties, err = unmarshalAnalysisResultSingletonResourcePropertiesClassification(val) - delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &a.SystemData) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &a.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type CPURegressionResultSingletonResourceProperties. -func (c CPURegressionResultSingletonResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["analysisResultType"] = AnalysisResultTypeCPURegression - populate(objectMap, "cpuRegressionResults", c.CPURegressionResults) - populate(objectMap, "grade", c.Grade) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type CPURegressionResultSingletonResourceProperties. -func (c *CPURegressionResultSingletonResourceProperties) UnmarshalJSON(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 "analysisResultType": - err = unpopulate(val, "AnalysisResultType", &c.AnalysisResultType) - delete(rawMsg, key) - case "cpuRegressionResults": - err = unpopulate(val, "CPURegressionResults", &c.CPURegressionResults) - delete(rawMsg, key) - case "grade": - err = unpopulate(val, "Grade", &c.Grade) - 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 CPUUtilizationResultSingletonResourceProperties. -func (c CPUUtilizationResultSingletonResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["analysisResultType"] = AnalysisResultTypeCPUUtilization - populate(objectMap, "cpuUtilizationResults", c.CPUUtilizationResults) - populate(objectMap, "grade", c.Grade) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type CPUUtilizationResultSingletonResourceProperties. -func (c *CPUUtilizationResultSingletonResourceProperties) UnmarshalJSON(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 "analysisResultType": - err = unpopulate(val, "AnalysisResultType", &c.AnalysisResultType) - delete(rawMsg, key) - case "cpuUtilizationResults": - err = unpopulate(val, "CPUUtilizationResults", &c.CPUUtilizationResults) - delete(rawMsg, key) - case "grade": - err = unpopulate(val, "Grade", &c.Grade) - 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 CustomerEventProperties. -func (c CustomerEventProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "eventName", c.EventName) - populate(objectMap, "receivers", c.Receivers) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type DistributionGroupListReceiverValue. -func (d DistributionGroupListReceiverValue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "distributionGroups", d.DistributionGroups) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DownloadURLResponse. -func (d *DownloadURLResponse) UnmarshalJSON(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 "downloadUrl": - err = unpopulate(val, "DownloadURL", &d.DownloadURL) - delete(rawMsg, key) - case "expirationTime": - err = unpopulateTimeRFC3339(val, "ExpirationTime", &d.ExpirationTime) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type MemoryRegressionResultSingletonResourceProperties. -func (m MemoryRegressionResultSingletonResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["analysisResultType"] = AnalysisResultTypeMemoryRegression - populate(objectMap, "grade", m.Grade) - populate(objectMap, "memoryRegressionResults", m.MemoryRegressionResults) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type MemoryRegressionResultSingletonResourceProperties. -func (m *MemoryRegressionResultSingletonResourceProperties) UnmarshalJSON(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 "analysisResultType": - err = unpopulate(val, "AnalysisResultType", &m.AnalysisResultType) - delete(rawMsg, key) - case "grade": - err = unpopulate(val, "Grade", &m.Grade) - delete(rawMsg, key) - case "memoryRegressionResults": - err = unpopulate(val, "MemoryRegressionResults", &m.MemoryRegressionResults) - 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 MemoryUtilizationResultSingletonResourceProperties. -func (m MemoryUtilizationResultSingletonResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["analysisResultType"] = AnalysisResultTypeMemoryUtilization - populate(objectMap, "grade", m.Grade) - populate(objectMap, "memoryUtilizationResults", m.MemoryUtilizationResults) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type MemoryUtilizationResultSingletonResourceProperties. -func (m *MemoryUtilizationResultSingletonResourceProperties) UnmarshalJSON(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 "analysisResultType": - err = unpopulate(val, "AnalysisResultType", &m.AnalysisResultType) - delete(rawMsg, key) - case "grade": - err = unpopulate(val, "Grade", &m.Grade) - delete(rawMsg, key) - case "memoryUtilizationResults": - err = unpopulate(val, "MemoryUtilizationResults", &m.MemoryUtilizationResults) - 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 OSUpdateProperties. -func (o OSUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "buildRevision", o.BuildRevision) - populate(objectMap, "buildVersion", o.BuildVersion) - populate(objectMap, "flightingRing", o.FlightingRing) - populate(objectMap, "osName", o.OSName) - populate(objectMap, "release", o.Release) - populateTimeRFC3339(objectMap, "releaseVersionDate", o.ReleaseVersionDate) - populate(objectMap, "type", o.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OSUpdateProperties. -func (o *OSUpdateProperties) UnmarshalJSON(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 "buildRevision": - err = unpopulate(val, "BuildRevision", &o.BuildRevision) - delete(rawMsg, key) - case "buildVersion": - err = unpopulate(val, "BuildVersion", &o.BuildVersion) - delete(rawMsg, key) - case "flightingRing": - err = unpopulate(val, "FlightingRing", &o.FlightingRing) - delete(rawMsg, key) - case "osName": - err = unpopulate(val, "OSName", &o.OSName) - delete(rawMsg, key) - case "release": - err = unpopulate(val, "Release", &o.Release) - delete(rawMsg, key) - case "releaseVersionDate": - err = unpopulateTimeRFC3339(val, "ReleaseVersionDate", &o.ReleaseVersionDate) - 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 OSUpdateTestSummary. -func (o OSUpdateTestSummary) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "buildRevision", o.BuildRevision) - populate(objectMap, "buildVersion", o.BuildVersion) - populate(objectMap, "executionStatus", o.ExecutionStatus) - populate(objectMap, "flightingRing", o.FlightingRing) - populate(objectMap, "grade", o.Grade) - populate(objectMap, "osName", o.OSName) - populate(objectMap, "releaseName", o.ReleaseName) - populateTimeRFC3339(objectMap, "releaseVersionDate", o.ReleaseVersionDate) - populate(objectMap, "testRunTime", o.TestRunTime) - populate(objectMap, "testStatus", o.TestStatus) - populate(objectMap, "testType", o.TestType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OSUpdateTestSummary. -func (o *OSUpdateTestSummary) UnmarshalJSON(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 "buildRevision": - err = unpopulate(val, "BuildRevision", &o.BuildRevision) - delete(rawMsg, key) - case "buildVersion": - err = unpopulate(val, "BuildVersion", &o.BuildVersion) - delete(rawMsg, key) - case "executionStatus": - err = unpopulate(val, "ExecutionStatus", &o.ExecutionStatus) - delete(rawMsg, key) - case "flightingRing": - err = unpopulate(val, "FlightingRing", &o.FlightingRing) - delete(rawMsg, key) - case "grade": - err = unpopulate(val, "Grade", &o.Grade) - delete(rawMsg, key) - case "osName": - err = unpopulate(val, "OSName", &o.OSName) - delete(rawMsg, key) - case "releaseName": - err = unpopulate(val, "ReleaseName", &o.ReleaseName) - delete(rawMsg, key) - case "releaseVersionDate": - err = unpopulateTimeRFC3339(val, "ReleaseVersionDate", &o.ReleaseVersionDate) - delete(rawMsg, key) - case "testRunTime": - err = unpopulate(val, "TestRunTime", &o.TestRunTime) - delete(rawMsg, key) - case "testStatus": - err = unpopulate(val, "TestStatus", &o.TestStatus) - delete(rawMsg, key) - case "testType": - err = unpopulate(val, "TestType", &o.TestType) - 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 OSUpdatesTestSummary. -func (o OSUpdatesTestSummary) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "executionStatus", o.ExecutionStatus) - populate(objectMap, "grade", o.Grade) - populate(objectMap, "osUpdateTestSummaries", o.OSUpdateTestSummaries) - populate(objectMap, "testRunTime", o.TestRunTime) - populate(objectMap, "testStatus", o.TestStatus) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type PackageProperties. -func (p PackageProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "applicationName", p.ApplicationName) - populate(objectMap, "blobPath", p.BlobPath) - populate(objectMap, "flightingRing", p.FlightingRing) - populate(objectMap, "isEnabled", p.IsEnabled) - populateTimeRFC3339(objectMap, "lastModifiedTime", p.LastModifiedTime) - populate(objectMap, "packageStatus", p.PackageStatus) - populate(objectMap, "provisioningState", p.ProvisioningState) - populate(objectMap, "targetOSList", p.TargetOSList) - populate(objectMap, "testTypes", p.TestTypes) - populate(objectMap, "tests", p.Tests) - populate(objectMap, "validationResults", p.ValidationResults) - populate(objectMap, "version", p.Version) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type PackageProperties. -func (p *PackageProperties) UnmarshalJSON(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 "applicationName": - err = unpopulate(val, "ApplicationName", &p.ApplicationName) - delete(rawMsg, key) - case "blobPath": - err = unpopulate(val, "BlobPath", &p.BlobPath) - delete(rawMsg, key) - case "flightingRing": - err = unpopulate(val, "FlightingRing", &p.FlightingRing) - delete(rawMsg, key) - case "isEnabled": - err = unpopulate(val, "IsEnabled", &p.IsEnabled) - delete(rawMsg, key) - case "lastModifiedTime": - err = unpopulateTimeRFC3339(val, "LastModifiedTime", &p.LastModifiedTime) - delete(rawMsg, key) - case "packageStatus": - err = unpopulate(val, "PackageStatus", &p.PackageStatus) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) - delete(rawMsg, key) - case "targetOSList": - err = unpopulate(val, "TargetOSList", &p.TargetOSList) - delete(rawMsg, key) - case "testTypes": - err = unpopulate(val, "TestTypes", &p.TestTypes) - delete(rawMsg, key) - case "tests": - err = unpopulate(val, "Tests", &p.Tests) - delete(rawMsg, key) - case "validationResults": - err = unpopulate(val, "ValidationResults", &p.ValidationResults) - delete(rawMsg, key) - case "version": - err = unpopulate(val, "Version", &p.Version) - 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 PackageResource. -func (p PackageResource) 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, "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 PackageUpdateParameterProperties. -func (p PackageUpdateParameterProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "blobPath", p.BlobPath) - populate(objectMap, "flightingRing", p.FlightingRing) - populate(objectMap, "isEnabled", p.IsEnabled) - populate(objectMap, "targetOSList", p.TargetOSList) - populate(objectMap, "tests", p.Tests) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type PackageUpdateParameters. -func (p PackageUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "properties", p.Properties) - populate(objectMap, "tags", p.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type PackageValidationResult. -func (p PackageValidationResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "errors", p.Errors) - populate(objectMap, "isValid", p.IsValid) - populate(objectMap, "validationName", p.ValidationName) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ReliabilityResultSingletonResourceProperties. -func (r ReliabilityResultSingletonResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["analysisResultType"] = AnalysisResultTypeReliability - populate(objectMap, "grade", r.Grade) - populate(objectMap, "reliabilityResults", r.ReliabilityResults) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ReliabilityResultSingletonResourceProperties. -func (r *ReliabilityResultSingletonResourceProperties) UnmarshalJSON(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 "analysisResultType": - err = unpopulate(val, "AnalysisResultType", &r.AnalysisResultType) - delete(rawMsg, key) - case "grade": - err = unpopulate(val, "Grade", &r.Grade) - delete(rawMsg, key) - case "reliabilityResults": - err = unpopulate(val, "ReliabilityResults", &r.ReliabilityResults) - 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 ScriptExecutionResult. -func (s ScriptExecutionResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "endTime", s.EndTime) - populate(objectMap, "exitCode", s.ExitCode) - populate(objectMap, "scriptName", s.ScriptName) - populateTimeRFC3339(objectMap, "startTime", s.StartTime) - populate(objectMap, "timedOut", s.TimedOut) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ScriptExecutionResult. -func (s *ScriptExecutionResult) UnmarshalJSON(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 "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &s.EndTime) - delete(rawMsg, key) - case "exitCode": - err = unpopulate(val, "ExitCode", &s.ExitCode) - delete(rawMsg, key) - case "scriptName": - err = unpopulate(val, "ScriptName", &s.ScriptName) - delete(rawMsg, key) - case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &s.StartTime) - delete(rawMsg, key) - case "timedOut": - err = unpopulate(val, "TimedOut", &s.TimedOut) - 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 ScriptExecutionResultSingletonResourceProperties. -func (s ScriptExecutionResultSingletonResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["analysisResultType"] = AnalysisResultTypeScriptExecution - populate(objectMap, "grade", s.Grade) - populate(objectMap, "scriptExecutionResults", s.ScriptExecutionResults) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ScriptExecutionResultSingletonResourceProperties. -func (s *ScriptExecutionResultSingletonResourceProperties) UnmarshalJSON(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 "analysisResultType": - err = unpopulate(val, "AnalysisResultType", &s.AnalysisResultType) - delete(rawMsg, key) - case "grade": - err = unpopulate(val, "Grade", &s.Grade) - delete(rawMsg, key) - case "scriptExecutionResults": - err = unpopulate(val, "ScriptExecutionResults", &s.ScriptExecutionResults) - 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 TargetOSInfo. -func (t TargetOSInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "osUpdateType", t.OSUpdateType) - populate(objectMap, "targetOSs", t.TargetOSs) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type Test. -func (t Test) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "commands", t.Commands) - populate(objectMap, "isActive", t.IsActive) - populate(objectMap, "testType", t.TestType) - populate(objectMap, "validationRunStatus", t.ValidationRunStatus) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type TestAnalysisResult. -func (t TestAnalysisResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "blobData", t.BlobData) - populate(objectMap, "identifiedFailures", t.IdentifiedFailures) - populate(objectMap, "testAnalysisStatus", t.TestAnalysisStatus) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type TestAnalysisResultSingletonResourceProperties. -func (t TestAnalysisResultSingletonResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["analysisResultType"] = AnalysisResultTypeTestAnalysis - populate(objectMap, "grade", t.Grade) - populate(objectMap, "testAnalysisResult", t.TestAnalysisResult) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type TestAnalysisResultSingletonResourceProperties. -func (t *TestAnalysisResultSingletonResourceProperties) UnmarshalJSON(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 "analysisResultType": - err = unpopulate(val, "AnalysisResultType", &t.AnalysisResultType) - delete(rawMsg, key) - case "grade": - err = unpopulate(val, "Grade", &t.Grade) - delete(rawMsg, key) - case "testAnalysisResult": - err = unpopulate(val, "TestAnalysisResult", &t.TestAnalysisResult) - 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 TestResultProperties. -func (t TestResultProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "analysisSummaries", t.AnalysisSummaries) - populate(objectMap, "applicationName", t.ApplicationName) - populate(objectMap, "applicationVersion", t.ApplicationVersion) - populate(objectMap, "baselineTestResultId", t.BaselineTestResultID) - populate(objectMap, "buildRevision", t.BuildRevision) - populate(objectMap, "buildVersion", t.BuildVersion) - populate(objectMap, "executionStatus", t.ExecutionStatus) - populate(objectMap, "flightingRing", t.FlightingRing) - populate(objectMap, "grade", t.Grade) - populate(objectMap, "isDownloadDataAvailable", t.IsDownloadDataAvailable) - populate(objectMap, "isVideoAvailable", t.IsVideoAvailable) - populate(objectMap, "kbNumber", t.KbNumber) - populate(objectMap, "osName", t.OSName) - populate(objectMap, "packageId", t.PackageID) - populate(objectMap, "packageVersion", t.PackageVersion) - populate(objectMap, "releaseName", t.ReleaseName) - populateTimeRFC3339(objectMap, "releaseVersionDate", t.ReleaseVersionDate) - populate(objectMap, "testRunTime", t.TestRunTime) - populate(objectMap, "testStatus", t.TestStatus) - populate(objectMap, "testType", t.TestType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type TestResultProperties. -func (t *TestResultProperties) UnmarshalJSON(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 "analysisSummaries": - err = unpopulate(val, "AnalysisSummaries", &t.AnalysisSummaries) - delete(rawMsg, key) - case "applicationName": - err = unpopulate(val, "ApplicationName", &t.ApplicationName) - delete(rawMsg, key) - case "applicationVersion": - err = unpopulate(val, "ApplicationVersion", &t.ApplicationVersion) - delete(rawMsg, key) - case "baselineTestResultId": - err = unpopulate(val, "BaselineTestResultID", &t.BaselineTestResultID) - delete(rawMsg, key) - case "buildRevision": - err = unpopulate(val, "BuildRevision", &t.BuildRevision) - delete(rawMsg, key) - case "buildVersion": - err = unpopulate(val, "BuildVersion", &t.BuildVersion) - delete(rawMsg, key) - case "executionStatus": - err = unpopulate(val, "ExecutionStatus", &t.ExecutionStatus) - delete(rawMsg, key) - case "flightingRing": - err = unpopulate(val, "FlightingRing", &t.FlightingRing) - delete(rawMsg, key) - case "grade": - err = unpopulate(val, "Grade", &t.Grade) - delete(rawMsg, key) - case "isDownloadDataAvailable": - err = unpopulate(val, "IsDownloadDataAvailable", &t.IsDownloadDataAvailable) - delete(rawMsg, key) - case "isVideoAvailable": - err = unpopulate(val, "IsVideoAvailable", &t.IsVideoAvailable) - delete(rawMsg, key) - case "kbNumber": - err = unpopulate(val, "KbNumber", &t.KbNumber) - delete(rawMsg, key) - case "osName": - err = unpopulate(val, "OSName", &t.OSName) - delete(rawMsg, key) - case "packageId": - err = unpopulate(val, "PackageID", &t.PackageID) - delete(rawMsg, key) - case "packageVersion": - err = unpopulate(val, "PackageVersion", &t.PackageVersion) - delete(rawMsg, key) - case "releaseName": - err = unpopulate(val, "ReleaseName", &t.ReleaseName) - delete(rawMsg, key) - case "releaseVersionDate": - err = unpopulateTimeRFC3339(val, "ReleaseVersionDate", &t.ReleaseVersionDate) - delete(rawMsg, key) - case "testRunTime": - err = unpopulate(val, "TestRunTime", &t.TestRunTime) - delete(rawMsg, key) - case "testStatus": - err = unpopulate(val, "TestStatus", &t.TestStatus) - delete(rawMsg, key) - case "testType": - err = unpopulate(val, "TestType", &t.TestType) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", t, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type TrackedResource. -func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "etag", t.Etag) - populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) - populate(objectMap, "name", t.Name) - populate(objectMap, "tags", t.Tags) - populate(objectMap, "type", t.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type UserObjectReceiverValue. -func (u UserObjectReceiverValue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "userObjectIds", u.UserObjectIDs) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type UtilizationEntry. -func (u UtilizationEntry) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "timestamp", u.Timestamp) - populate(objectMap, "value", u.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type UtilizationEntry. -func (u *UtilizationEntry) UnmarshalJSON(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 "timestamp": - err = unpopulateTimeRFC3339(val, "Timestamp", &u.Timestamp) - 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 UtilizationResult. -func (u UtilizationResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "lowerBound", u.LowerBound) - populate(objectMap, "process", u.Process) - populate(objectMap, "upperBound", u.UpperBound) - populate(objectMap, "utilization", u.Utilization) - 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/timeseriesinsights/armtimeseriesinsights/CHANGELOG.md b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/CHANGELOG.md index 205e04f9543d..0ebfa698cb27 100644 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/CHANGELOG.md +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2022-06-10) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights` 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/timeseriesinsights/armtimeseriesinsights/README.md b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/README.md index ed9f3385e021..2e4f9a7f360f 100644 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/README.md +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/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 Time Series Insights 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 Time Series Insights 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 := armtimeseriesinsights.NewEventSourcesClient(, cred, nil) +clientFactory, err := armtimeseriesinsights.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 := armtimeseriesinsights.NewEventSourcesClient(, cred, &options) +clientFactory, err := armtimeseriesinsights.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.NewEventSourcesClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_accesspolicies_client.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/accesspolicies_client.go similarity index 83% rename from sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_accesspolicies_client.go rename to sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/accesspolicies_client.go index 353cffafe5ed..dcb410bf26f3 100644 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_accesspolicies_client.go +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/accesspolicies_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 armtimeseriesinsights @@ -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 ( // AccessPoliciesClient contains the methods for the AccessPolicies group. // Don't use this type directly, use NewAccessPoliciesClient() instead. type AccessPoliciesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAccessPoliciesClient creates a new instance of AccessPoliciesClient with the specified values. -// subscriptionID - Azure Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAccessPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AccessPoliciesClient, 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+".AccessPoliciesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AccessPoliciesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or update an access policy in the specified environment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// environmentName - The name of the Time Series Insights environment associated with the specified resource group. -// accessPolicyName - Name of the access policy. -// parameters - Parameters for creating an access policy. -// options - AccessPoliciesClientCreateOrUpdateOptions contains the optional parameters for the AccessPoliciesClient.CreateOrUpdate -// method. +// - resourceGroupName - Name of an Azure Resource group. +// - environmentName - The name of the Time Series Insights environment associated with the specified resource group. +// - accessPolicyName - Name of the access policy. +// - parameters - Parameters for creating an access policy. +// - options - AccessPoliciesClientCreateOrUpdateOptions contains the optional parameters for the AccessPoliciesClient.CreateOrUpdate +// method. func (client *AccessPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, environmentName string, accessPolicyName string, parameters AccessPolicyCreateOrUpdateParameters, options *AccessPoliciesClientCreateOrUpdateOptions) (AccessPoliciesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, environmentName, accessPolicyName, parameters, options) if err != nil { return AccessPoliciesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccessPoliciesClientCreateOrUpdateResponse{}, err } @@ -97,7 +88,7 @@ func (client *AccessPoliciesClient) createOrUpdateCreateRequest(ctx context.Cont return nil, errors.New("parameter accessPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accessPolicyName}", url.PathEscape(accessPolicyName)) - 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 *AccessPoliciesClient) createOrUpdateHandleResponse(resp *http.Resp // Delete - Deletes the access policy with the specified name in the specified subscription, resource group, and environment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// environmentName - The name of the Time Series Insights environment associated with the specified resource group. -// accessPolicyName - The name of the Time Series Insights access policy associated with the specified environment. -// options - AccessPoliciesClientDeleteOptions contains the optional parameters for the AccessPoliciesClient.Delete method. +// - resourceGroupName - Name of an Azure Resource group. +// - environmentName - The name of the Time Series Insights environment associated with the specified resource group. +// - accessPolicyName - The name of the Time Series Insights access policy associated with the specified environment. +// - options - AccessPoliciesClientDeleteOptions contains the optional parameters for the AccessPoliciesClient.Delete method. func (client *AccessPoliciesClient) Delete(ctx context.Context, resourceGroupName string, environmentName string, accessPolicyName string, options *AccessPoliciesClientDeleteOptions) (AccessPoliciesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, environmentName, accessPolicyName, options) if err != nil { return AccessPoliciesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccessPoliciesClientDeleteResponse{}, err } @@ -158,7 +150,7 @@ func (client *AccessPoliciesClient) deleteCreateRequest(ctx context.Context, res return nil, errors.New("parameter accessPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accessPolicyName}", url.PathEscape(accessPolicyName)) - 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 *AccessPoliciesClient) deleteCreateRequest(ctx context.Context, res // Get - Gets the access policy with the specified name in the specified environment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// environmentName - The name of the Time Series Insights environment associated with the specified resource group. -// accessPolicyName - The name of the Time Series Insights access policy associated with the specified environment. -// options - AccessPoliciesClientGetOptions contains the optional parameters for the AccessPoliciesClient.Get method. +// - resourceGroupName - Name of an Azure Resource group. +// - environmentName - The name of the Time Series Insights environment associated with the specified resource group. +// - accessPolicyName - The name of the Time Series Insights access policy associated with the specified environment. +// - options - AccessPoliciesClientGetOptions contains the optional parameters for the AccessPoliciesClient.Get method. func (client *AccessPoliciesClient) Get(ctx context.Context, resourceGroupName string, environmentName string, accessPolicyName string, options *AccessPoliciesClientGetOptions) (AccessPoliciesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, environmentName, accessPolicyName, options) if err != nil { return AccessPoliciesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccessPoliciesClientGetResponse{}, err } @@ -210,7 +203,7 @@ func (client *AccessPoliciesClient) getCreateRequest(ctx context.Context, resour return nil, errors.New("parameter accessPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accessPolicyName}", url.PathEscape(accessPolicyName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -232,17 +225,18 @@ func (client *AccessPoliciesClient) getHandleResponse(resp *http.Response) (Acce // ListByEnvironment - Lists all the available access policies associated with the environment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// environmentName - The name of the Time Series Insights environment associated with the specified resource group. -// options - AccessPoliciesClientListByEnvironmentOptions contains the optional parameters for the AccessPoliciesClient.ListByEnvironment -// method. +// - resourceGroupName - Name of an Azure Resource group. +// - environmentName - The name of the Time Series Insights environment associated with the specified resource group. +// - options - AccessPoliciesClientListByEnvironmentOptions contains the optional parameters for the AccessPoliciesClient.ListByEnvironment +// method. func (client *AccessPoliciesClient) ListByEnvironment(ctx context.Context, resourceGroupName string, environmentName string, options *AccessPoliciesClientListByEnvironmentOptions) (AccessPoliciesClientListByEnvironmentResponse, error) { req, err := client.listByEnvironmentCreateRequest(ctx, resourceGroupName, environmentName, options) if err != nil { return AccessPoliciesClientListByEnvironmentResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccessPoliciesClientListByEnvironmentResponse{}, err } @@ -267,7 +261,7 @@ func (client *AccessPoliciesClient) listByEnvironmentCreateRequest(ctx context.C return nil, errors.New("parameter environmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{environmentName}", url.PathEscape(environmentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -289,18 +283,19 @@ func (client *AccessPoliciesClient) listByEnvironmentHandleResponse(resp *http.R // Update - Updates the access policy with the specified name in the specified subscription, resource group, and environment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// environmentName - The name of the Time Series Insights environment associated with the specified resource group. -// accessPolicyName - The name of the Time Series Insights access policy associated with the specified environment. -// accessPolicyUpdateParameters - Request object that contains the updated information for the access policy. -// options - AccessPoliciesClientUpdateOptions contains the optional parameters for the AccessPoliciesClient.Update method. +// - resourceGroupName - Name of an Azure Resource group. +// - environmentName - The name of the Time Series Insights environment associated with the specified resource group. +// - accessPolicyName - The name of the Time Series Insights access policy associated with the specified environment. +// - accessPolicyUpdateParameters - Request object that contains the updated information for the access policy. +// - options - AccessPoliciesClientUpdateOptions contains the optional parameters for the AccessPoliciesClient.Update method. func (client *AccessPoliciesClient) Update(ctx context.Context, resourceGroupName string, environmentName string, accessPolicyName string, accessPolicyUpdateParameters AccessPolicyUpdateParameters, options *AccessPoliciesClientUpdateOptions) (AccessPoliciesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, environmentName, accessPolicyName, accessPolicyUpdateParameters, options) if err != nil { return AccessPoliciesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccessPoliciesClientUpdateResponse{}, err } @@ -329,7 +324,7 @@ func (client *AccessPoliciesClient) updateCreateRequest(ctx context.Context, res return nil, errors.New("parameter accessPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accessPolicyName}", url.PathEscape(accessPolicyName)) - 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/timeseriesinsights/armtimeseriesinsights/accesspolicies_client_example_test.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/accesspolicies_client_example_test.go new file mode 100644 index 000000000000..80da149e0ddc --- /dev/null +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/accesspolicies_client_example_test.go @@ -0,0 +1,176 @@ +//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 armtimeseriesinsights_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/timeseriesinsights/armtimeseriesinsights" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/AccessPoliciesCreate.json +func ExampleAccessPoliciesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccessPoliciesClient().CreateOrUpdate(ctx, "rg1", "env1", "ap1", armtimeseriesinsights.AccessPolicyCreateOrUpdateParameters{ + Properties: &armtimeseriesinsights.AccessPolicyResourceProperties{ + Description: to.Ptr("some description"), + PrincipalObjectID: to.Ptr("aGuid"), + Roles: []*armtimeseriesinsights.AccessPolicyRole{ + to.Ptr(armtimeseriesinsights.AccessPolicyRoleReader)}, + }, + }, 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.AccessPolicyResource = armtimeseriesinsights.AccessPolicyResource{ + // Name: to.Ptr("ap1"), + // Type: to.Ptr("Microsoft.TimeSeriesInsights/Environments/AccessPolicies"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.TimeSeriesInsights/Environments/env1/accessPolicies/ap1"), + // Properties: &armtimeseriesinsights.AccessPolicyResourceProperties{ + // Description: to.Ptr("some description"), + // PrincipalObjectID: to.Ptr("aGuid"), + // Roles: []*armtimeseriesinsights.AccessPolicyRole{ + // to.Ptr(armtimeseriesinsights.AccessPolicyRoleReader)}, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/AccessPoliciesGet.json +func ExampleAccessPoliciesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccessPoliciesClient().Get(ctx, "rg1", "env1", "ap1", 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.AccessPolicyResource = armtimeseriesinsights.AccessPolicyResource{ + // Name: to.Ptr("ap1"), + // Type: to.Ptr("Microsoft.TimeSeriesInsights/Environments/AccessPolicies"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.TimeSeriesInsights/Environments/env1/accessPolicies/ap1"), + // Properties: &armtimeseriesinsights.AccessPolicyResourceProperties{ + // Description: to.Ptr("some description"), + // PrincipalObjectID: to.Ptr("aGuid"), + // Roles: []*armtimeseriesinsights.AccessPolicyRole{ + // to.Ptr(armtimeseriesinsights.AccessPolicyRoleReader)}, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/AccessPoliciesPatchRoles.json +func ExampleAccessPoliciesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccessPoliciesClient().Update(ctx, "rg1", "env1", "ap1", armtimeseriesinsights.AccessPolicyUpdateParameters{ + Properties: &armtimeseriesinsights.AccessPolicyMutableProperties{ + Roles: []*armtimeseriesinsights.AccessPolicyRole{ + to.Ptr(armtimeseriesinsights.AccessPolicyRoleReader), + to.Ptr(armtimeseriesinsights.AccessPolicyRoleContributor)}, + }, + }, 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.AccessPolicyResource = armtimeseriesinsights.AccessPolicyResource{ + // Name: to.Ptr("ap1"), + // Type: to.Ptr("Microsoft.TimeSeriesInsights/Environments/AccessPolicies"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.TimeSeriesInsights/Environments/env1/accessPolicies/ap1"), + // Properties: &armtimeseriesinsights.AccessPolicyResourceProperties{ + // Description: to.Ptr("some description"), + // PrincipalObjectID: to.Ptr("aGuid"), + // Roles: []*armtimeseriesinsights.AccessPolicyRole{ + // to.Ptr(armtimeseriesinsights.AccessPolicyRoleReader)}, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/AccessPoliciesDelete.json +func ExampleAccessPoliciesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewAccessPoliciesClient().Delete(ctx, "rg1", "env1", "ap1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/AccessPoliciesListByEnvironment.json +func ExampleAccessPoliciesClient_ListByEnvironment() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccessPoliciesClient().ListByEnvironment(ctx, "rg1", "env1", 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.AccessPolicyListResponse = armtimeseriesinsights.AccessPolicyListResponse{ + // Value: []*armtimeseriesinsights.AccessPolicyResource{ + // { + // Name: to.Ptr("ap1"), + // Type: to.Ptr("Microsoft.TimeSeriesInsights/Environments/AccessPolicies"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.TimeSeriesInsights/Environments/env1/accessPolicies/ap1"), + // Properties: &armtimeseriesinsights.AccessPolicyResourceProperties{ + // Description: to.Ptr("some description"), + // PrincipalObjectID: to.Ptr("aGuid"), + // Roles: []*armtimeseriesinsights.AccessPolicyRole{ + // to.Ptr(armtimeseriesinsights.AccessPolicyRoleReader)}, + // }, + // }}, + // } +} diff --git a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/autorest.md b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/autorest.md index b94976206b3f..806fd2b0ac88 100644 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/autorest.md +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 1.1.0 tag: package-2020-05-15 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/client_factory.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/client_factory.go new file mode 100644 index 000000000000..d7689349ea00 --- /dev/null +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/client_factory.go @@ -0,0 +1,64 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armtimeseriesinsights + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewEnvironmentsClient() *EnvironmentsClient { + subClient, _ := NewEnvironmentsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewEventSourcesClient() *EventSourcesClient { + subClient, _ := NewEventSourcesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewReferenceDataSetsClient() *ReferenceDataSetsClient { + subClient, _ := NewReferenceDataSetsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAccessPoliciesClient() *AccessPoliciesClient { + subClient, _ := NewAccessPoliciesClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_constants.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/constants.go similarity index 99% rename from sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_constants.go rename to sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/constants.go index 9e8995b29017..a35c741c590f 100644 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_constants.go +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/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 armtimeseriesinsights const ( moduleName = "armtimeseriesinsights" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // AccessPolicyRole - A role defining the data plane operations that a principal can perform on a Time Series Insights client. diff --git a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_environments_client.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/environments_client.go similarity index 85% rename from sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_environments_client.go rename to sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/environments_client.go index 8b4a4f12f214..10b44ebcc351 100644 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_environments_client.go +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/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 armtimeseriesinsights @@ -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 ( // 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 - Azure Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func 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 update an environment in the specified subscription and resource group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// environmentName - Name of the environment -// parameters - Parameters for creating an environment resource. -// options - EnvironmentsClientBeginCreateOrUpdateOptions contains the optional parameters for the EnvironmentsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - Name of an Azure Resource group. +// - environmentName - Name of the environment +// - parameters - Parameters for creating an environment resource. +// - options - EnvironmentsClientBeginCreateOrUpdateOptions contains the optional parameters for the EnvironmentsClient.BeginCreateOrUpdate +// method. func (client *EnvironmentsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, environmentName string, parameters EnvironmentCreateOrUpdateParametersClassification, options *EnvironmentsClientBeginCreateOrUpdateOptions) (*runtime.Poller[EnvironmentsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, environmentName, parameters, 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 update an environment in the specified subscription and resource group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 func (client *EnvironmentsClient) createOrUpdate(ctx context.Context, resourceGroupName string, environmentName string, parameters EnvironmentCreateOrUpdateParametersClassification, options *EnvironmentsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, environmentName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -107,7 +99,7 @@ func (client *EnvironmentsClient) createOrUpdateCreateRequest(ctx context.Contex return nil, errors.New("parameter environmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{environmentName}", url.PathEscape(environmentName)) - 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 *EnvironmentsClient) createOrUpdateCreateRequest(ctx context.Contex // Delete - Deletes the environment with the specified name in the specified subscription and resource group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// environmentName - The name of the Time Series Insights environment associated with the specified resource group. -// options - EnvironmentsClientDeleteOptions contains the optional parameters for the EnvironmentsClient.Delete method. +// - resourceGroupName - Name of an Azure Resource group. +// - environmentName - The name of the Time Series Insights environment associated with the specified resource group. +// - options - EnvironmentsClientDeleteOptions contains the optional parameters for the EnvironmentsClient.Delete method. func (client *EnvironmentsClient) Delete(ctx context.Context, resourceGroupName string, environmentName string, options *EnvironmentsClientDeleteOptions) (EnvironmentsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, environmentName, options) if err != nil { return EnvironmentsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return EnvironmentsClientDeleteResponse{}, err } @@ -154,7 +147,7 @@ func (client *EnvironmentsClient) deleteCreateRequest(ctx context.Context, resou return nil, errors.New("parameter environmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{environmentName}", url.PathEscape(environmentName)) - 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 *EnvironmentsClient) deleteCreateRequest(ctx context.Context, resou // Get - Gets the environment with the specified name in the specified subscription and resource group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// environmentName - The name of the Time Series Insights environment associated with the specified resource group. -// options - EnvironmentsClientGetOptions contains the optional parameters for the EnvironmentsClient.Get method. +// - resourceGroupName - Name of an Azure Resource group. +// - environmentName - The name of the Time Series Insights environment associated with the specified resource group. +// - options - EnvironmentsClientGetOptions contains the optional parameters for the EnvironmentsClient.Get method. func (client *EnvironmentsClient) Get(ctx context.Context, resourceGroupName string, environmentName string, options *EnvironmentsClientGetOptions) (EnvironmentsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, environmentName, 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 } @@ -201,7 +195,7 @@ func (client *EnvironmentsClient) getCreateRequest(ctx context.Context, resource return nil, errors.New("parameter environmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{environmentName}", url.PathEscape(environmentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -227,16 +221,17 @@ func (client *EnvironmentsClient) getHandleResponse(resp *http.Response) (Enviro // ListByResourceGroup - Lists all the available environments associated with the subscription and within the specified resource // group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// options - EnvironmentsClientListByResourceGroupOptions contains the optional parameters for the EnvironmentsClient.ListByResourceGroup -// method. +// - resourceGroupName - Name of an Azure Resource group. +// - options - EnvironmentsClientListByResourceGroupOptions contains the optional parameters for the EnvironmentsClient.ListByResourceGroup +// method. func (client *EnvironmentsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, options *EnvironmentsClientListByResourceGroupOptions) (EnvironmentsClientListByResourceGroupResponse, error) { req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) if err != nil { return EnvironmentsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return EnvironmentsClientListByResourceGroupResponse{}, err } @@ -257,7 +252,7 @@ func (client *EnvironmentsClient) 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 } @@ -279,15 +274,16 @@ func (client *EnvironmentsClient) listByResourceGroupHandleResponse(resp *http.R // ListBySubscription - Lists all the available environments within a subscription, irrespective of the resource groups. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// options - EnvironmentsClientListBySubscriptionOptions contains the optional parameters for the EnvironmentsClient.ListBySubscription -// method. +// - options - EnvironmentsClientListBySubscriptionOptions contains the optional parameters for the EnvironmentsClient.ListBySubscription +// method. func (client *EnvironmentsClient) ListBySubscription(ctx context.Context, options *EnvironmentsClientListBySubscriptionOptions) (EnvironmentsClientListBySubscriptionResponse, error) { req, err := client.listBySubscriptionCreateRequest(ctx, options) if err != nil { return EnvironmentsClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return EnvironmentsClientListBySubscriptionResponse{}, err } @@ -304,7 +300,7 @@ func (client *EnvironmentsClient) listBySubscriptionCreateRequest(ctx context.Co return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -326,33 +322,35 @@ func (client *EnvironmentsClient) listBySubscriptionHandleResponse(resp *http.Re // BeginUpdate - Updates the environment with the specified name in the specified subscription and resource group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// environmentName - The name of the Time Series Insights environment associated with the specified resource group. -// environmentUpdateParameters - Request object that contains the updated information for the environment. -// options - EnvironmentsClientBeginUpdateOptions contains the optional parameters for the EnvironmentsClient.BeginUpdate -// method. +// - resourceGroupName - Name of an Azure Resource group. +// - environmentName - The name of the Time Series Insights environment associated with the specified resource group. +// - environmentUpdateParameters - Request object that contains the updated information for the environment. +// - options - EnvironmentsClientBeginUpdateOptions contains the optional parameters for the EnvironmentsClient.BeginUpdate +// method. func (client *EnvironmentsClient) BeginUpdate(ctx context.Context, resourceGroupName string, environmentName string, environmentUpdateParameters EnvironmentUpdateParametersClassification, options *EnvironmentsClientBeginUpdateOptions) (*runtime.Poller[EnvironmentsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, environmentName, environmentUpdateParameters, options) if err != nil { return nil, err } - return runtime.NewPoller[EnvironmentsClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[EnvironmentsClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[EnvironmentsClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[EnvironmentsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates the environment with the specified name in the specified subscription and resource group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 func (client *EnvironmentsClient) update(ctx context.Context, resourceGroupName string, environmentName string, environmentUpdateParameters EnvironmentUpdateParametersClassification, options *EnvironmentsClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, environmentName, environmentUpdateParameters, 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 +375,7 @@ func (client *EnvironmentsClient) updateCreateRequest(ctx context.Context, resou return nil, errors.New("parameter environmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{environmentName}", url.PathEscape(environmentName)) - 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/timeseriesinsights/armtimeseriesinsights/environments_client_example_test.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/environments_client_example_test.go new file mode 100644 index 000000000000..71518cbe001e --- /dev/null +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/environments_client_example_test.go @@ -0,0 +1,271 @@ +//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 armtimeseriesinsights_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/timeseriesinsights/armtimeseriesinsights" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EnvironmentsCreate.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 := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEnvironmentsClient().BeginCreateOrUpdate(ctx, "rg1", "env1", &armtimeseriesinsights.Gen1EnvironmentCreateOrUpdateParameters{ + Location: to.Ptr("West US"), + Kind: to.Ptr(armtimeseriesinsights.EnvironmentKindGen1), + SKU: &armtimeseriesinsights.SKU{ + Name: to.Ptr(armtimeseriesinsights.SKUNameS1), + Capacity: to.Ptr[int32](1), + }, + Properties: &armtimeseriesinsights.Gen1EnvironmentCreationProperties{ + DataRetentionTime: to.Ptr("P31D"), + PartitionKeyProperties: []*armtimeseriesinsights.TimeSeriesIDProperty{ + { + Name: to.Ptr("DeviceId1"), + Type: to.Ptr(armtimeseriesinsights.PropertyTypeString), + }}, + }, + }, 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 = armtimeseriesinsights.EnvironmentsClientCreateOrUpdateResponse{ + // EnvironmentResourceClassification: &armtimeseriesinsights.Gen1EnvironmentResource{ + // Name: to.Ptr("env1"), + // Type: to.Ptr("Microsoft.TimeSeriesInsights/Environments"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.TimeSeriesInsights/Environments/env1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // }, + // Kind: to.Ptr(armtimeseriesinsights.EnvironmentResourceKindGen1), + // SKU: &armtimeseriesinsights.SKU{ + // Name: to.Ptr(armtimeseriesinsights.SKUNameS1), + // Capacity: to.Ptr[int32](1), + // }, + // Properties: &armtimeseriesinsights.Gen1EnvironmentResourceProperties{ + // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-18T19:20:33.2288820Z"); return t}()), + // ProvisioningState: to.Ptr(armtimeseriesinsights.ProvisioningStateSucceeded), + // DataRetentionTime: to.Ptr("P31D"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EnvironmentsGet.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 := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEnvironmentsClient().Get(ctx, "rg1", "env1", &armtimeseriesinsights.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 = armtimeseriesinsights.EnvironmentsClientGetResponse{ + // EnvironmentResourceClassification: &armtimeseriesinsights.Gen1EnvironmentResource{ + // Name: to.Ptr("env1"), + // Type: to.Ptr("Microsoft.TimeSeriesInsights/Environments"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.TimeSeriesInsights/Environments/env1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // }, + // Kind: to.Ptr(armtimeseriesinsights.EnvironmentResourceKindGen1), + // SKU: &armtimeseriesinsights.SKU{ + // Name: to.Ptr(armtimeseriesinsights.SKUNameS1), + // Capacity: to.Ptr[int32](1), + // }, + // Properties: &armtimeseriesinsights.Gen1EnvironmentResourceProperties{ + // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-18T19:20:33.2288820Z"); return t}()), + // ProvisioningState: to.Ptr(armtimeseriesinsights.ProvisioningStateSucceeded), + // DataRetentionTime: to.Ptr("P31D"), + // PartitionKeyProperties: []*armtimeseriesinsights.TimeSeriesIDProperty{ + // { + // Name: to.Ptr("DeviceId1"), + // Type: to.Ptr(armtimeseriesinsights.PropertyTypeString), + // }}, + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EnvironmentsPatchTags.json +func ExampleEnvironmentsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewEnvironmentsClient().BeginUpdate(ctx, "rg1", "env1", &armtimeseriesinsights.EnvironmentUpdateParameters{ + Tags: map[string]*string{ + "someTag": to.Ptr("someTagValue"), + }, + }, 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 = armtimeseriesinsights.EnvironmentsClientUpdateResponse{ + // EnvironmentResourceClassification: &armtimeseriesinsights.Gen1EnvironmentResource{ + // Name: to.Ptr("env1"), + // Type: to.Ptr("Microsoft.TimeSeriesInsights/Environments"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.TimeSeriesInsights/Environments/env1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "someTag": to.Ptr("someTagValue"), + // }, + // Kind: to.Ptr(armtimeseriesinsights.EnvironmentResourceKindGen1), + // SKU: &armtimeseriesinsights.SKU{ + // Name: to.Ptr(armtimeseriesinsights.SKUNameS1), + // Capacity: to.Ptr[int32](10), + // }, + // Properties: &armtimeseriesinsights.Gen1EnvironmentResourceProperties{ + // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-18T19:20:33.2288820Z"); return t}()), + // ProvisioningState: to.Ptr(armtimeseriesinsights.ProvisioningStateSucceeded), + // DataRetentionTime: to.Ptr("P31D"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EnvironmentsDelete.json +func ExampleEnvironmentsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewEnvironmentsClient().Delete(ctx, "rg1", "env1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EnvironmentsListByResourceGroup.json +func ExampleEnvironmentsClient_ListByResourceGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEnvironmentsClient().ListByResourceGroup(ctx, "rg1", 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.EnvironmentListResponse = armtimeseriesinsights.EnvironmentListResponse{ + // Value: []armtimeseriesinsights.EnvironmentResourceClassification{ + // &armtimeseriesinsights.Gen1EnvironmentResource{ + // Name: to.Ptr("env1"), + // Type: to.Ptr("Microsoft.TimeSeriesInsights/Environments"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.TimeSeriesInsights/Environments/env1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // }, + // Kind: to.Ptr(armtimeseriesinsights.EnvironmentResourceKindGen1), + // SKU: &armtimeseriesinsights.SKU{ + // Name: to.Ptr(armtimeseriesinsights.SKUNameS1), + // Capacity: to.Ptr[int32](1), + // }, + // Properties: &armtimeseriesinsights.Gen1EnvironmentResourceProperties{ + // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-18T19:20:33.2288820Z"); return t}()), + // ProvisioningState: to.Ptr(armtimeseriesinsights.ProvisioningStateSucceeded), + // DataRetentionTime: to.Ptr("P31D"), + // }, + // }}, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EnvironmentsListBySubscription.json +func ExampleEnvironmentsClient_ListBySubscription() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEnvironmentsClient().ListBySubscription(ctx, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.EnvironmentListResponse = armtimeseriesinsights.EnvironmentListResponse{ + // Value: []armtimeseriesinsights.EnvironmentResourceClassification{ + // &armtimeseriesinsights.Gen1EnvironmentResource{ + // Name: to.Ptr("env1"), + // Type: to.Ptr("Microsoft.TimeSeriesInsights/Environments"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.TimeSeriesInsights/Environments/env1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // }, + // Kind: to.Ptr(armtimeseriesinsights.EnvironmentResourceKindGen1), + // SKU: &armtimeseriesinsights.SKU{ + // Name: to.Ptr(armtimeseriesinsights.SKUNameS1), + // Capacity: to.Ptr[int32](1), + // }, + // Properties: &armtimeseriesinsights.Gen1EnvironmentResourceProperties{ + // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-18T19:20:33.2288820Z"); return t}()), + // ProvisioningState: to.Ptr(armtimeseriesinsights.ProvisioningStateSucceeded), + // DataRetentionTime: to.Ptr("P31D"), + // }, + // }}, + // } +} diff --git a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_eventsources_client.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/eventsources_client.go similarity index 83% rename from sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_eventsources_client.go rename to sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/eventsources_client.go index ca6e6c788fc8..7e3596df9718 100644 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_eventsources_client.go +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/eventsources_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 armtimeseriesinsights @@ -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 ( // EventSourcesClient contains the methods for the EventSources group. // Don't use this type directly, use NewEventSourcesClient() instead. type EventSourcesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewEventSourcesClient creates a new instance of EventSourcesClient with the specified values. -// subscriptionID - Azure Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewEventSourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EventSourcesClient, 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+".EventSourcesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &EventSourcesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or update an event source under the specified environment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// environmentName - The name of the Time Series Insights environment associated with the specified resource group. -// eventSourceName - Name of the event source. -// parameters - Parameters for creating an event source resource. -// options - EventSourcesClientCreateOrUpdateOptions contains the optional parameters for the EventSourcesClient.CreateOrUpdate -// method. +// - resourceGroupName - Name of an Azure Resource group. +// - environmentName - The name of the Time Series Insights environment associated with the specified resource group. +// - eventSourceName - Name of the event source. +// - parameters - Parameters for creating an event source resource. +// - options - EventSourcesClientCreateOrUpdateOptions contains the optional parameters for the EventSourcesClient.CreateOrUpdate +// method. func (client *EventSourcesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, environmentName string, eventSourceName string, parameters EventSourceCreateOrUpdateParametersClassification, options *EventSourcesClientCreateOrUpdateOptions) (EventSourcesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, environmentName, eventSourceName, parameters, options) if err != nil { return EventSourcesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return EventSourcesClientCreateOrUpdateResponse{}, err } @@ -97,7 +88,7 @@ func (client *EventSourcesClient) createOrUpdateCreateRequest(ctx context.Contex return nil, errors.New("parameter eventSourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{eventSourceName}", url.PathEscape(eventSourceName)) - 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 *EventSourcesClient) createOrUpdateHandleResponse(resp *http.Respon // Delete - Deletes the event source with the specified name in the specified subscription, resource group, and environment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// environmentName - The name of the Time Series Insights environment associated with the specified resource group. -// eventSourceName - The name of the Time Series Insights event source associated with the specified environment. -// options - EventSourcesClientDeleteOptions contains the optional parameters for the EventSourcesClient.Delete method. +// - resourceGroupName - Name of an Azure Resource group. +// - environmentName - The name of the Time Series Insights environment associated with the specified resource group. +// - eventSourceName - The name of the Time Series Insights event source associated with the specified environment. +// - options - EventSourcesClientDeleteOptions contains the optional parameters for the EventSourcesClient.Delete method. func (client *EventSourcesClient) Delete(ctx context.Context, resourceGroupName string, environmentName string, eventSourceName string, options *EventSourcesClientDeleteOptions) (EventSourcesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, environmentName, eventSourceName, options) if err != nil { return EventSourcesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return EventSourcesClientDeleteResponse{}, err } @@ -158,7 +150,7 @@ func (client *EventSourcesClient) deleteCreateRequest(ctx context.Context, resou return nil, errors.New("parameter eventSourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{eventSourceName}", url.PathEscape(eventSourceName)) - 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 *EventSourcesClient) deleteCreateRequest(ctx context.Context, resou // Get - Gets the event source with the specified name in the specified environment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// environmentName - The name of the Time Series Insights environment associated with the specified resource group. -// eventSourceName - The name of the Time Series Insights event source associated with the specified environment. -// options - EventSourcesClientGetOptions contains the optional parameters for the EventSourcesClient.Get method. +// - resourceGroupName - Name of an Azure Resource group. +// - environmentName - The name of the Time Series Insights environment associated with the specified resource group. +// - eventSourceName - The name of the Time Series Insights event source associated with the specified environment. +// - options - EventSourcesClientGetOptions contains the optional parameters for the EventSourcesClient.Get method. func (client *EventSourcesClient) Get(ctx context.Context, resourceGroupName string, environmentName string, eventSourceName string, options *EventSourcesClientGetOptions) (EventSourcesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, environmentName, eventSourceName, options) if err != nil { return EventSourcesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return EventSourcesClientGetResponse{}, err } @@ -210,7 +203,7 @@ func (client *EventSourcesClient) getCreateRequest(ctx context.Context, resource return nil, errors.New("parameter eventSourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{eventSourceName}", url.PathEscape(eventSourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -233,17 +226,18 @@ func (client *EventSourcesClient) getHandleResponse(resp *http.Response) (EventS // ListByEnvironment - Lists all the available event sources associated with the subscription and within the specified resource // group and environment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// environmentName - The name of the Time Series Insights environment associated with the specified resource group. -// options - EventSourcesClientListByEnvironmentOptions contains the optional parameters for the EventSourcesClient.ListByEnvironment -// method. +// - resourceGroupName - Name of an Azure Resource group. +// - environmentName - The name of the Time Series Insights environment associated with the specified resource group. +// - options - EventSourcesClientListByEnvironmentOptions contains the optional parameters for the EventSourcesClient.ListByEnvironment +// method. func (client *EventSourcesClient) ListByEnvironment(ctx context.Context, resourceGroupName string, environmentName string, options *EventSourcesClientListByEnvironmentOptions) (EventSourcesClientListByEnvironmentResponse, error) { req, err := client.listByEnvironmentCreateRequest(ctx, resourceGroupName, environmentName, options) if err != nil { return EventSourcesClientListByEnvironmentResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return EventSourcesClientListByEnvironmentResponse{}, err } @@ -268,7 +262,7 @@ func (client *EventSourcesClient) listByEnvironmentCreateRequest(ctx context.Con return nil, errors.New("parameter environmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{environmentName}", url.PathEscape(environmentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -290,18 +284,19 @@ func (client *EventSourcesClient) listByEnvironmentHandleResponse(resp *http.Res // Update - Updates the event source with the specified name in the specified subscription, resource group, and environment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// environmentName - The name of the Time Series Insights environment associated with the specified resource group. -// eventSourceName - The name of the Time Series Insights event source associated with the specified environment. -// eventSourceUpdateParameters - Request object that contains the updated information for the event source. -// options - EventSourcesClientUpdateOptions contains the optional parameters for the EventSourcesClient.Update method. +// - resourceGroupName - Name of an Azure Resource group. +// - environmentName - The name of the Time Series Insights environment associated with the specified resource group. +// - eventSourceName - The name of the Time Series Insights event source associated with the specified environment. +// - eventSourceUpdateParameters - Request object that contains the updated information for the event source. +// - options - EventSourcesClientUpdateOptions contains the optional parameters for the EventSourcesClient.Update method. func (client *EventSourcesClient) Update(ctx context.Context, resourceGroupName string, environmentName string, eventSourceName string, eventSourceUpdateParameters EventSourceUpdateParametersClassification, options *EventSourcesClientUpdateOptions) (EventSourcesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, environmentName, eventSourceName, eventSourceUpdateParameters, options) if err != nil { return EventSourcesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return EventSourcesClientUpdateResponse{}, err } @@ -330,7 +325,7 @@ func (client *EventSourcesClient) updateCreateRequest(ctx context.Context, resou return nil, errors.New("parameter eventSourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{eventSourceName}", url.PathEscape(eventSourceName)) - 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/timeseriesinsights/armtimeseriesinsights/eventsources_client_example_test.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/eventsources_client_example_test.go new file mode 100644 index 000000000000..3f3ac7790835 --- /dev/null +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/eventsources_client_example_test.go @@ -0,0 +1,320 @@ +//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 armtimeseriesinsights_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/timeseriesinsights/armtimeseriesinsights" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EventSourcesCreateEventHub.json +func ExampleEventSourcesClient_CreateOrUpdate_createEventHubEventSource() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEventSourcesClient().CreateOrUpdate(ctx, "rg1", "env1", "es1", &armtimeseriesinsights.EventHubEventSourceCreateOrUpdateParameters{ + Location: to.Ptr("West US"), + Kind: to.Ptr(armtimeseriesinsights.EventSourceKindMicrosoftEventHub), + Properties: &armtimeseriesinsights.EventHubEventSourceCreationProperties{ + IngressStartAt: &armtimeseriesinsights.IngressStartAtProperties{ + Type: to.Ptr(armtimeseriesinsights.IngressStartAtTypeEarliestAvailable), + }, + LocalTimestamp: &armtimeseriesinsights.LocalTimestamp{ + Format: to.Ptr(armtimeseriesinsights.LocalTimestampFormat("TimeSpan")), + TimeZoneOffset: &armtimeseriesinsights.LocalTimestampTimeZoneOffset{ + PropertyName: to.Ptr("someEventPropertyName"), + }, + }, + TimestampPropertyName: to.Ptr("someTimestampProperty"), + EventSourceResourceID: to.Ptr("somePathInArm"), + ConsumerGroupName: to.Ptr("cgn"), + EventHubName: to.Ptr("ehn"), + KeyName: to.Ptr("managementKey"), + ServiceBusNamespace: to.Ptr("sbn"), + SharedAccessKey: to.Ptr("someSecretvalue"), + }, + }, 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 = armtimeseriesinsights.EventSourcesClientCreateOrUpdateResponse{ + // EventSourceResourceClassification: &armtimeseriesinsights.EventHubEventSourceResource{ + // Name: to.Ptr("es1"), + // Type: to.Ptr("Microsoft.TimeSeriesInsights/Environments/EventSources"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.TimeSeriesInsights/Environments/env1/eventSources/es1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // }, + // Kind: to.Ptr(armtimeseriesinsights.EventSourceResourceKindMicrosoftEventHub), + // Properties: &armtimeseriesinsights.EventHubEventSourceResourceProperties{ + // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-18T19:20:33.2288820Z"); return t}()), + // ProvisioningState: to.Ptr(armtimeseriesinsights.ProvisioningStateSucceeded), + // IngressStartAt: &armtimeseriesinsights.IngressStartAtProperties{ + // Type: to.Ptr(armtimeseriesinsights.IngressStartAtTypeEarliestAvailable), + // }, + // LocalTimestamp: &armtimeseriesinsights.LocalTimestamp{ + // Format: to.Ptr(armtimeseriesinsights.LocalTimestampFormat("TimeSpan")), + // TimeZoneOffset: &armtimeseriesinsights.LocalTimestampTimeZoneOffset{ + // PropertyName: to.Ptr("someEventPropertyName"), + // }, + // }, + // EventSourceResourceID: to.Ptr("somePathInArm"), + // ConsumerGroupName: to.Ptr("cgn"), + // EventHubName: to.Ptr("ehn"), + // KeyName: to.Ptr("managementKey"), + // ServiceBusNamespace: to.Ptr("sbn"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EventSourcesCreateEventHubWithCustomEnquedTime.json +func ExampleEventSourcesClient_CreateOrUpdate_eventSourcesCreateEventHubWithCustomEnquedTime() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEventSourcesClient().CreateOrUpdate(ctx, "rg1", "env1", "es1", &armtimeseriesinsights.EventHubEventSourceCreateOrUpdateParameters{ + Location: to.Ptr("West US"), + Kind: to.Ptr(armtimeseriesinsights.EventSourceKindMicrosoftEventHub), + Properties: &armtimeseriesinsights.EventHubEventSourceCreationProperties{ + IngressStartAt: &armtimeseriesinsights.IngressStartAtProperties{ + Type: to.Ptr(armtimeseriesinsights.IngressStartAtTypeCustomEnqueuedTime), + Time: to.Ptr("2017-04-01T19:20:33.2288820Z"), + }, + TimestampPropertyName: to.Ptr("someTimestampProperty"), + EventSourceResourceID: to.Ptr("somePathInArm"), + ConsumerGroupName: to.Ptr("cgn"), + EventHubName: to.Ptr("ehn"), + KeyName: to.Ptr("managementKey"), + ServiceBusNamespace: to.Ptr("sbn"), + SharedAccessKey: to.Ptr("someSecretvalue"), + }, + }, 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 = armtimeseriesinsights.EventSourcesClientCreateOrUpdateResponse{ + // EventSourceResourceClassification: &armtimeseriesinsights.EventHubEventSourceResource{ + // Name: to.Ptr("es1"), + // Type: to.Ptr("Microsoft.TimeSeriesInsights/Environments/EventSources"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.TimeSeriesInsights/Environments/env1/eventSources/es1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // }, + // Kind: to.Ptr(armtimeseriesinsights.EventSourceResourceKindMicrosoftEventHub), + // Properties: &armtimeseriesinsights.EventHubEventSourceResourceProperties{ + // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-18T19:20:33.2288820Z"); return t}()), + // ProvisioningState: to.Ptr(armtimeseriesinsights.ProvisioningStateSucceeded), + // IngressStartAt: &armtimeseriesinsights.IngressStartAtProperties{ + // Type: to.Ptr(armtimeseriesinsights.IngressStartAtTypeCustomEnqueuedTime), + // Time: to.Ptr("2017-04-01T19:20:33.2288820Z"), + // }, + // EventSourceResourceID: to.Ptr("somePathInArm"), + // ConsumerGroupName: to.Ptr("cgn"), + // EventHubName: to.Ptr("ehn"), + // KeyName: to.Ptr("managementKey"), + // ServiceBusNamespace: to.Ptr("sbn"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EventSourcesGetEventHub.json +func ExampleEventSourcesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEventSourcesClient().Get(ctx, "rg1", "env1", "es1", 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 = armtimeseriesinsights.EventSourcesClientGetResponse{ + // EventSourceResourceClassification: &armtimeseriesinsights.EventHubEventSourceResource{ + // Name: to.Ptr("es1"), + // Type: to.Ptr("Microsoft.TimeSeriesInsights/Environments/EventSources"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.TimeSeriesInsights/Environments/env1/eventSources/es1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // }, + // Kind: to.Ptr(armtimeseriesinsights.EventSourceResourceKindMicrosoftEventHub), + // Properties: &armtimeseriesinsights.EventHubEventSourceResourceProperties{ + // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-18T19:20:33.2288820Z"); return t}()), + // ProvisioningState: to.Ptr(armtimeseriesinsights.ProvisioningStateSucceeded), + // IngressStartAt: &armtimeseriesinsights.IngressStartAtProperties{ + // Type: to.Ptr(armtimeseriesinsights.IngressStartAtTypeEarliestAvailable), + // }, + // LocalTimestamp: &armtimeseriesinsights.LocalTimestamp{ + // Format: to.Ptr(armtimeseriesinsights.LocalTimestampFormat("TimeSpan")), + // TimeZoneOffset: &armtimeseriesinsights.LocalTimestampTimeZoneOffset{ + // PropertyName: to.Ptr("someEventPropertyName"), + // }, + // }, + // EventSourceResourceID: to.Ptr("somePathInArm"), + // ConsumerGroupName: to.Ptr("cgn"), + // EventHubName: to.Ptr("ehn"), + // KeyName: to.Ptr("managementKey"), + // ServiceBusNamespace: to.Ptr("sbn"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EventSourcesPatchTags.json +func ExampleEventSourcesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEventSourcesClient().Update(ctx, "rg1", "env1", "es1", &armtimeseriesinsights.EventSourceUpdateParameters{ + Tags: map[string]*string{ + "someKey": to.Ptr("someValue"), + }, + }, 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 = armtimeseriesinsights.EventSourcesClientUpdateResponse{ + // EventSourceResourceClassification: &armtimeseriesinsights.EventHubEventSourceResource{ + // Name: to.Ptr("es1"), + // Type: to.Ptr("Microsoft.TimeSeriesInsights/Environments/EventSources"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.TimeSeriesInsights/Environments/env1/eventSources/es1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "someKey": to.Ptr("someValue"), + // }, + // Kind: to.Ptr(armtimeseriesinsights.EventSourceResourceKindMicrosoftEventHub), + // Properties: &armtimeseriesinsights.EventHubEventSourceResourceProperties{ + // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-18T19:20:33.2288820Z"); return t}()), + // ProvisioningState: to.Ptr(armtimeseriesinsights.ProvisioningStateSucceeded), + // IngressStartAt: &armtimeseriesinsights.IngressStartAtProperties{ + // Type: to.Ptr(armtimeseriesinsights.IngressStartAtTypeEarliestAvailable), + // }, + // LocalTimestamp: &armtimeseriesinsights.LocalTimestamp{ + // Format: to.Ptr(armtimeseriesinsights.LocalTimestampFormat("TimeSpan")), + // TimeZoneOffset: &armtimeseriesinsights.LocalTimestampTimeZoneOffset{ + // PropertyName: to.Ptr("someEventPropertyName"), + // }, + // }, + // TimestampPropertyName: to.Ptr("someOtherTimestampProperty"), + // EventSourceResourceID: to.Ptr("somePathInArm"), + // ConsumerGroupName: to.Ptr("cgn"), + // EventHubName: to.Ptr("ehn"), + // KeyName: to.Ptr("managementKey"), + // ServiceBusNamespace: to.Ptr("sbn"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EventSourcesDelete.json +func ExampleEventSourcesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewEventSourcesClient().Delete(ctx, "rg1", "env1", "es1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EventSourcesListByEnvironment.json +func ExampleEventSourcesClient_ListByEnvironment() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewEventSourcesClient().ListByEnvironment(ctx, "rg1", "env1", 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.EventSourceListResponse = armtimeseriesinsights.EventSourceListResponse{ + // Value: []armtimeseriesinsights.EventSourceResourceClassification{ + // &armtimeseriesinsights.EventHubEventSourceResource{ + // Name: to.Ptr("es1"), + // Type: to.Ptr("Microsoft.TimeSeriesInsights/Environments/EventSources"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.TimeSeriesInsights/Environments/env1/eventSources/es1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // }, + // Kind: to.Ptr(armtimeseriesinsights.EventSourceResourceKindMicrosoftEventHub), + // Properties: &armtimeseriesinsights.EventHubEventSourceResourceProperties{ + // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-18T19:20:33.2288820Z"); return t}()), + // ProvisioningState: to.Ptr(armtimeseriesinsights.ProvisioningStateSucceeded), + // IngressStartAt: &armtimeseriesinsights.IngressStartAtProperties{ + // Type: to.Ptr(armtimeseriesinsights.IngressStartAtTypeEarliestAvailable), + // }, + // LocalTimestamp: &armtimeseriesinsights.LocalTimestamp{ + // Format: to.Ptr(armtimeseriesinsights.LocalTimestampFormat("TimeSpan")), + // TimeZoneOffset: &armtimeseriesinsights.LocalTimestampTimeZoneOffset{ + // PropertyName: to.Ptr("someEventPropertyName"), + // }, + // }, + // EventSourceResourceID: to.Ptr("somePathInArm"), + // ConsumerGroupName: to.Ptr("cgn"), + // EventHubName: to.Ptr("ehn"), + // KeyName: to.Ptr("managementKey"), + // ServiceBusNamespace: to.Ptr("sbn"), + // }, + // }}, + // } +} diff --git a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/go.mod b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/go.mod index b44ea0c05b8d..af052bd73e22 100644 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/go.mod +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/timeseriesinsights/ 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/timeseriesinsights/armtimeseriesinsights/go.sum b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/go.sum index 8828b17b1853..8ba445a8c4da 100644 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/go.sum +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/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/timeseriesinsights/armtimeseriesinsights/zz_generated_models.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/models.go similarity index 98% rename from sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_models.go rename to sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/models.go index fe360793046c..5a571d82e112 100644 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_models.go +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/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 armtimeseriesinsights @@ -114,28 +115,6 @@ type AzureEventSourceProperties struct { ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` } -// CloudError - Contains information about an API error. -type CloudError struct { - // Describes a particular API error with an error code and a message. - Error *CloudErrorBody `json:"error,omitempty"` -} - -// CloudErrorBody - Describes a particular API error with an error code and a message. -type CloudErrorBody struct { - // An error code that describes the error condition more precisely than an HTTP status code. Can be used to programmatically - // handle specific error cases. - Code *string `json:"code,omitempty"` - - // Contains nested errors that are related to this error. - Details []*CloudErrorBody `json:"details,omitempty"` - - // A message that describes the error in detail and provides debugging information. - 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"` -} - // CreateOrUpdateTrackedResourceProperties - Properties required to create any resource tracked by Azure Resource Manager. type CreateOrUpdateTrackedResourceProperties struct { // REQUIRED; The location of the resource. @@ -1378,7 +1357,7 @@ type OperationProperties struct { ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/models_serde.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/models_serde.go new file mode 100644 index 000000000000..943fc3610256 --- /dev/null +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/models_serde.go @@ -0,0 +1,3022 @@ +//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 armtimeseriesinsights + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AccessPolicyCreateOrUpdateParameters. +func (a AccessPolicyCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccessPolicyCreateOrUpdateParameters. +func (a *AccessPolicyCreateOrUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccessPolicyListResponse. +func (a AccessPolicyListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccessPolicyListResponse. +func (a *AccessPolicyListResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccessPolicyMutableProperties. +func (a AccessPolicyMutableProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", a.Description) + populate(objectMap, "roles", a.Roles) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccessPolicyMutableProperties. +func (a *AccessPolicyMutableProperties) UnmarshalJSON(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 "description": + err = unpopulate(val, "Description", &a.Description) + delete(rawMsg, key) + case "roles": + err = unpopulate(val, "Roles", &a.Roles) + 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 AccessPolicyResource. +func (a AccessPolicyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccessPolicyResource. +func (a *AccessPolicyResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccessPolicyResourceProperties. +func (a AccessPolicyResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", a.Description) + populate(objectMap, "principalObjectId", a.PrincipalObjectID) + populate(objectMap, "roles", a.Roles) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccessPolicyResourceProperties. +func (a *AccessPolicyResourceProperties) UnmarshalJSON(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 "description": + err = unpopulate(val, "Description", &a.Description) + delete(rawMsg, key) + case "principalObjectId": + err = unpopulate(val, "PrincipalObjectID", &a.PrincipalObjectID) + delete(rawMsg, key) + case "roles": + err = unpopulate(val, "Roles", &a.Roles) + 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 AccessPolicyUpdateParameters. +func (a AccessPolicyUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccessPolicyUpdateParameters. +func (a *AccessPolicyUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AzureEventSourceProperties. +func (a AzureEventSourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "creationTime", a.CreationTime) + populate(objectMap, "eventSourceResourceId", a.EventSourceResourceID) + populate(objectMap, "ingressStartAt", a.IngressStartAt) + populate(objectMap, "localTimestamp", a.LocalTimestamp) + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "timestampPropertyName", a.TimestampPropertyName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureEventSourceProperties. +func (a *AzureEventSourceProperties) UnmarshalJSON(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 "creationTime": + err = unpopulateTimeRFC3339(val, "CreationTime", &a.CreationTime) + delete(rawMsg, key) + case "eventSourceResourceId": + err = unpopulate(val, "EventSourceResourceID", &a.EventSourceResourceID) + delete(rawMsg, key) + case "ingressStartAt": + err = unpopulate(val, "IngressStartAt", &a.IngressStartAt) + delete(rawMsg, key) + case "localTimestamp": + err = unpopulate(val, "LocalTimestamp", &a.LocalTimestamp) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + case "timestampPropertyName": + err = unpopulate(val, "TimestampPropertyName", &a.TimestampPropertyName) + 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 CreateOrUpdateTrackedResourceProperties. +func (c CreateOrUpdateTrackedResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "location", c.Location) + populate(objectMap, "tags", c.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CreateOrUpdateTrackedResourceProperties. +func (c *CreateOrUpdateTrackedResourceProperties) UnmarshalJSON(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 "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, 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 Dimension. +func (d Dimension) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", d.DisplayName) + populate(objectMap, "name", d.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Dimension. +func (d *Dimension) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &d.DisplayName) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + 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 EnvironmentCreateOrUpdateParameters. +func (e EnvironmentCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["kind"] = e.Kind + populate(objectMap, "location", e.Location) + populate(objectMap, "sku", e.SKU) + populate(objectMap, "tags", e.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentCreateOrUpdateParameters. +func (e *EnvironmentCreateOrUpdateParameters) UnmarshalJSON(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 "kind": + err = unpopulate(val, "Kind", &e.Kind) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &e.Location) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &e.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + 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 EnvironmentListResponse. +func (e EnvironmentListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentListResponse. +func (e *EnvironmentListResponse) UnmarshalJSON(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 "value": + e.Value, err = unmarshalEnvironmentResourceClassificationArray(val) + 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 EnvironmentResource. +func (e EnvironmentResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + objectMap["kind"] = e.Kind + populate(objectMap, "location", e.Location) + populate(objectMap, "name", e.Name) + populate(objectMap, "sku", e.SKU) + populate(objectMap, "tags", e.Tags) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentResource. +func (e *EnvironmentResource) UnmarshalJSON(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 "kind": + err = unpopulate(val, "Kind", &e.Kind) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &e.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &e.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + 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 EnvironmentResourceProperties. +func (e EnvironmentResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "creationTime", e.CreationTime) + populate(objectMap, "dataAccessFqdn", e.DataAccessFqdn) + populate(objectMap, "dataAccessId", e.DataAccessID) + populate(objectMap, "provisioningState", e.ProvisioningState) + populate(objectMap, "status", e.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentResourceProperties. +func (e *EnvironmentResourceProperties) UnmarshalJSON(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 "creationTime": + err = unpopulateTimeRFC3339(val, "CreationTime", &e.CreationTime) + delete(rawMsg, key) + case "dataAccessFqdn": + err = unpopulate(val, "DataAccessFqdn", &e.DataAccessFqdn) + delete(rawMsg, key) + case "dataAccessId": + err = unpopulate(val, "DataAccessID", &e.DataAccessID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &e.Status) + 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 EnvironmentStateDetails. +func (e EnvironmentStateDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", e.Code) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentStateDetails. +func (e *EnvironmentStateDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EnvironmentStatus. +func (e EnvironmentStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ingress", e.Ingress) + populate(objectMap, "warmStorage", e.WarmStorage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentStatus. +func (e *EnvironmentStatus) UnmarshalJSON(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 "ingress": + err = unpopulate(val, "Ingress", &e.Ingress) + delete(rawMsg, key) + case "warmStorage": + err = unpopulate(val, "WarmStorage", &e.WarmStorage) + 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 EnvironmentUpdateParameters. +func (e EnvironmentUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["kind"] = e.Kind + populate(objectMap, "tags", e.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentUpdateParameters. +func (e *EnvironmentUpdateParameters) UnmarshalJSON(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 "kind": + err = unpopulate(val, "Kind", &e.Kind) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + 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 EventHubEventSourceCommonProperties. +func (e EventHubEventSourceCommonProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "consumerGroupName", e.ConsumerGroupName) + populateTimeRFC3339(objectMap, "creationTime", e.CreationTime) + populate(objectMap, "eventHubName", e.EventHubName) + populate(objectMap, "eventSourceResourceId", e.EventSourceResourceID) + populate(objectMap, "ingressStartAt", e.IngressStartAt) + populate(objectMap, "keyName", e.KeyName) + populate(objectMap, "localTimestamp", e.LocalTimestamp) + populate(objectMap, "provisioningState", e.ProvisioningState) + populate(objectMap, "serviceBusNamespace", e.ServiceBusNamespace) + populate(objectMap, "timestampPropertyName", e.TimestampPropertyName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventHubEventSourceCommonProperties. +func (e *EventHubEventSourceCommonProperties) UnmarshalJSON(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 "consumerGroupName": + err = unpopulate(val, "ConsumerGroupName", &e.ConsumerGroupName) + delete(rawMsg, key) + case "creationTime": + err = unpopulateTimeRFC3339(val, "CreationTime", &e.CreationTime) + delete(rawMsg, key) + case "eventHubName": + err = unpopulate(val, "EventHubName", &e.EventHubName) + delete(rawMsg, key) + case "eventSourceResourceId": + err = unpopulate(val, "EventSourceResourceID", &e.EventSourceResourceID) + delete(rawMsg, key) + case "ingressStartAt": + err = unpopulate(val, "IngressStartAt", &e.IngressStartAt) + delete(rawMsg, key) + case "keyName": + err = unpopulate(val, "KeyName", &e.KeyName) + delete(rawMsg, key) + case "localTimestamp": + err = unpopulate(val, "LocalTimestamp", &e.LocalTimestamp) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + delete(rawMsg, key) + case "serviceBusNamespace": + err = unpopulate(val, "ServiceBusNamespace", &e.ServiceBusNamespace) + delete(rawMsg, key) + case "timestampPropertyName": + err = unpopulate(val, "TimestampPropertyName", &e.TimestampPropertyName) + 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 EventHubEventSourceCreateOrUpdateParameters. +func (e EventHubEventSourceCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["kind"] = EventSourceKindMicrosoftEventHub + populate(objectMap, "localTimestamp", e.LocalTimestamp) + populate(objectMap, "location", e.Location) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "tags", e.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventHubEventSourceCreateOrUpdateParameters. +func (e *EventHubEventSourceCreateOrUpdateParameters) UnmarshalJSON(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 "kind": + err = unpopulate(val, "Kind", &e.Kind) + delete(rawMsg, key) + case "localTimestamp": + err = unpopulate(val, "LocalTimestamp", &e.LocalTimestamp) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &e.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + 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 EventHubEventSourceCreationProperties. +func (e EventHubEventSourceCreationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "consumerGroupName", e.ConsumerGroupName) + populateTimeRFC3339(objectMap, "creationTime", e.CreationTime) + populate(objectMap, "eventHubName", e.EventHubName) + populate(objectMap, "eventSourceResourceId", e.EventSourceResourceID) + populate(objectMap, "ingressStartAt", e.IngressStartAt) + populate(objectMap, "keyName", e.KeyName) + populate(objectMap, "localTimestamp", e.LocalTimestamp) + populate(objectMap, "provisioningState", e.ProvisioningState) + populate(objectMap, "serviceBusNamespace", e.ServiceBusNamespace) + populate(objectMap, "sharedAccessKey", e.SharedAccessKey) + populate(objectMap, "timestampPropertyName", e.TimestampPropertyName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventHubEventSourceCreationProperties. +func (e *EventHubEventSourceCreationProperties) UnmarshalJSON(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 "consumerGroupName": + err = unpopulate(val, "ConsumerGroupName", &e.ConsumerGroupName) + delete(rawMsg, key) + case "creationTime": + err = unpopulateTimeRFC3339(val, "CreationTime", &e.CreationTime) + delete(rawMsg, key) + case "eventHubName": + err = unpopulate(val, "EventHubName", &e.EventHubName) + delete(rawMsg, key) + case "eventSourceResourceId": + err = unpopulate(val, "EventSourceResourceID", &e.EventSourceResourceID) + delete(rawMsg, key) + case "ingressStartAt": + err = unpopulate(val, "IngressStartAt", &e.IngressStartAt) + delete(rawMsg, key) + case "keyName": + err = unpopulate(val, "KeyName", &e.KeyName) + delete(rawMsg, key) + case "localTimestamp": + err = unpopulate(val, "LocalTimestamp", &e.LocalTimestamp) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + delete(rawMsg, key) + case "serviceBusNamespace": + err = unpopulate(val, "ServiceBusNamespace", &e.ServiceBusNamespace) + delete(rawMsg, key) + case "sharedAccessKey": + err = unpopulate(val, "SharedAccessKey", &e.SharedAccessKey) + delete(rawMsg, key) + case "timestampPropertyName": + err = unpopulate(val, "TimestampPropertyName", &e.TimestampPropertyName) + 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 EventHubEventSourceMutableProperties. +func (e EventHubEventSourceMutableProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "sharedAccessKey", e.SharedAccessKey) + populate(objectMap, "timestampPropertyName", e.TimestampPropertyName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventHubEventSourceMutableProperties. +func (e *EventHubEventSourceMutableProperties) UnmarshalJSON(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 "sharedAccessKey": + err = unpopulate(val, "SharedAccessKey", &e.SharedAccessKey) + delete(rawMsg, key) + case "timestampPropertyName": + err = unpopulate(val, "TimestampPropertyName", &e.TimestampPropertyName) + 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 EventHubEventSourceResource. +func (e EventHubEventSourceResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + objectMap["kind"] = EventSourceResourceKindMicrosoftEventHub + populate(objectMap, "location", e.Location) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "tags", e.Tags) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventHubEventSourceResource. +func (e *EventHubEventSourceResource) UnmarshalJSON(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 "kind": + err = unpopulate(val, "Kind", &e.Kind) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &e.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + 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 EventHubEventSourceResourceProperties. +func (e EventHubEventSourceResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "consumerGroupName", e.ConsumerGroupName) + populateTimeRFC3339(objectMap, "creationTime", e.CreationTime) + populate(objectMap, "eventHubName", e.EventHubName) + populate(objectMap, "eventSourceResourceId", e.EventSourceResourceID) + populate(objectMap, "ingressStartAt", e.IngressStartAt) + populate(objectMap, "keyName", e.KeyName) + populate(objectMap, "localTimestamp", e.LocalTimestamp) + populate(objectMap, "provisioningState", e.ProvisioningState) + populate(objectMap, "serviceBusNamespace", e.ServiceBusNamespace) + populate(objectMap, "timestampPropertyName", e.TimestampPropertyName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventHubEventSourceResourceProperties. +func (e *EventHubEventSourceResourceProperties) UnmarshalJSON(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 "consumerGroupName": + err = unpopulate(val, "ConsumerGroupName", &e.ConsumerGroupName) + delete(rawMsg, key) + case "creationTime": + err = unpopulateTimeRFC3339(val, "CreationTime", &e.CreationTime) + delete(rawMsg, key) + case "eventHubName": + err = unpopulate(val, "EventHubName", &e.EventHubName) + delete(rawMsg, key) + case "eventSourceResourceId": + err = unpopulate(val, "EventSourceResourceID", &e.EventSourceResourceID) + delete(rawMsg, key) + case "ingressStartAt": + err = unpopulate(val, "IngressStartAt", &e.IngressStartAt) + delete(rawMsg, key) + case "keyName": + err = unpopulate(val, "KeyName", &e.KeyName) + delete(rawMsg, key) + case "localTimestamp": + err = unpopulate(val, "LocalTimestamp", &e.LocalTimestamp) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + delete(rawMsg, key) + case "serviceBusNamespace": + err = unpopulate(val, "ServiceBusNamespace", &e.ServiceBusNamespace) + delete(rawMsg, key) + case "timestampPropertyName": + err = unpopulate(val, "TimestampPropertyName", &e.TimestampPropertyName) + 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 EventHubEventSourceUpdateParameters. +func (e EventHubEventSourceUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["kind"] = EventSourceKindMicrosoftEventHub + populate(objectMap, "properties", e.Properties) + populate(objectMap, "tags", e.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventHubEventSourceUpdateParameters. +func (e *EventHubEventSourceUpdateParameters) UnmarshalJSON(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 "kind": + err = unpopulate(val, "Kind", &e.Kind) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + 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 EventSourceCommonProperties. +func (e EventSourceCommonProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "creationTime", e.CreationTime) + populate(objectMap, "ingressStartAt", e.IngressStartAt) + populate(objectMap, "localTimestamp", e.LocalTimestamp) + populate(objectMap, "provisioningState", e.ProvisioningState) + populate(objectMap, "timestampPropertyName", e.TimestampPropertyName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventSourceCommonProperties. +func (e *EventSourceCommonProperties) UnmarshalJSON(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 "creationTime": + err = unpopulateTimeRFC3339(val, "CreationTime", &e.CreationTime) + delete(rawMsg, key) + case "ingressStartAt": + err = unpopulate(val, "IngressStartAt", &e.IngressStartAt) + delete(rawMsg, key) + case "localTimestamp": + err = unpopulate(val, "LocalTimestamp", &e.LocalTimestamp) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + delete(rawMsg, key) + case "timestampPropertyName": + err = unpopulate(val, "TimestampPropertyName", &e.TimestampPropertyName) + 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 EventSourceCreateOrUpdateParameters. +func (e EventSourceCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["kind"] = e.Kind + populate(objectMap, "localTimestamp", e.LocalTimestamp) + populate(objectMap, "location", e.Location) + populate(objectMap, "tags", e.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventSourceCreateOrUpdateParameters. +func (e *EventSourceCreateOrUpdateParameters) UnmarshalJSON(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 "kind": + err = unpopulate(val, "Kind", &e.Kind) + delete(rawMsg, key) + case "localTimestamp": + err = unpopulate(val, "LocalTimestamp", &e.LocalTimestamp) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &e.Location) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + 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 EventSourceListResponse. +func (e EventSourceListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventSourceListResponse. +func (e *EventSourceListResponse) UnmarshalJSON(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 "value": + e.Value, err = unmarshalEventSourceResourceClassificationArray(val) + 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 EventSourceMutableProperties. +func (e EventSourceMutableProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "timestampPropertyName", e.TimestampPropertyName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventSourceMutableProperties. +func (e *EventSourceMutableProperties) UnmarshalJSON(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 "timestampPropertyName": + err = unpopulate(val, "TimestampPropertyName", &e.TimestampPropertyName) + 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 EventSourceResource. +func (e EventSourceResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + objectMap["kind"] = e.Kind + populate(objectMap, "location", e.Location) + populate(objectMap, "name", e.Name) + populate(objectMap, "tags", e.Tags) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventSourceResource. +func (e *EventSourceResource) UnmarshalJSON(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 "kind": + err = unpopulate(val, "Kind", &e.Kind) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &e.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + 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 EventSourceUpdateParameters. +func (e EventSourceUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["kind"] = e.Kind + populate(objectMap, "tags", e.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventSourceUpdateParameters. +func (e *EventSourceUpdateParameters) UnmarshalJSON(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 "kind": + err = unpopulate(val, "Kind", &e.Kind) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + 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 Gen1EnvironmentCreateOrUpdateParameters. +func (g Gen1EnvironmentCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["kind"] = EnvironmentKindGen1 + populate(objectMap, "location", g.Location) + populate(objectMap, "properties", g.Properties) + populate(objectMap, "sku", g.SKU) + populate(objectMap, "tags", g.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Gen1EnvironmentCreateOrUpdateParameters. +func (g *Gen1EnvironmentCreateOrUpdateParameters) UnmarshalJSON(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 "kind": + err = unpopulate(val, "Kind", &g.Kind) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &g.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &g.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &g.Tags) + 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 Gen1EnvironmentCreationProperties. +func (g Gen1EnvironmentCreationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dataRetentionTime", g.DataRetentionTime) + populate(objectMap, "partitionKeyProperties", g.PartitionKeyProperties) + populate(objectMap, "storageLimitExceededBehavior", g.StorageLimitExceededBehavior) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Gen1EnvironmentCreationProperties. +func (g *Gen1EnvironmentCreationProperties) UnmarshalJSON(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 "dataRetentionTime": + err = unpopulate(val, "DataRetentionTime", &g.DataRetentionTime) + delete(rawMsg, key) + case "partitionKeyProperties": + err = unpopulate(val, "PartitionKeyProperties", &g.PartitionKeyProperties) + delete(rawMsg, key) + case "storageLimitExceededBehavior": + err = unpopulate(val, "StorageLimitExceededBehavior", &g.StorageLimitExceededBehavior) + 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 Gen1EnvironmentMutableProperties. +func (g Gen1EnvironmentMutableProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dataRetentionTime", g.DataRetentionTime) + populate(objectMap, "storageLimitExceededBehavior", g.StorageLimitExceededBehavior) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Gen1EnvironmentMutableProperties. +func (g *Gen1EnvironmentMutableProperties) UnmarshalJSON(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 "dataRetentionTime": + err = unpopulate(val, "DataRetentionTime", &g.DataRetentionTime) + delete(rawMsg, key) + case "storageLimitExceededBehavior": + err = unpopulate(val, "StorageLimitExceededBehavior", &g.StorageLimitExceededBehavior) + 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 Gen1EnvironmentResource. +func (g Gen1EnvironmentResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", g.ID) + objectMap["kind"] = EnvironmentResourceKindGen1 + populate(objectMap, "location", g.Location) + populate(objectMap, "name", g.Name) + populate(objectMap, "properties", g.Properties) + populate(objectMap, "sku", g.SKU) + populate(objectMap, "tags", g.Tags) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Gen1EnvironmentResource. +func (g *Gen1EnvironmentResource) UnmarshalJSON(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 "kind": + err = unpopulate(val, "Kind", &g.Kind) + 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 "sku": + err = unpopulate(val, "SKU", &g.SKU) + 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 Gen1EnvironmentResourceProperties. +func (g Gen1EnvironmentResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "creationTime", g.CreationTime) + populate(objectMap, "dataAccessFqdn", g.DataAccessFqdn) + populate(objectMap, "dataAccessId", g.DataAccessID) + populate(objectMap, "dataRetentionTime", g.DataRetentionTime) + populate(objectMap, "partitionKeyProperties", g.PartitionKeyProperties) + populate(objectMap, "provisioningState", g.ProvisioningState) + populate(objectMap, "status", g.Status) + populate(objectMap, "storageLimitExceededBehavior", g.StorageLimitExceededBehavior) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Gen1EnvironmentResourceProperties. +func (g *Gen1EnvironmentResourceProperties) UnmarshalJSON(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 "creationTime": + err = unpopulateTimeRFC3339(val, "CreationTime", &g.CreationTime) + delete(rawMsg, key) + case "dataAccessFqdn": + err = unpopulate(val, "DataAccessFqdn", &g.DataAccessFqdn) + delete(rawMsg, key) + case "dataAccessId": + err = unpopulate(val, "DataAccessID", &g.DataAccessID) + delete(rawMsg, key) + case "dataRetentionTime": + err = unpopulate(val, "DataRetentionTime", &g.DataRetentionTime) + delete(rawMsg, key) + case "partitionKeyProperties": + err = unpopulate(val, "PartitionKeyProperties", &g.PartitionKeyProperties) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &g.ProvisioningState) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &g.Status) + delete(rawMsg, key) + case "storageLimitExceededBehavior": + err = unpopulate(val, "StorageLimitExceededBehavior", &g.StorageLimitExceededBehavior) + 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 Gen1EnvironmentUpdateParameters. +func (g Gen1EnvironmentUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["kind"] = EnvironmentKindGen1 + populate(objectMap, "properties", g.Properties) + populate(objectMap, "sku", g.SKU) + populate(objectMap, "tags", g.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Gen1EnvironmentUpdateParameters. +func (g *Gen1EnvironmentUpdateParameters) UnmarshalJSON(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 "kind": + err = unpopulate(val, "Kind", &g.Kind) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &g.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &g.Tags) + 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 Gen2EnvironmentCreateOrUpdateParameters. +func (g Gen2EnvironmentCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["kind"] = EnvironmentKindGen2 + populate(objectMap, "location", g.Location) + populate(objectMap, "properties", g.Properties) + populate(objectMap, "sku", g.SKU) + populate(objectMap, "tags", g.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Gen2EnvironmentCreateOrUpdateParameters. +func (g *Gen2EnvironmentCreateOrUpdateParameters) UnmarshalJSON(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 "kind": + err = unpopulate(val, "Kind", &g.Kind) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &g.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &g.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &g.Tags) + 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 Gen2EnvironmentCreationProperties. +func (g Gen2EnvironmentCreationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "storageConfiguration", g.StorageConfiguration) + populate(objectMap, "timeSeriesIdProperties", g.TimeSeriesIDProperties) + populate(objectMap, "warmStoreConfiguration", g.WarmStoreConfiguration) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Gen2EnvironmentCreationProperties. +func (g *Gen2EnvironmentCreationProperties) UnmarshalJSON(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 "storageConfiguration": + err = unpopulate(val, "StorageConfiguration", &g.StorageConfiguration) + delete(rawMsg, key) + case "timeSeriesIdProperties": + err = unpopulate(val, "TimeSeriesIDProperties", &g.TimeSeriesIDProperties) + delete(rawMsg, key) + case "warmStoreConfiguration": + err = unpopulate(val, "WarmStoreConfiguration", &g.WarmStoreConfiguration) + 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 Gen2EnvironmentMutableProperties. +func (g Gen2EnvironmentMutableProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "storageConfiguration", g.StorageConfiguration) + populate(objectMap, "warmStoreConfiguration", g.WarmStoreConfiguration) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Gen2EnvironmentMutableProperties. +func (g *Gen2EnvironmentMutableProperties) UnmarshalJSON(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 "storageConfiguration": + err = unpopulate(val, "StorageConfiguration", &g.StorageConfiguration) + delete(rawMsg, key) + case "warmStoreConfiguration": + err = unpopulate(val, "WarmStoreConfiguration", &g.WarmStoreConfiguration) + 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 Gen2EnvironmentResource. +func (g Gen2EnvironmentResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", g.ID) + objectMap["kind"] = EnvironmentResourceKindGen2 + populate(objectMap, "location", g.Location) + populate(objectMap, "name", g.Name) + populate(objectMap, "properties", g.Properties) + populate(objectMap, "sku", g.SKU) + populate(objectMap, "tags", g.Tags) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Gen2EnvironmentResource. +func (g *Gen2EnvironmentResource) UnmarshalJSON(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 "kind": + err = unpopulate(val, "Kind", &g.Kind) + 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 "sku": + err = unpopulate(val, "SKU", &g.SKU) + 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 Gen2EnvironmentResourceProperties. +func (g Gen2EnvironmentResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "creationTime", g.CreationTime) + populate(objectMap, "dataAccessFqdn", g.DataAccessFqdn) + populate(objectMap, "dataAccessId", g.DataAccessID) + populate(objectMap, "provisioningState", g.ProvisioningState) + populate(objectMap, "status", g.Status) + populate(objectMap, "storageConfiguration", g.StorageConfiguration) + populate(objectMap, "timeSeriesIdProperties", g.TimeSeriesIDProperties) + populate(objectMap, "warmStoreConfiguration", g.WarmStoreConfiguration) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Gen2EnvironmentResourceProperties. +func (g *Gen2EnvironmentResourceProperties) UnmarshalJSON(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 "creationTime": + err = unpopulateTimeRFC3339(val, "CreationTime", &g.CreationTime) + delete(rawMsg, key) + case "dataAccessFqdn": + err = unpopulate(val, "DataAccessFqdn", &g.DataAccessFqdn) + delete(rawMsg, key) + case "dataAccessId": + err = unpopulate(val, "DataAccessID", &g.DataAccessID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &g.ProvisioningState) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &g.Status) + delete(rawMsg, key) + case "storageConfiguration": + err = unpopulate(val, "StorageConfiguration", &g.StorageConfiguration) + delete(rawMsg, key) + case "timeSeriesIdProperties": + err = unpopulate(val, "TimeSeriesIDProperties", &g.TimeSeriesIDProperties) + delete(rawMsg, key) + case "warmStoreConfiguration": + err = unpopulate(val, "WarmStoreConfiguration", &g.WarmStoreConfiguration) + 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 Gen2EnvironmentUpdateParameters. +func (g Gen2EnvironmentUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["kind"] = EnvironmentKindGen2 + populate(objectMap, "properties", g.Properties) + populate(objectMap, "tags", g.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Gen2EnvironmentUpdateParameters. +func (g *Gen2EnvironmentUpdateParameters) UnmarshalJSON(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 "kind": + err = unpopulate(val, "Kind", &g.Kind) + 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) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Gen2StorageConfigurationInput. +func (g Gen2StorageConfigurationInput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountName", g.AccountName) + populate(objectMap, "managementKey", g.ManagementKey) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Gen2StorageConfigurationInput. +func (g *Gen2StorageConfigurationInput) UnmarshalJSON(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 "accountName": + err = unpopulate(val, "AccountName", &g.AccountName) + delete(rawMsg, key) + case "managementKey": + err = unpopulate(val, "ManagementKey", &g.ManagementKey) + 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 Gen2StorageConfigurationMutableProperties. +func (g Gen2StorageConfigurationMutableProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "managementKey", g.ManagementKey) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Gen2StorageConfigurationMutableProperties. +func (g *Gen2StorageConfigurationMutableProperties) UnmarshalJSON(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 "managementKey": + err = unpopulate(val, "ManagementKey", &g.ManagementKey) + 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 Gen2StorageConfigurationOutput. +func (g Gen2StorageConfigurationOutput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountName", g.AccountName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Gen2StorageConfigurationOutput. +func (g *Gen2StorageConfigurationOutput) UnmarshalJSON(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 "accountName": + err = unpopulate(val, "AccountName", &g.AccountName) + 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 IngressEnvironmentStatus. +func (i IngressEnvironmentStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "state", i.State) + populate(objectMap, "stateDetails", i.StateDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IngressEnvironmentStatus. +func (i *IngressEnvironmentStatus) UnmarshalJSON(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 "state": + err = unpopulate(val, "State", &i.State) + delete(rawMsg, key) + case "stateDetails": + err = unpopulate(val, "StateDetails", &i.StateDetails) + 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 IngressStartAtProperties. +func (i IngressStartAtProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "time", i.Time) + populate(objectMap, "type", i.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IngressStartAtProperties. +func (i *IngressStartAtProperties) UnmarshalJSON(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 "time": + err = unpopulate(val, "Time", &i.Time) + 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 IoTHubEventSourceCommonProperties. +func (i IoTHubEventSourceCommonProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "consumerGroupName", i.ConsumerGroupName) + populateTimeRFC3339(objectMap, "creationTime", i.CreationTime) + populate(objectMap, "eventSourceResourceId", i.EventSourceResourceID) + populate(objectMap, "ingressStartAt", i.IngressStartAt) + populate(objectMap, "iotHubName", i.IotHubName) + populate(objectMap, "keyName", i.KeyName) + populate(objectMap, "localTimestamp", i.LocalTimestamp) + populate(objectMap, "provisioningState", i.ProvisioningState) + populate(objectMap, "timestampPropertyName", i.TimestampPropertyName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IoTHubEventSourceCommonProperties. +func (i *IoTHubEventSourceCommonProperties) UnmarshalJSON(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 "consumerGroupName": + err = unpopulate(val, "ConsumerGroupName", &i.ConsumerGroupName) + delete(rawMsg, key) + case "creationTime": + err = unpopulateTimeRFC3339(val, "CreationTime", &i.CreationTime) + delete(rawMsg, key) + case "eventSourceResourceId": + err = unpopulate(val, "EventSourceResourceID", &i.EventSourceResourceID) + delete(rawMsg, key) + case "ingressStartAt": + err = unpopulate(val, "IngressStartAt", &i.IngressStartAt) + delete(rawMsg, key) + case "iotHubName": + err = unpopulate(val, "IotHubName", &i.IotHubName) + delete(rawMsg, key) + case "keyName": + err = unpopulate(val, "KeyName", &i.KeyName) + delete(rawMsg, key) + case "localTimestamp": + err = unpopulate(val, "LocalTimestamp", &i.LocalTimestamp) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &i.ProvisioningState) + delete(rawMsg, key) + case "timestampPropertyName": + err = unpopulate(val, "TimestampPropertyName", &i.TimestampPropertyName) + 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 IoTHubEventSourceCreateOrUpdateParameters. +func (i IoTHubEventSourceCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["kind"] = EventSourceKindMicrosoftIoTHub + populate(objectMap, "localTimestamp", i.LocalTimestamp) + populate(objectMap, "location", i.Location) + populate(objectMap, "properties", i.Properties) + populate(objectMap, "tags", i.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IoTHubEventSourceCreateOrUpdateParameters. +func (i *IoTHubEventSourceCreateOrUpdateParameters) UnmarshalJSON(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 "kind": + err = unpopulate(val, "Kind", &i.Kind) + delete(rawMsg, key) + case "localTimestamp": + err = unpopulate(val, "LocalTimestamp", &i.LocalTimestamp) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &i.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &i.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &i.Tags) + 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 IoTHubEventSourceCreationProperties. +func (i IoTHubEventSourceCreationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "consumerGroupName", i.ConsumerGroupName) + populateTimeRFC3339(objectMap, "creationTime", i.CreationTime) + populate(objectMap, "eventSourceResourceId", i.EventSourceResourceID) + populate(objectMap, "ingressStartAt", i.IngressStartAt) + populate(objectMap, "iotHubName", i.IotHubName) + populate(objectMap, "keyName", i.KeyName) + populate(objectMap, "localTimestamp", i.LocalTimestamp) + populate(objectMap, "provisioningState", i.ProvisioningState) + populate(objectMap, "sharedAccessKey", i.SharedAccessKey) + populate(objectMap, "timestampPropertyName", i.TimestampPropertyName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IoTHubEventSourceCreationProperties. +func (i *IoTHubEventSourceCreationProperties) UnmarshalJSON(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 "consumerGroupName": + err = unpopulate(val, "ConsumerGroupName", &i.ConsumerGroupName) + delete(rawMsg, key) + case "creationTime": + err = unpopulateTimeRFC3339(val, "CreationTime", &i.CreationTime) + delete(rawMsg, key) + case "eventSourceResourceId": + err = unpopulate(val, "EventSourceResourceID", &i.EventSourceResourceID) + delete(rawMsg, key) + case "ingressStartAt": + err = unpopulate(val, "IngressStartAt", &i.IngressStartAt) + delete(rawMsg, key) + case "iotHubName": + err = unpopulate(val, "IotHubName", &i.IotHubName) + delete(rawMsg, key) + case "keyName": + err = unpopulate(val, "KeyName", &i.KeyName) + delete(rawMsg, key) + case "localTimestamp": + err = unpopulate(val, "LocalTimestamp", &i.LocalTimestamp) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &i.ProvisioningState) + delete(rawMsg, key) + case "sharedAccessKey": + err = unpopulate(val, "SharedAccessKey", &i.SharedAccessKey) + delete(rawMsg, key) + case "timestampPropertyName": + err = unpopulate(val, "TimestampPropertyName", &i.TimestampPropertyName) + 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 IoTHubEventSourceMutableProperties. +func (i IoTHubEventSourceMutableProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "sharedAccessKey", i.SharedAccessKey) + populate(objectMap, "timestampPropertyName", i.TimestampPropertyName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IoTHubEventSourceMutableProperties. +func (i *IoTHubEventSourceMutableProperties) UnmarshalJSON(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 "sharedAccessKey": + err = unpopulate(val, "SharedAccessKey", &i.SharedAccessKey) + delete(rawMsg, key) + case "timestampPropertyName": + err = unpopulate(val, "TimestampPropertyName", &i.TimestampPropertyName) + 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 IoTHubEventSourceResource. +func (i IoTHubEventSourceResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", i.ID) + objectMap["kind"] = EventSourceResourceKindMicrosoftIoTHub + populate(objectMap, "location", i.Location) + populate(objectMap, "name", i.Name) + populate(objectMap, "properties", i.Properties) + populate(objectMap, "tags", i.Tags) + populate(objectMap, "type", i.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IoTHubEventSourceResource. +func (i *IoTHubEventSourceResource) UnmarshalJSON(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 "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &i.Kind) + 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) + case "properties": + err = unpopulate(val, "Properties", &i.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &i.Tags) + 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 IoTHubEventSourceResourceProperties. +func (i IoTHubEventSourceResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "consumerGroupName", i.ConsumerGroupName) + populateTimeRFC3339(objectMap, "creationTime", i.CreationTime) + populate(objectMap, "eventSourceResourceId", i.EventSourceResourceID) + populate(objectMap, "ingressStartAt", i.IngressStartAt) + populate(objectMap, "iotHubName", i.IotHubName) + populate(objectMap, "keyName", i.KeyName) + populate(objectMap, "localTimestamp", i.LocalTimestamp) + populate(objectMap, "provisioningState", i.ProvisioningState) + populate(objectMap, "timestampPropertyName", i.TimestampPropertyName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IoTHubEventSourceResourceProperties. +func (i *IoTHubEventSourceResourceProperties) UnmarshalJSON(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 "consumerGroupName": + err = unpopulate(val, "ConsumerGroupName", &i.ConsumerGroupName) + delete(rawMsg, key) + case "creationTime": + err = unpopulateTimeRFC3339(val, "CreationTime", &i.CreationTime) + delete(rawMsg, key) + case "eventSourceResourceId": + err = unpopulate(val, "EventSourceResourceID", &i.EventSourceResourceID) + delete(rawMsg, key) + case "ingressStartAt": + err = unpopulate(val, "IngressStartAt", &i.IngressStartAt) + delete(rawMsg, key) + case "iotHubName": + err = unpopulate(val, "IotHubName", &i.IotHubName) + delete(rawMsg, key) + case "keyName": + err = unpopulate(val, "KeyName", &i.KeyName) + delete(rawMsg, key) + case "localTimestamp": + err = unpopulate(val, "LocalTimestamp", &i.LocalTimestamp) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &i.ProvisioningState) + delete(rawMsg, key) + case "timestampPropertyName": + err = unpopulate(val, "TimestampPropertyName", &i.TimestampPropertyName) + 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 IoTHubEventSourceUpdateParameters. +func (i IoTHubEventSourceUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["kind"] = EventSourceKindMicrosoftIoTHub + populate(objectMap, "properties", i.Properties) + populate(objectMap, "tags", i.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IoTHubEventSourceUpdateParameters. +func (i *IoTHubEventSourceUpdateParameters) UnmarshalJSON(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 "kind": + err = unpopulate(val, "Kind", &i.Kind) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &i.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &i.Tags) + 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 LocalTimestamp. +func (l LocalTimestamp) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "format", l.Format) + populate(objectMap, "timeZoneOffset", l.TimeZoneOffset) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LocalTimestamp. +func (l *LocalTimestamp) UnmarshalJSON(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 "format": + err = unpopulate(val, "Format", &l.Format) + delete(rawMsg, key) + case "timeZoneOffset": + err = unpopulate(val, "TimeZoneOffset", &l.TimeZoneOffset) + 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 LocalTimestampTimeZoneOffset. +func (l LocalTimestampTimeZoneOffset) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "propertyName", l.PropertyName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LocalTimestampTimeZoneOffset. +func (l *LocalTimestampTimeZoneOffset) UnmarshalJSON(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 "propertyName": + err = unpopulate(val, "PropertyName", &l.PropertyName) + 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 LogSpecification. +func (l LogSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", l.DisplayName) + populate(objectMap, "name", l.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogSpecification. +func (l *LogSpecification) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &l.DisplayName) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &l.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MetricAvailability. +func (m MetricAvailability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "blobDuration", m.BlobDuration) + populate(objectMap, "timeGrain", m.TimeGrain) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetricAvailability. +func (m *MetricAvailability) UnmarshalJSON(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 "blobDuration": + err = unpopulate(val, "BlobDuration", &m.BlobDuration) + delete(rawMsg, key) + case "timeGrain": + err = unpopulate(val, "TimeGrain", &m.TimeGrain) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MetricSpecification. +func (m MetricSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "aggregationType", m.AggregationType) + populate(objectMap, "availabilities", m.Availabilities) + populate(objectMap, "category", m.Category) + populate(objectMap, "dimensions", m.Dimensions) + populate(objectMap, "displayDescription", m.DisplayDescription) + populate(objectMap, "displayName", m.DisplayName) + populate(objectMap, "name", m.Name) + populate(objectMap, "resourceIdDimensionNameOverride", m.ResourceIDDimensionNameOverride) + populate(objectMap, "unit", m.Unit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MetricSpecification. +func (m *MetricSpecification) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "aggregationType": + err = unpopulate(val, "AggregationType", &m.AggregationType) + delete(rawMsg, key) + case "availabilities": + err = unpopulate(val, "Availabilities", &m.Availabilities) + delete(rawMsg, key) + case "category": + err = unpopulate(val, "Category", &m.Category) + delete(rawMsg, key) + case "dimensions": + err = unpopulate(val, "Dimensions", &m.Dimensions) + delete(rawMsg, key) + case "displayDescription": + err = unpopulate(val, "DisplayDescription", &m.DisplayDescription) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &m.DisplayName) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &m.Name) + delete(rawMsg, key) + case "resourceIdDimensionNameOverride": + err = unpopulate(val, "ResourceIDDimensionNameOverride", &m.ResourceIDDimensionNameOverride) + delete(rawMsg, key) + case "unit": + err = unpopulate(val, "Unit", &m.Unit) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", o.Display) + populate(objectMap, "name", o.Name) + populate(objectMap, "properties", o.OperationProperties) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "OperationProperties", &o.OperationProperties) + 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 OperationProperties. +func (o OperationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "serviceSpecification", o.ServiceSpecification) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationProperties. +func (o *OperationProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "serviceSpecification": + err = unpopulate(val, "ServiceSpecification", &o.ServiceSpecification) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReferenceDataSetCreateOrUpdateParameters. +func (r ReferenceDataSetCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "location", r.Location) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "tags", r.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReferenceDataSetCreateOrUpdateParameters. +func (r *ReferenceDataSetCreateOrUpdateParameters) UnmarshalJSON(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 "location": + err = unpopulate(val, "Location", &r.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + 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 ReferenceDataSetCreationProperties. +func (r ReferenceDataSetCreationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dataStringComparisonBehavior", r.DataStringComparisonBehavior) + populate(objectMap, "keyProperties", r.KeyProperties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReferenceDataSetCreationProperties. +func (r *ReferenceDataSetCreationProperties) UnmarshalJSON(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 "dataStringComparisonBehavior": + err = unpopulate(val, "DataStringComparisonBehavior", &r.DataStringComparisonBehavior) + delete(rawMsg, key) + case "keyProperties": + err = unpopulate(val, "KeyProperties", &r.KeyProperties) + 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 ReferenceDataSetKeyProperty. +func (r ReferenceDataSetKeyProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReferenceDataSetKeyProperty. +func (r *ReferenceDataSetKeyProperty) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "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 ReferenceDataSetListResponse. +func (r ReferenceDataSetListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReferenceDataSetListResponse. +func (r *ReferenceDataSetListResponse) UnmarshalJSON(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 "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 ReferenceDataSetResource. +func (r ReferenceDataSetResource) 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, "properties", r.Properties) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReferenceDataSetResource. +func (r *ReferenceDataSetResource) UnmarshalJSON(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 "properties": + err = unpopulate(val, "Properties", &r.Properties) + 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 ReferenceDataSetResourceProperties. +func (r ReferenceDataSetResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "creationTime", r.CreationTime) + populate(objectMap, "dataStringComparisonBehavior", r.DataStringComparisonBehavior) + populate(objectMap, "keyProperties", r.KeyProperties) + populate(objectMap, "provisioningState", r.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReferenceDataSetResourceProperties. +func (r *ReferenceDataSetResourceProperties) UnmarshalJSON(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 "creationTime": + err = unpopulateTimeRFC3339(val, "CreationTime", &r.CreationTime) + delete(rawMsg, key) + case "dataStringComparisonBehavior": + err = unpopulate(val, "DataStringComparisonBehavior", &r.DataStringComparisonBehavior) + delete(rawMsg, key) + case "keyProperties": + err = unpopulate(val, "KeyProperties", &r.KeyProperties) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) + 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 ReferenceDataSetUpdateParameters. +func (r ReferenceDataSetUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", r.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReferenceDataSetUpdateParameters. +func (r *ReferenceDataSetUpdateParameters) UnmarshalJSON(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 "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceProperties. +func (r ResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "creationTime", r.CreationTime) + populate(objectMap, "provisioningState", r.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProperties. +func (r *ResourceProperties) UnmarshalJSON(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 "creationTime": + err = unpopulateTimeRFC3339(val, "CreationTime", &r.CreationTime) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SKU. +func (s SKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "capacity", s.Capacity) + populate(objectMap, "name", s.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKU. +func (s *SKU) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "capacity": + err = unpopulate(val, "Capacity", &s.Capacity) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceSpecification. +func (s ServiceSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "logSpecifications", s.LogSpecifications) + populate(objectMap, "metricSpecifications", s.MetricSpecifications) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceSpecification. +func (s *ServiceSpecification) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "logSpecifications": + err = unpopulate(val, "LogSpecifications", &s.LogSpecifications) + delete(rawMsg, key) + case "metricSpecifications": + err = unpopulate(val, "MetricSpecifications", &s.MetricSpecifications) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TimeSeriesIDProperty. +func (t TimeSeriesIDProperty) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", t.Name) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TimeSeriesIDProperty. +func (t *TimeSeriesIDProperty) UnmarshalJSON(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 "name": + err = unpopulate(val, "Name", &t.Name) + 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 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 WarmStorageEnvironmentStatus. +func (w WarmStorageEnvironmentStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "propertiesUsage", w.PropertiesUsage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WarmStorageEnvironmentStatus. +func (w *WarmStorageEnvironmentStatus) UnmarshalJSON(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 "propertiesUsage": + err = unpopulate(val, "PropertiesUsage", &w.PropertiesUsage) + 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 WarmStoragePropertiesUsage. +func (w WarmStoragePropertiesUsage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "state", w.State) + populate(objectMap, "stateDetails", w.StateDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WarmStoragePropertiesUsage. +func (w *WarmStoragePropertiesUsage) UnmarshalJSON(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 "state": + err = unpopulate(val, "State", &w.State) + delete(rawMsg, key) + case "stateDetails": + err = unpopulate(val, "StateDetails", &w.StateDetails) + 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 WarmStoragePropertiesUsageStateDetails. +func (w WarmStoragePropertiesUsageStateDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "currentCount", w.CurrentCount) + populate(objectMap, "maxCount", w.MaxCount) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WarmStoragePropertiesUsageStateDetails. +func (w *WarmStoragePropertiesUsageStateDetails) UnmarshalJSON(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 "currentCount": + err = unpopulate(val, "CurrentCount", &w.CurrentCount) + delete(rawMsg, key) + case "maxCount": + err = unpopulate(val, "MaxCount", &w.MaxCount) + 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 WarmStoreConfigurationProperties. +func (w WarmStoreConfigurationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dataRetention", w.DataRetention) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WarmStoreConfigurationProperties. +func (w *WarmStoreConfigurationProperties) UnmarshalJSON(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 "dataRetention": + err = unpopulate(val, "DataRetention", &w.DataRetention) + 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/timeseriesinsights/armtimeseriesinsights/zz_generated_operations_client.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/operations_client.go similarity index 77% rename from sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_operations_client.go rename to sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/operations_client.go index d8ae70d7f40e..047eac35d997 100644 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_operations_client.go +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/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 armtimeseriesinsights @@ -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 Time Series Insights related operations. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// 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.TimeSeriesInsights/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/timeseriesinsights/armtimeseriesinsights/operations_client_example_test.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/operations_client_example_test.go new file mode 100644 index 000000000000..69ae24e62e5a --- /dev/null +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/operations_client_example_test.go @@ -0,0 +1,598 @@ +//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 armtimeseriesinsights_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/Operation_List.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.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 = armtimeseriesinsights.OperationListResult{ + // Value: []*armtimeseriesinsights.Operation{ + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/register/action"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Registers the subscription for the Time Series Insights resource provider and enables the creation of Time Series Insights environments."), + // Operation: to.Ptr("Registers the Time Series Insights Resource Provider"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Time Series Insights Resource Provider"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/providers/Microsoft.Insights/metricDefinitions/read"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Gets the available metrics for environments"), + // Operation: to.Ptr("Read environments metric definitions"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("The metrics definition of environments"), + // }, + // Origin: to.Ptr("system"), + // OperationProperties: &armtimeseriesinsights.OperationProperties{ + // ServiceSpecification: &armtimeseriesinsights.ServiceSpecification{ + // MetricSpecifications: []*armtimeseriesinsights.MetricSpecification{ + // { + // Name: to.Ptr("IngressReceivedMessages"), + // AggregationType: to.Ptr("Total"), + // Availabilities: []*armtimeseriesinsights.MetricAvailability{ + // { + // BlobDuration: to.Ptr("PT1H"), + // TimeGrain: to.Ptr("PT1M"), + // }}, + // DisplayDescription: to.Ptr("Count of messages read from all Event hub or IoT hub event sources"), + // DisplayName: to.Ptr("Ingress Received Messages"), + // Unit: to.Ptr("Count"), + // }, + // { + // Name: to.Ptr("IngressReceivedInvalidMessages"), + // AggregationType: to.Ptr("Total"), + // Availabilities: []*armtimeseriesinsights.MetricAvailability{ + // { + // BlobDuration: to.Ptr("PT1H"), + // TimeGrain: to.Ptr("PT1M"), + // }}, + // DisplayDescription: to.Ptr("Count of invalid messages read from all Event hub or IoT hub event sources"), + // DisplayName: to.Ptr("Ingress Received Invalid Messages"), + // Unit: to.Ptr("Count"), + // }, + // { + // Name: to.Ptr("IngressReceivedBytes"), + // AggregationType: to.Ptr("Total"), + // Availabilities: []*armtimeseriesinsights.MetricAvailability{ + // { + // BlobDuration: to.Ptr("PT1H"), + // TimeGrain: to.Ptr("PT1M"), + // }}, + // DisplayDescription: to.Ptr("Count of bytes read from all event sources"), + // DisplayName: to.Ptr("Ingress Received Bytes"), + // Unit: to.Ptr("Bytes"), + // }, + // { + // Name: to.Ptr("IngressStoredBytes"), + // AggregationType: to.Ptr("Total"), + // Availabilities: []*armtimeseriesinsights.MetricAvailability{ + // { + // BlobDuration: to.Ptr("PT1H"), + // TimeGrain: to.Ptr("PT1M"), + // }}, + // DisplayDescription: to.Ptr("Total size of events successfully processed and available for query"), + // DisplayName: to.Ptr("Ingress Stored Bytes"), + // Unit: to.Ptr("Bytes"), + // }, + // { + // Name: to.Ptr("IngressStoredEvents"), + // AggregationType: to.Ptr("Total"), + // Availabilities: []*armtimeseriesinsights.MetricAvailability{ + // { + // BlobDuration: to.Ptr("PT1H"), + // TimeGrain: to.Ptr("PT1M"), + // }}, + // DisplayDescription: to.Ptr("Count of flattened events successfully processed and available for query"), + // DisplayName: to.Ptr("Ingress Stored Events"), + // Unit: to.Ptr("Count"), + // }, + // { + // Name: to.Ptr("IngressReceivedMessagesTimeLag"), + // AggregationType: to.Ptr("Maximum"), + // Availabilities: []*armtimeseriesinsights.MetricAvailability{ + // { + // BlobDuration: to.Ptr("PT1H"), + // TimeGrain: to.Ptr("PT1M"), + // }}, + // DisplayDescription: to.Ptr("Difference between the time that the message is enqueued in the event source and the time it is processed in Ingress"), + // DisplayName: to.Ptr("Ingress Received Messages Time Lag"), + // Unit: to.Ptr("Seconds"), + // }, + // { + // Name: to.Ptr("IngressReceivedMessagesCountLag"), + // AggregationType: to.Ptr("Average"), + // Availabilities: []*armtimeseriesinsights.MetricAvailability{ + // { + // BlobDuration: to.Ptr("PT1H"), + // TimeGrain: to.Ptr("PT1M"), + // }}, + // DisplayDescription: to.Ptr("Difference between the sequence number of last enqueued message in the event source partition and sequence number of messages being processed in Ingress"), + // DisplayName: to.Ptr("Ingress Received Messages Count Lag"), + // Unit: to.Ptr("Count"), + // }, + // { + // Name: to.Ptr("WarmStorageMaxProperties"), + // AggregationType: to.Ptr("Maximum"), + // Availabilities: []*armtimeseriesinsights.MetricAvailability{ + // { + // BlobDuration: to.Ptr("PT1H"), + // TimeGrain: to.Ptr("PT1M"), + // }}, + // DisplayDescription: to.Ptr("Maximum number of properties used allowed by the environment for S1/S2 SKU and maximum number of properties allowed by Warm Store for PAYG SKU"), + // DisplayName: to.Ptr("Warm Storage Max Properties"), + // Unit: to.Ptr("Count"), + // }, + // { + // Name: to.Ptr("WarmStorageUsedProperties"), + // AggregationType: to.Ptr("Maximum"), + // Availabilities: []*armtimeseriesinsights.MetricAvailability{ + // { + // BlobDuration: to.Ptr("PT1H"), + // TimeGrain: to.Ptr("PT1M"), + // }}, + // DisplayDescription: to.Ptr("Number of properties used by the environment for S1/S2 SKU and number of properties used by Warm Store for PAYG SKU"), + // DisplayName: to.Ptr("Warm Storage Used Properties "), + // Unit: to.Ptr("Count"), + // }}, + // }, + // }, + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/providers/Microsoft.Insights/diagnosticSettings/read"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Gets the diagnostic setting for the resource"), + // Operation: to.Ptr("Read diagnostic setting."), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("environments"), + // }, + // Origin: to.Ptr("system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/providers/Microsoft.Insights/diagnosticSettings/write"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Creates or updates the diagnostic setting for the resource"), + // Operation: to.Ptr("Write diagnostic setting."), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("environments"), + // }, + // Origin: to.Ptr("system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/providers/Microsoft.Insights/logDefinitions/read"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Gets the available logs for environments"), + // Operation: to.Ptr("Read environments log definitions"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("environments"), + // }, + // Origin: to.Ptr("system"), + // OperationProperties: &armtimeseriesinsights.OperationProperties{ + // ServiceSpecification: &armtimeseriesinsights.ServiceSpecification{ + // LogSpecifications: []*armtimeseriesinsights.LogSpecification{ + // { + // Name: to.Ptr("Ingress"), + // DisplayName: to.Ptr("Ingress"), + // }, + // { + // Name: to.Ptr("Management"), + // DisplayName: to.Ptr("Management"), + // }}, + // }, + // }, + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/eventsources/providers/Microsoft.Insights/logDefinitions/read"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Gets the available logs for the event source"), + // Operation: to.Ptr("Read event source log definitions"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Event Source"), + // }, + // Origin: to.Ptr("system"), + // OperationProperties: &armtimeseriesinsights.OperationProperties{ + // ServiceSpecification: &armtimeseriesinsights.ServiceSpecification{ + // LogSpecifications: []*armtimeseriesinsights.LogSpecification{ + // { + // Name: to.Ptr("Ingress"), + // DisplayName: to.Ptr("Ingress"), + // }, + // { + // Name: to.Ptr("Management"), + // DisplayName: to.Ptr("Management"), + // }}, + // }, + // }, + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/eventsources/providers/Microsoft.Insights/metricDefinitions/read"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Gets the available metrics for eventsources"), + // Operation: to.Ptr("Read eventsources metric definitions"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("The metrics definition of environments/eventsources"), + // }, + // Origin: to.Ptr("system"), + // OperationProperties: &armtimeseriesinsights.OperationProperties{ + // ServiceSpecification: &armtimeseriesinsights.ServiceSpecification{ + // MetricSpecifications: []*armtimeseriesinsights.MetricSpecification{ + // { + // Name: to.Ptr("IngressReceivedMessages"), + // AggregationType: to.Ptr("Total"), + // Availabilities: []*armtimeseriesinsights.MetricAvailability{ + // { + // BlobDuration: to.Ptr("PT1H"), + // TimeGrain: to.Ptr("PT1M"), + // }}, + // DisplayDescription: to.Ptr("Count of messages read from the event source"), + // DisplayName: to.Ptr("Ingress Received Messages"), + // Unit: to.Ptr("Count"), + // }, + // { + // Name: to.Ptr("IngressReceivedInvalidMessages"), + // AggregationType: to.Ptr("Total"), + // Availabilities: []*armtimeseriesinsights.MetricAvailability{ + // { + // BlobDuration: to.Ptr("PT1H"), + // TimeGrain: to.Ptr("PT1M"), + // }}, + // DisplayDescription: to.Ptr("Count of invalid messages read from the event source"), + // DisplayName: to.Ptr("Ingress Received Invalid Messages"), + // Unit: to.Ptr("Count"), + // }, + // { + // Name: to.Ptr("IngressReceivedBytes"), + // AggregationType: to.Ptr("Total"), + // Availabilities: []*armtimeseriesinsights.MetricAvailability{ + // { + // BlobDuration: to.Ptr("PT1H"), + // TimeGrain: to.Ptr("PT1M"), + // }}, + // DisplayDescription: to.Ptr("Count of bytes read from the event source"), + // DisplayName: to.Ptr("Ingress Received Bytes"), + // Unit: to.Ptr("Bytes"), + // }, + // { + // Name: to.Ptr("IngressStoredBytes"), + // AggregationType: to.Ptr("Total"), + // Availabilities: []*armtimeseriesinsights.MetricAvailability{ + // { + // BlobDuration: to.Ptr("PT1H"), + // TimeGrain: to.Ptr("PT1M"), + // }}, + // DisplayDescription: to.Ptr("Total size of events successfully processed and available for query"), + // DisplayName: to.Ptr("Ingress Stored Bytes"), + // Unit: to.Ptr("Bytes"), + // }, + // { + // Name: to.Ptr("IngressStoredEvents"), + // AggregationType: to.Ptr("Total"), + // Availabilities: []*armtimeseriesinsights.MetricAvailability{ + // { + // BlobDuration: to.Ptr("PT1H"), + // TimeGrain: to.Ptr("PT1M"), + // }}, + // DisplayDescription: to.Ptr("Count of flattened events successfully processed and available for query"), + // DisplayName: to.Ptr("Ingress Stored Events"), + // Unit: to.Ptr("Count"), + // }, + // { + // Name: to.Ptr("IngressReceivedMessagesTimeLag"), + // AggregationType: to.Ptr("Maximum"), + // Availabilities: []*armtimeseriesinsights.MetricAvailability{ + // { + // BlobDuration: to.Ptr("PT1H"), + // TimeGrain: to.Ptr("PT1M"), + // }}, + // DisplayDescription: to.Ptr("Difference between the time that the message is enqueued in the event source and the time it is processed in Ingress"), + // DisplayName: to.Ptr("Ingress Received Messages Time Lag"), + // Unit: to.Ptr("Seconds"), + // }, + // { + // Name: to.Ptr("IngressReceivedMessagesCountLag"), + // AggregationType: to.Ptr("Average"), + // Availabilities: []*armtimeseriesinsights.MetricAvailability{ + // { + // BlobDuration: to.Ptr("PT1H"), + // TimeGrain: to.Ptr("PT1M"), + // }}, + // DisplayDescription: to.Ptr("Difference between the sequence number of last enqueued message in the event source partition and sequence number of messages being processed in Ingress"), + // DisplayName: to.Ptr("Ingress Received Messages Count Lag"), + // Unit: to.Ptr("Count"), + // }, + // { + // Name: to.Ptr("WarmStorageMaxProperties"), + // AggregationType: to.Ptr("Maximum"), + // Availabilities: []*armtimeseriesinsights.MetricAvailability{ + // { + // BlobDuration: to.Ptr("PT1H"), + // TimeGrain: to.Ptr("PT1M"), + // }}, + // DisplayDescription: to.Ptr("Maximum number of properties used allowed by the environment for S1/S2 SKU and maximum number of properties allowed by Warm Store for PAYG SKU"), + // DisplayName: to.Ptr("Warm Storage Max Properties"), + // Unit: to.Ptr("Count"), + // }, + // { + // Name: to.Ptr("WarmStorageUsedProperties"), + // AggregationType: to.Ptr("Maximum"), + // Availabilities: []*armtimeseriesinsights.MetricAvailability{ + // { + // BlobDuration: to.Ptr("PT1H"), + // TimeGrain: to.Ptr("PT1M"), + // }}, + // DisplayDescription: to.Ptr("Number of properties used by the environment for S1/S2 SKU and number of properties used by Warm Store for PAYG SKU"), + // DisplayName: to.Ptr("Warm Storage Used Properties "), + // Unit: to.Ptr("Count"), + // }}, + // }, + // }, + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/eventsources/providers/Microsoft.Insights/diagnosticSettings/read"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Gets the diagnostic setting for the resource"), + // Operation: to.Ptr("Read diagnostic setting."), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("environments/eventsources"), + // }, + // Origin: to.Ptr("system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/eventsources/providers/Microsoft.Insights/diagnosticSettings/write"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Creates or updates the diagnostic setting for the resource"), + // Operation: to.Ptr("Write diagnostic setting."), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("environments/eventsources"), + // }, + // Origin: to.Ptr("system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/read"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Get the properties of an environment."), + // Operation: to.Ptr("Read Environment"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Environment"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/write"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Creates a new environment, or updates an existing environment."), + // Operation: to.Ptr("Create or Update Environment"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Environment"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/delete"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Deletes the environment."), + // Operation: to.Ptr("Delete Environment"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Environment"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/status/read"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Get the status of the environment, state of its associated operations like ingress."), + // Operation: to.Ptr("Read Environment status"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Environment"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/eventsources/read"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Get the properties of an event source."), + // Operation: to.Ptr("Read Event Source"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Event Source"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/eventsources/write"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Creates a new event source for an environment, or updates an existing event source."), + // Operation: to.Ptr("Create or Update Event Source"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Event Source"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/eventsources/delete"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Deletes the event source."), + // Operation: to.Ptr("Delete Event Source"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Event Source"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/referencedatasets/read"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Get the properties of a reference data set."), + // Operation: to.Ptr("Read Reference Data Set"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Reference Data Set"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/referencedatasets/write"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Creates a new reference data set for an environment, or updates an existing reference data set."), + // Operation: to.Ptr("Create or Update Reference Data Set"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Reference Data Set"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/referencedatasets/delete"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Deletes the reference data set."), + // Operation: to.Ptr("Delete Reference Data Set"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Reference Data Set"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/accesspolicies/read"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Get the properties of an access policy."), + // Operation: to.Ptr("Read Access Policy"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Access Policy"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/accesspolicies/write"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Creates a new access policy for an environment, or updates an existing access policy."), + // Operation: to.Ptr("Create or Update Access Policy"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Access Policy"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/accesspolicies/delete"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Deletes the access policy."), + // Operation: to.Ptr("Delete Access Policy"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Access Policy"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/privateEndpointConnectionProxies/read"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Get the properties of a private endpoint connection proxy."), + // Operation: to.Ptr("Read private endpoint connection proxy"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Private endpoint connection proxy"), + // }, + // Origin: to.Ptr("system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/privateEndpointConnectionProxies/write"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Creates a new private endpoint connection proxy for an environment, or updates an existing connection proxy."), + // Operation: to.Ptr("Create or Update private endpoint connection proxy"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Private endpoint connection proxy"), + // }, + // Origin: to.Ptr("system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/privateEndpointConnectionProxies/delete"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Deletes the private endpoint connection proxy."), + // Operation: to.Ptr("Delete the private endpoint connection proxy"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Private endpoint connection proxy"), + // }, + // Origin: to.Ptr("system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/privateEndpointConnectionProxies/validate/action"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Validate the private endpoint connection proxy object before creation."), + // Operation: to.Ptr("Validate the private endpoint connection proxy."), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Private endpoint connection proxy"), + // }, + // Origin: to.Ptr("system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/privateEndpointConnectionProxies/operationresults/read"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Validate the private endpoint connection proxy operation status."), + // Operation: to.Ptr("Get private endpoint connection proxy operation status."), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Private endpoint connection proxy"), + // }, + // Origin: to.Ptr("system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/privateendpointConnections/read"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Get the properties of a private endpoint connection."), + // Operation: to.Ptr("Read private endpoint connection."), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Private endpoint connection."), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/privateendpointConnections/write"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Creates a new private endpoint connection for an environment, or updates an existing connection."), + // Operation: to.Ptr("Create or Update private endpoint connection."), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Private endpoint connection."), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.TimeSeriesInsights/environments/privateendpointConnections/delete"), + // Display: &armtimeseriesinsights.OperationDisplay{ + // Description: to.Ptr("Deletes the private endpoint connection."), + // Operation: to.Ptr("Delete the private endpoint connection"), + // Provider: to.Ptr("Microsoft Time Series Insights"), + // Resource: to.Ptr("Private endpoint connection"), + // }, + // Origin: to.Ptr("user,system"), + // }}, + // } + } +} diff --git a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_polymorphic_helpers.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/polymorphic_helpers.go similarity index 97% rename from sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_polymorphic_helpers.go rename to sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/polymorphic_helpers.go index 4ea74ec5e081..70f190f1ec1b 100644 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_polymorphic_helpers.go +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/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 armtimeseriesinsights @@ -14,7 +15,7 @@ func unmarshalEnvironmentResourceClassification(rawMsg json.RawMessage) (Environ 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 } @@ -53,7 +54,7 @@ func unmarshalEventSourceResourceClassification(rawMsg json.RawMessage) (EventSo 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/timeseriesinsights/armtimeseriesinsights/zz_generated_referencedatasets_client.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/referencedatasets_client.go similarity index 83% rename from sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_referencedatasets_client.go rename to sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/referencedatasets_client.go index f48361efbb9e..14faf31b5ca2 100644 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_referencedatasets_client.go +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/referencedatasets_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 armtimeseriesinsights @@ -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 ( // ReferenceDataSetsClient contains the methods for the ReferenceDataSets group. // Don't use this type directly, use NewReferenceDataSetsClient() instead. type ReferenceDataSetsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewReferenceDataSetsClient creates a new instance of ReferenceDataSetsClient with the specified values. -// subscriptionID - Azure Subscription ID. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Azure Subscription ID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewReferenceDataSetsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ReferenceDataSetsClient, 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+".ReferenceDataSetsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ReferenceDataSetsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or update a reference data set in the specified environment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// environmentName - The name of the Time Series Insights environment associated with the specified resource group. -// referenceDataSetName - Name of the reference data set. -// parameters - Parameters for creating a reference data set. -// options - ReferenceDataSetsClientCreateOrUpdateOptions contains the optional parameters for the ReferenceDataSetsClient.CreateOrUpdate -// method. +// - resourceGroupName - Name of an Azure Resource group. +// - environmentName - The name of the Time Series Insights environment associated with the specified resource group. +// - referenceDataSetName - Name of the reference data set. +// - parameters - Parameters for creating a reference data set. +// - options - ReferenceDataSetsClientCreateOrUpdateOptions contains the optional parameters for the ReferenceDataSetsClient.CreateOrUpdate +// method. func (client *ReferenceDataSetsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, environmentName string, referenceDataSetName string, parameters ReferenceDataSetCreateOrUpdateParameters, options *ReferenceDataSetsClientCreateOrUpdateOptions) (ReferenceDataSetsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, environmentName, referenceDataSetName, parameters, options) if err != nil { return ReferenceDataSetsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ReferenceDataSetsClientCreateOrUpdateResponse{}, err } @@ -97,7 +88,7 @@ func (client *ReferenceDataSetsClient) createOrUpdateCreateRequest(ctx context.C return nil, errors.New("parameter referenceDataSetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{referenceDataSetName}", url.PathEscape(referenceDataSetName)) - 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,18 +110,19 @@ func (client *ReferenceDataSetsClient) createOrUpdateHandleResponse(resp *http.R // Delete - Deletes the reference data set with the specified name in the specified subscription, resource group, and environment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// environmentName - The name of the Time Series Insights environment associated with the specified resource group. -// referenceDataSetName - The name of the Time Series Insights reference data set associated with the specified environment. -// options - ReferenceDataSetsClientDeleteOptions contains the optional parameters for the ReferenceDataSetsClient.Delete -// method. +// - resourceGroupName - Name of an Azure Resource group. +// - environmentName - The name of the Time Series Insights environment associated with the specified resource group. +// - referenceDataSetName - The name of the Time Series Insights reference data set associated with the specified environment. +// - options - ReferenceDataSetsClientDeleteOptions contains the optional parameters for the ReferenceDataSetsClient.Delete +// method. func (client *ReferenceDataSetsClient) Delete(ctx context.Context, resourceGroupName string, environmentName string, referenceDataSetName string, options *ReferenceDataSetsClientDeleteOptions) (ReferenceDataSetsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, environmentName, referenceDataSetName, options) if err != nil { return ReferenceDataSetsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ReferenceDataSetsClientDeleteResponse{}, err } @@ -159,7 +151,7 @@ func (client *ReferenceDataSetsClient) deleteCreateRequest(ctx context.Context, return nil, errors.New("parameter referenceDataSetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{referenceDataSetName}", url.PathEscape(referenceDataSetName)) - 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 *ReferenceDataSetsClient) deleteCreateRequest(ctx context.Context, // Get - Gets the reference data set with the specified name in the specified environment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// environmentName - The name of the Time Series Insights environment associated with the specified resource group. -// referenceDataSetName - The name of the Time Series Insights reference data set associated with the specified environment. -// options - ReferenceDataSetsClientGetOptions contains the optional parameters for the ReferenceDataSetsClient.Get method. +// - resourceGroupName - Name of an Azure Resource group. +// - environmentName - The name of the Time Series Insights environment associated with the specified resource group. +// - referenceDataSetName - The name of the Time Series Insights reference data set associated with the specified environment. +// - options - ReferenceDataSetsClientGetOptions contains the optional parameters for the ReferenceDataSetsClient.Get method. func (client *ReferenceDataSetsClient) Get(ctx context.Context, resourceGroupName string, environmentName string, referenceDataSetName string, options *ReferenceDataSetsClientGetOptions) (ReferenceDataSetsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, environmentName, referenceDataSetName, options) if err != nil { return ReferenceDataSetsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ReferenceDataSetsClientGetResponse{}, err } @@ -211,7 +204,7 @@ func (client *ReferenceDataSetsClient) getCreateRequest(ctx context.Context, res return nil, errors.New("parameter referenceDataSetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{referenceDataSetName}", url.PathEscape(referenceDataSetName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -234,17 +227,18 @@ func (client *ReferenceDataSetsClient) getHandleResponse(resp *http.Response) (R // ListByEnvironment - Lists all the available reference data sets associated with the subscription and within the specified // resource group and environment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// environmentName - The name of the Time Series Insights environment associated with the specified resource group. -// options - ReferenceDataSetsClientListByEnvironmentOptions contains the optional parameters for the ReferenceDataSetsClient.ListByEnvironment -// method. +// - resourceGroupName - Name of an Azure Resource group. +// - environmentName - The name of the Time Series Insights environment associated with the specified resource group. +// - options - ReferenceDataSetsClientListByEnvironmentOptions contains the optional parameters for the ReferenceDataSetsClient.ListByEnvironment +// method. func (client *ReferenceDataSetsClient) ListByEnvironment(ctx context.Context, resourceGroupName string, environmentName string, options *ReferenceDataSetsClientListByEnvironmentOptions) (ReferenceDataSetsClientListByEnvironmentResponse, error) { req, err := client.listByEnvironmentCreateRequest(ctx, resourceGroupName, environmentName, options) if err != nil { return ReferenceDataSetsClientListByEnvironmentResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ReferenceDataSetsClientListByEnvironmentResponse{}, err } @@ -269,7 +263,7 @@ func (client *ReferenceDataSetsClient) listByEnvironmentCreateRequest(ctx contex return nil, errors.New("parameter environmentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{environmentName}", url.PathEscape(environmentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -291,19 +285,20 @@ func (client *ReferenceDataSetsClient) listByEnvironmentHandleResponse(resp *htt // Update - Updates the reference data set with the specified name in the specified subscription, resource group, and environment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-15 -// resourceGroupName - Name of an Azure Resource group. -// environmentName - The name of the Time Series Insights environment associated with the specified resource group. -// referenceDataSetName - The name of the Time Series Insights reference data set associated with the specified environment. -// referenceDataSetUpdateParameters - Request object that contains the updated information for the reference data set. -// options - ReferenceDataSetsClientUpdateOptions contains the optional parameters for the ReferenceDataSetsClient.Update -// method. +// - resourceGroupName - Name of an Azure Resource group. +// - environmentName - The name of the Time Series Insights environment associated with the specified resource group. +// - referenceDataSetName - The name of the Time Series Insights reference data set associated with the specified environment. +// - referenceDataSetUpdateParameters - Request object that contains the updated information for the reference data set. +// - options - ReferenceDataSetsClientUpdateOptions contains the optional parameters for the ReferenceDataSetsClient.Update +// method. func (client *ReferenceDataSetsClient) Update(ctx context.Context, resourceGroupName string, environmentName string, referenceDataSetName string, referenceDataSetUpdateParameters ReferenceDataSetUpdateParameters, options *ReferenceDataSetsClientUpdateOptions) (ReferenceDataSetsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, environmentName, referenceDataSetName, referenceDataSetUpdateParameters, options) if err != nil { return ReferenceDataSetsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ReferenceDataSetsClientUpdateResponse{}, err } @@ -332,7 +327,7 @@ func (client *ReferenceDataSetsClient) updateCreateRequest(ctx context.Context, return nil, errors.New("parameter referenceDataSetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{referenceDataSetName}", url.PathEscape(referenceDataSetName)) - 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/timeseriesinsights/armtimeseriesinsights/referencedatasets_client_example_test.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/referencedatasets_client_example_test.go new file mode 100644 index 000000000000..aff884216ded --- /dev/null +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/referencedatasets_client_example_test.go @@ -0,0 +1,221 @@ +//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 armtimeseriesinsights_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/timeseriesinsights/armtimeseriesinsights" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/ReferenceDataSetsCreate.json +func ExampleReferenceDataSetsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewReferenceDataSetsClient().CreateOrUpdate(ctx, "rg1", "env1", "rds1", armtimeseriesinsights.ReferenceDataSetCreateOrUpdateParameters{ + Location: to.Ptr("West US"), + Properties: &armtimeseriesinsights.ReferenceDataSetCreationProperties{ + KeyProperties: []*armtimeseriesinsights.ReferenceDataSetKeyProperty{ + { + Name: to.Ptr("DeviceId1"), + Type: to.Ptr(armtimeseriesinsights.ReferenceDataKeyPropertyTypeString), + }, + { + Name: to.Ptr("DeviceFloor"), + Type: to.Ptr(armtimeseriesinsights.ReferenceDataKeyPropertyTypeDouble), + }}, + }, + }, 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.ReferenceDataSetResource = armtimeseriesinsights.ReferenceDataSetResource{ + // Name: to.Ptr("rds1"), + // Type: to.Ptr("Microsoft.TimeSeriesInsights/Environments/ReferenceDataSets"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.TimeSeriesInsights/Environments/env1/referenceDataSets/rds1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // }, + // Properties: &armtimeseriesinsights.ReferenceDataSetResourceProperties{ + // KeyProperties: []*armtimeseriesinsights.ReferenceDataSetKeyProperty{ + // { + // Name: to.Ptr("DeviceId1"), + // Type: to.Ptr(armtimeseriesinsights.ReferenceDataKeyPropertyTypeString), + // }, + // { + // Name: to.Ptr("DeviceFloor"), + // Type: to.Ptr(armtimeseriesinsights.ReferenceDataKeyPropertyTypeDouble), + // }}, + // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-18T19:20:33.2288820Z"); return t}()), + // ProvisioningState: to.Ptr(armtimeseriesinsights.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/ReferenceDataSetsGet.json +func ExampleReferenceDataSetsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewReferenceDataSetsClient().Get(ctx, "rg1", "env1", "rds1", 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.ReferenceDataSetResource = armtimeseriesinsights.ReferenceDataSetResource{ + // Name: to.Ptr("rds1"), + // Type: to.Ptr("Microsoft.TimeSeriesInsights/Environments/ReferenceDataSets"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.TimeSeriesInsights/Environments/env1/referenceDataSets/rds1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // }, + // Properties: &armtimeseriesinsights.ReferenceDataSetResourceProperties{ + // KeyProperties: []*armtimeseriesinsights.ReferenceDataSetKeyProperty{ + // { + // Name: to.Ptr("DeviceId1"), + // Type: to.Ptr(armtimeseriesinsights.ReferenceDataKeyPropertyTypeString), + // }, + // { + // Name: to.Ptr("DeviceFloor"), + // Type: to.Ptr(armtimeseriesinsights.ReferenceDataKeyPropertyTypeDouble), + // }}, + // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-18T19:20:33.2288820Z"); return t}()), + // ProvisioningState: to.Ptr(armtimeseriesinsights.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/ReferenceDataSetsPatchTags.json +func ExampleReferenceDataSetsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewReferenceDataSetsClient().Update(ctx, "rg1", "env1", "rds1", armtimeseriesinsights.ReferenceDataSetUpdateParameters{ + Tags: map[string]*string{ + "someKey": to.Ptr("someValue"), + }, + }, 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.ReferenceDataSetResource = armtimeseriesinsights.ReferenceDataSetResource{ + // Name: to.Ptr("rds1"), + // Type: to.Ptr("Microsoft.TimeSeriesInsights/Environments/ReferenceDataSets"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.TimeSeriesInsights/Environments/env1/referenceDataSets/rds1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "someKey": to.Ptr("someValue"), + // }, + // Properties: &armtimeseriesinsights.ReferenceDataSetResourceProperties{ + // KeyProperties: []*armtimeseriesinsights.ReferenceDataSetKeyProperty{ + // { + // Name: to.Ptr("DeviceId1"), + // Type: to.Ptr(armtimeseriesinsights.ReferenceDataKeyPropertyTypeString), + // }, + // { + // Name: to.Ptr("DeviceFloor"), + // Type: to.Ptr(armtimeseriesinsights.ReferenceDataKeyPropertyTypeDouble), + // }}, + // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-18T19:20:33.2288820Z"); return t}()), + // ProvisioningState: to.Ptr(armtimeseriesinsights.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/ReferenceDataSetsDelete.json +func ExampleReferenceDataSetsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewReferenceDataSetsClient().Delete(ctx, "rg1", "env1", "rds1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/ReferenceDataSetsListByEnvironment.json +func ExampleReferenceDataSetsClient_ListByEnvironment() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armtimeseriesinsights.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewReferenceDataSetsClient().ListByEnvironment(ctx, "rg1", "env1", 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.ReferenceDataSetListResponse = armtimeseriesinsights.ReferenceDataSetListResponse{ + // Value: []*armtimeseriesinsights.ReferenceDataSetResource{ + // { + // Name: to.Ptr("rds1"), + // Type: to.Ptr("Microsoft.TimeSeriesInsights/Environments/ReferenceDataSets"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.TimeSeriesInsights/Environments/env1/referenceDataSets/rds1"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // }, + // Properties: &armtimeseriesinsights.ReferenceDataSetResourceProperties{ + // KeyProperties: []*armtimeseriesinsights.ReferenceDataSetKeyProperty{ + // { + // Name: to.Ptr("DeviceId1"), + // Type: to.Ptr(armtimeseriesinsights.ReferenceDataKeyPropertyTypeString), + // }, + // { + // Name: to.Ptr("DeviceFloor"), + // Type: to.Ptr(armtimeseriesinsights.ReferenceDataKeyPropertyTypeDouble), + // }}, + // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-18T19:20:33.2288820Z"); return t}()), + // ProvisioningState: to.Ptr(armtimeseriesinsights.ProvisioningStateSucceeded), + // }, + // }}, + // } +} diff --git a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_response_types.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/response_types.go similarity index 97% rename from sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_response_types.go rename to sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/response_types.go index fc5ff2a1c6fc..c191576abb86 100644 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_response_types.go +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/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 armtimeseriesinsights @@ -33,7 +34,7 @@ type AccessPoliciesClientUpdateResponse struct { AccessPolicyResource } -// EnvironmentsClientCreateOrUpdateResponse contains the response from method EnvironmentsClient.CreateOrUpdate. +// EnvironmentsClientCreateOrUpdateResponse contains the response from method EnvironmentsClient.BeginCreateOrUpdate. type EnvironmentsClientCreateOrUpdateResponse struct { EnvironmentResourceClassification } @@ -78,7 +79,7 @@ type EnvironmentsClientListBySubscriptionResponse struct { EnvironmentListResponse } -// EnvironmentsClientUpdateResponse contains the response from method EnvironmentsClient.Update. +// EnvironmentsClientUpdateResponse contains the response from method EnvironmentsClient.BeginUpdate. type EnvironmentsClientUpdateResponse struct { EnvironmentResourceClassification } @@ -148,7 +149,7 @@ func (e *EventSourcesClientUpdateResponse) UnmarshalJSON(data []byte) error { return nil } -// 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/timeseriesinsights/armtimeseriesinsights/zz_generated_time_rfc3339.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/time_rfc3339.go index 4048bc48a070..c17d3b408e0d 100644 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/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 armtimeseriesinsights @@ -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/timeseriesinsights/armtimeseriesinsights/ze_generated_example_accesspolicies_client_test.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/ze_generated_example_accesspolicies_client_test.go deleted file mode 100644 index cac2467c0d6c..000000000000 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/ze_generated_example_accesspolicies_client_test.go +++ /dev/null @@ -1,145 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armtimeseriesinsights_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/timeseriesinsights/armtimeseriesinsights" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/AccessPoliciesCreate.json -func ExampleAccessPoliciesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtimeseriesinsights.NewAccessPoliciesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "rg1", - "env1", - "ap1", - armtimeseriesinsights.AccessPolicyCreateOrUpdateParameters{ - Properties: &armtimeseriesinsights.AccessPolicyResourceProperties{ - Description: to.Ptr("some description"), - PrincipalObjectID: to.Ptr("aGuid"), - Roles: []*armtimeseriesinsights.AccessPolicyRole{ - to.Ptr(armtimeseriesinsights.AccessPolicyRoleReader)}, - }, - }, - 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/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/AccessPoliciesGet.json -func ExampleAccessPoliciesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtimeseriesinsights.NewAccessPoliciesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "rg1", - "env1", - "ap1", - 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/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/AccessPoliciesPatchRoles.json -func ExampleAccessPoliciesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtimeseriesinsights.NewAccessPoliciesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "rg1", - "env1", - "ap1", - armtimeseriesinsights.AccessPolicyUpdateParameters{ - Properties: &armtimeseriesinsights.AccessPolicyMutableProperties{ - Roles: []*armtimeseriesinsights.AccessPolicyRole{ - to.Ptr(armtimeseriesinsights.AccessPolicyRoleReader), - to.Ptr(armtimeseriesinsights.AccessPolicyRoleContributor)}, - }, - }, - 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/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/AccessPoliciesDelete.json -func ExampleAccessPoliciesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtimeseriesinsights.NewAccessPoliciesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "rg1", - "env1", - "ap1", - 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/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/AccessPoliciesListByEnvironment.json -func ExampleAccessPoliciesClient_ListByEnvironment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtimeseriesinsights.NewAccessPoliciesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListByEnvironment(ctx, - "rg1", - "env1", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/ze_generated_example_environments_client_test.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/ze_generated_example_environments_client_test.go deleted file mode 100644 index c235a76c965b..000000000000 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/ze_generated_example_environments_client_test.go +++ /dev/null @@ -1,174 +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 armtimeseriesinsights_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/timeseriesinsights/armtimeseriesinsights" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EnvironmentsCreate.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 := armtimeseriesinsights.NewEnvironmentsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "rg1", - "env1", - &armtimeseriesinsights.Gen1EnvironmentCreateOrUpdateParameters{ - Location: to.Ptr("West US"), - Kind: to.Ptr(armtimeseriesinsights.EnvironmentKindGen1), - SKU: &armtimeseriesinsights.SKU{ - Name: to.Ptr(armtimeseriesinsights.SKUNameS1), - Capacity: to.Ptr[int32](1), - }, - Properties: &armtimeseriesinsights.Gen1EnvironmentCreationProperties{ - DataRetentionTime: to.Ptr("P31D"), - PartitionKeyProperties: []*armtimeseriesinsights.TimeSeriesIDProperty{ - { - Name: to.Ptr("DeviceId1"), - Type: to.Ptr(armtimeseriesinsights.PropertyTypeString), - }}, - }, - }, - 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/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EnvironmentsGet.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 := armtimeseriesinsights.NewEnvironmentsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "rg1", - "env1", - &armtimeseriesinsights.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/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EnvironmentsPatchTags.json -func ExampleEnvironmentsClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtimeseriesinsights.NewEnvironmentsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, - "rg1", - "env1", - &armtimeseriesinsights.EnvironmentUpdateParameters{ - Tags: map[string]*string{ - "someTag": to.Ptr("someTagValue"), - }, - }, - 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/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EnvironmentsDelete.json -func ExampleEnvironmentsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtimeseriesinsights.NewEnvironmentsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "rg1", - "env1", - 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/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EnvironmentsListByResourceGroup.json -func ExampleEnvironmentsClient_ListByResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtimeseriesinsights.NewEnvironmentsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListByResourceGroup(ctx, - "rg1", - 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/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EnvironmentsListBySubscription.json -func ExampleEnvironmentsClient_ListBySubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtimeseriesinsights.NewEnvironmentsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListBySubscription(ctx, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/ze_generated_example_eventsources_client_test.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/ze_generated_example_eventsources_client_test.go deleted file mode 100644 index f4ac648262ab..000000000000 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/ze_generated_example_eventsources_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 armtimeseriesinsights_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/timeseriesinsights/armtimeseriesinsights" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EventSourcesCreateEventHub.json -func ExampleEventSourcesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtimeseriesinsights.NewEventSourcesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "rg1", - "env1", - "es1", - &armtimeseriesinsights.EventHubEventSourceCreateOrUpdateParameters{ - Location: to.Ptr("West US"), - Kind: to.Ptr(armtimeseriesinsights.EventSourceKindMicrosoftEventHub), - Properties: &armtimeseriesinsights.EventHubEventSourceCreationProperties{ - IngressStartAt: &armtimeseriesinsights.IngressStartAtProperties{ - Type: to.Ptr(armtimeseriesinsights.IngressStartAtTypeEarliestAvailable), - }, - LocalTimestamp: &armtimeseriesinsights.LocalTimestamp{ - Format: to.Ptr(armtimeseriesinsights.LocalTimestampFormat("TimeSpan")), - TimeZoneOffset: &armtimeseriesinsights.LocalTimestampTimeZoneOffset{ - PropertyName: to.Ptr("someEventPropertyName"), - }, - }, - TimestampPropertyName: to.Ptr("someTimestampProperty"), - EventSourceResourceID: to.Ptr("somePathInArm"), - ConsumerGroupName: to.Ptr("cgn"), - EventHubName: to.Ptr("ehn"), - KeyName: to.Ptr("managementKey"), - ServiceBusNamespace: to.Ptr("sbn"), - SharedAccessKey: to.Ptr("someSecretvalue"), - }, - }, - 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/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EventSourcesGetEventHub.json -func ExampleEventSourcesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtimeseriesinsights.NewEventSourcesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "rg1", - "env1", - "es1", - 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/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EventSourcesPatchTags.json -func ExampleEventSourcesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtimeseriesinsights.NewEventSourcesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "rg1", - "env1", - "es1", - &armtimeseriesinsights.EventSourceUpdateParameters{ - Tags: map[string]*string{ - "someKey": to.Ptr("someValue"), - }, - }, - 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/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EventSourcesDelete.json -func ExampleEventSourcesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtimeseriesinsights.NewEventSourcesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "rg1", - "env1", - "es1", - 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/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/EventSourcesListByEnvironment.json -func ExampleEventSourcesClient_ListByEnvironment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtimeseriesinsights.NewEventSourcesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListByEnvironment(ctx, - "rg1", - "env1", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/ze_generated_example_operations_client_test.go deleted file mode 100644 index 70eed962cd99..000000000000 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/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 armtimeseriesinsights_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/Operation_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 := armtimeseriesinsights.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/timeseriesinsights/armtimeseriesinsights/ze_generated_example_referencedatasets_client_test.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/ze_generated_example_referencedatasets_client_test.go deleted file mode 100644 index 16d6dc35dfe2..000000000000 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/ze_generated_example_referencedatasets_client_test.go +++ /dev/null @@ -1,149 +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 armtimeseriesinsights_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/timeseriesinsights/armtimeseriesinsights" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/ReferenceDataSetsCreate.json -func ExampleReferenceDataSetsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtimeseriesinsights.NewReferenceDataSetsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "rg1", - "env1", - "rds1", - armtimeseriesinsights.ReferenceDataSetCreateOrUpdateParameters{ - Location: to.Ptr("West US"), - Properties: &armtimeseriesinsights.ReferenceDataSetCreationProperties{ - KeyProperties: []*armtimeseriesinsights.ReferenceDataSetKeyProperty{ - { - Name: to.Ptr("DeviceId1"), - Type: to.Ptr(armtimeseriesinsights.ReferenceDataKeyPropertyTypeString), - }, - { - Name: to.Ptr("DeviceFloor"), - Type: to.Ptr(armtimeseriesinsights.ReferenceDataKeyPropertyTypeDouble), - }}, - }, - }, - 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/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/ReferenceDataSetsGet.json -func ExampleReferenceDataSetsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtimeseriesinsights.NewReferenceDataSetsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "rg1", - "env1", - "rds1", - 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/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/ReferenceDataSetsPatchTags.json -func ExampleReferenceDataSetsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtimeseriesinsights.NewReferenceDataSetsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "rg1", - "env1", - "rds1", - armtimeseriesinsights.ReferenceDataSetUpdateParameters{ - Tags: map[string]*string{ - "someKey": to.Ptr("someValue"), - }, - }, - 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/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/ReferenceDataSetsDelete.json -func ExampleReferenceDataSetsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtimeseriesinsights.NewReferenceDataSetsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "rg1", - "env1", - "rds1", - 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/timeseriesinsights/resource-manager/Microsoft.TimeSeriesInsights/stable/2020-05-15/examples/ReferenceDataSetsListByEnvironment.json -func ExampleReferenceDataSetsClient_ListByEnvironment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armtimeseriesinsights.NewReferenceDataSetsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListByEnvironment(ctx, - "rg1", - "env1", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_models_serde.go b/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_models_serde.go deleted file mode 100644 index d970b72ca82d..000000000000 --- a/sdk/resourcemanager/timeseriesinsights/armtimeseriesinsights/zz_generated_models_serde.go +++ /dev/null @@ -1,1347 +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 armtimeseriesinsights - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type AccessPolicyMutableProperties. -func (a AccessPolicyMutableProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "description", a.Description) - populate(objectMap, "roles", a.Roles) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type AccessPolicyResourceProperties. -func (a AccessPolicyResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "description", a.Description) - populate(objectMap, "principalObjectId", a.PrincipalObjectID) - populate(objectMap, "roles", a.Roles) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type AccessPolicyUpdateParameters. -func (a AccessPolicyUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "properties", a.Properties) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type AzureEventSourceProperties. -func (a AzureEventSourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "creationTime", a.CreationTime) - populate(objectMap, "eventSourceResourceId", a.EventSourceResourceID) - populate(objectMap, "ingressStartAt", a.IngressStartAt) - populate(objectMap, "localTimestamp", a.LocalTimestamp) - populate(objectMap, "provisioningState", a.ProvisioningState) - populate(objectMap, "timestampPropertyName", a.TimestampPropertyName) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AzureEventSourceProperties. -func (a *AzureEventSourceProperties) UnmarshalJSON(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 "creationTime": - err = unpopulateTimeRFC3339(val, "CreationTime", &a.CreationTime) - delete(rawMsg, key) - case "eventSourceResourceId": - err = unpopulate(val, "EventSourceResourceID", &a.EventSourceResourceID) - delete(rawMsg, key) - case "ingressStartAt": - err = unpopulate(val, "IngressStartAt", &a.IngressStartAt) - delete(rawMsg, key) - case "localTimestamp": - err = unpopulate(val, "LocalTimestamp", &a.LocalTimestamp) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) - delete(rawMsg, key) - case "timestampPropertyName": - err = unpopulate(val, "TimestampPropertyName", &a.TimestampPropertyName) - 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 CreateOrUpdateTrackedResourceProperties. -func (c CreateOrUpdateTrackedResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "location", c.Location) - populate(objectMap, "tags", c.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type EnvironmentCreateOrUpdateParameters. -func (e EnvironmentCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["kind"] = e.Kind - populate(objectMap, "location", e.Location) - populate(objectMap, "sku", e.SKU) - populate(objectMap, "tags", e.Tags) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentListResponse. -func (e *EnvironmentListResponse) UnmarshalJSON(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 "value": - e.Value, err = unmarshalEnvironmentResourceClassificationArray(val) - 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 EnvironmentResourceProperties. -func (e EnvironmentResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "creationTime", e.CreationTime) - populate(objectMap, "dataAccessFqdn", e.DataAccessFqdn) - populate(objectMap, "dataAccessId", e.DataAccessID) - populate(objectMap, "provisioningState", e.ProvisioningState) - populate(objectMap, "status", e.Status) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentResourceProperties. -func (e *EnvironmentResourceProperties) UnmarshalJSON(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 "creationTime": - err = unpopulateTimeRFC3339(val, "CreationTime", &e.CreationTime) - delete(rawMsg, key) - case "dataAccessFqdn": - err = unpopulate(val, "DataAccessFqdn", &e.DataAccessFqdn) - delete(rawMsg, key) - case "dataAccessId": - err = unpopulate(val, "DataAccessID", &e.DataAccessID) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &e.Status) - 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 EnvironmentUpdateParameters. -func (e EnvironmentUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["kind"] = e.Kind - populate(objectMap, "tags", e.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type EventHubEventSourceCommonProperties. -func (e EventHubEventSourceCommonProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "consumerGroupName", e.ConsumerGroupName) - populateTimeRFC3339(objectMap, "creationTime", e.CreationTime) - populate(objectMap, "eventHubName", e.EventHubName) - populate(objectMap, "eventSourceResourceId", e.EventSourceResourceID) - populate(objectMap, "ingressStartAt", e.IngressStartAt) - populate(objectMap, "keyName", e.KeyName) - populate(objectMap, "localTimestamp", e.LocalTimestamp) - populate(objectMap, "provisioningState", e.ProvisioningState) - populate(objectMap, "serviceBusNamespace", e.ServiceBusNamespace) - populate(objectMap, "timestampPropertyName", e.TimestampPropertyName) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type EventHubEventSourceCommonProperties. -func (e *EventHubEventSourceCommonProperties) UnmarshalJSON(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 "consumerGroupName": - err = unpopulate(val, "ConsumerGroupName", &e.ConsumerGroupName) - delete(rawMsg, key) - case "creationTime": - err = unpopulateTimeRFC3339(val, "CreationTime", &e.CreationTime) - delete(rawMsg, key) - case "eventHubName": - err = unpopulate(val, "EventHubName", &e.EventHubName) - delete(rawMsg, key) - case "eventSourceResourceId": - err = unpopulate(val, "EventSourceResourceID", &e.EventSourceResourceID) - delete(rawMsg, key) - case "ingressStartAt": - err = unpopulate(val, "IngressStartAt", &e.IngressStartAt) - delete(rawMsg, key) - case "keyName": - err = unpopulate(val, "KeyName", &e.KeyName) - delete(rawMsg, key) - case "localTimestamp": - err = unpopulate(val, "LocalTimestamp", &e.LocalTimestamp) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) - delete(rawMsg, key) - case "serviceBusNamespace": - err = unpopulate(val, "ServiceBusNamespace", &e.ServiceBusNamespace) - delete(rawMsg, key) - case "timestampPropertyName": - err = unpopulate(val, "TimestampPropertyName", &e.TimestampPropertyName) - 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 EventHubEventSourceCreateOrUpdateParameters. -func (e EventHubEventSourceCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["kind"] = EventSourceKindMicrosoftEventHub - populate(objectMap, "localTimestamp", e.LocalTimestamp) - populate(objectMap, "location", e.Location) - populate(objectMap, "properties", e.Properties) - populate(objectMap, "tags", e.Tags) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type EventHubEventSourceCreateOrUpdateParameters. -func (e *EventHubEventSourceCreateOrUpdateParameters) UnmarshalJSON(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 "kind": - err = unpopulate(val, "Kind", &e.Kind) - delete(rawMsg, key) - case "localTimestamp": - err = unpopulate(val, "LocalTimestamp", &e.LocalTimestamp) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &e.Location) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &e.Properties) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &e.Tags) - 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 EventHubEventSourceCreationProperties. -func (e EventHubEventSourceCreationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "consumerGroupName", e.ConsumerGroupName) - populateTimeRFC3339(objectMap, "creationTime", e.CreationTime) - populate(objectMap, "eventHubName", e.EventHubName) - populate(objectMap, "eventSourceResourceId", e.EventSourceResourceID) - populate(objectMap, "ingressStartAt", e.IngressStartAt) - populate(objectMap, "keyName", e.KeyName) - populate(objectMap, "localTimestamp", e.LocalTimestamp) - populate(objectMap, "provisioningState", e.ProvisioningState) - populate(objectMap, "serviceBusNamespace", e.ServiceBusNamespace) - populate(objectMap, "sharedAccessKey", e.SharedAccessKey) - populate(objectMap, "timestampPropertyName", e.TimestampPropertyName) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type EventHubEventSourceCreationProperties. -func (e *EventHubEventSourceCreationProperties) UnmarshalJSON(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 "consumerGroupName": - err = unpopulate(val, "ConsumerGroupName", &e.ConsumerGroupName) - delete(rawMsg, key) - case "creationTime": - err = unpopulateTimeRFC3339(val, "CreationTime", &e.CreationTime) - delete(rawMsg, key) - case "eventHubName": - err = unpopulate(val, "EventHubName", &e.EventHubName) - delete(rawMsg, key) - case "eventSourceResourceId": - err = unpopulate(val, "EventSourceResourceID", &e.EventSourceResourceID) - delete(rawMsg, key) - case "ingressStartAt": - err = unpopulate(val, "IngressStartAt", &e.IngressStartAt) - delete(rawMsg, key) - case "keyName": - err = unpopulate(val, "KeyName", &e.KeyName) - delete(rawMsg, key) - case "localTimestamp": - err = unpopulate(val, "LocalTimestamp", &e.LocalTimestamp) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) - delete(rawMsg, key) - case "serviceBusNamespace": - err = unpopulate(val, "ServiceBusNamespace", &e.ServiceBusNamespace) - delete(rawMsg, key) - case "sharedAccessKey": - err = unpopulate(val, "SharedAccessKey", &e.SharedAccessKey) - delete(rawMsg, key) - case "timestampPropertyName": - err = unpopulate(val, "TimestampPropertyName", &e.TimestampPropertyName) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type EventHubEventSourceResource. -func (e *EventHubEventSourceResource) UnmarshalJSON(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 "kind": - err = unpopulate(val, "Kind", &e.Kind) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &e.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &e.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &e.Properties) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &e.Tags) - 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 EventHubEventSourceResourceProperties. -func (e EventHubEventSourceResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "consumerGroupName", e.ConsumerGroupName) - populateTimeRFC3339(objectMap, "creationTime", e.CreationTime) - populate(objectMap, "eventHubName", e.EventHubName) - populate(objectMap, "eventSourceResourceId", e.EventSourceResourceID) - populate(objectMap, "ingressStartAt", e.IngressStartAt) - populate(objectMap, "keyName", e.KeyName) - populate(objectMap, "localTimestamp", e.LocalTimestamp) - populate(objectMap, "provisioningState", e.ProvisioningState) - populate(objectMap, "serviceBusNamespace", e.ServiceBusNamespace) - populate(objectMap, "timestampPropertyName", e.TimestampPropertyName) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type EventHubEventSourceResourceProperties. -func (e *EventHubEventSourceResourceProperties) UnmarshalJSON(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 "consumerGroupName": - err = unpopulate(val, "ConsumerGroupName", &e.ConsumerGroupName) - delete(rawMsg, key) - case "creationTime": - err = unpopulateTimeRFC3339(val, "CreationTime", &e.CreationTime) - delete(rawMsg, key) - case "eventHubName": - err = unpopulate(val, "EventHubName", &e.EventHubName) - delete(rawMsg, key) - case "eventSourceResourceId": - err = unpopulate(val, "EventSourceResourceID", &e.EventSourceResourceID) - delete(rawMsg, key) - case "ingressStartAt": - err = unpopulate(val, "IngressStartAt", &e.IngressStartAt) - delete(rawMsg, key) - case "keyName": - err = unpopulate(val, "KeyName", &e.KeyName) - delete(rawMsg, key) - case "localTimestamp": - err = unpopulate(val, "LocalTimestamp", &e.LocalTimestamp) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) - delete(rawMsg, key) - case "serviceBusNamespace": - err = unpopulate(val, "ServiceBusNamespace", &e.ServiceBusNamespace) - delete(rawMsg, key) - case "timestampPropertyName": - err = unpopulate(val, "TimestampPropertyName", &e.TimestampPropertyName) - 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 EventHubEventSourceUpdateParameters. -func (e EventHubEventSourceUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["kind"] = EventSourceKindMicrosoftEventHub - populate(objectMap, "properties", e.Properties) - populate(objectMap, "tags", e.Tags) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type EventHubEventSourceUpdateParameters. -func (e *EventHubEventSourceUpdateParameters) UnmarshalJSON(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 "kind": - err = unpopulate(val, "Kind", &e.Kind) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &e.Properties) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &e.Tags) - 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 EventSourceCommonProperties. -func (e EventSourceCommonProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "creationTime", e.CreationTime) - populate(objectMap, "ingressStartAt", e.IngressStartAt) - populate(objectMap, "localTimestamp", e.LocalTimestamp) - populate(objectMap, "provisioningState", e.ProvisioningState) - populate(objectMap, "timestampPropertyName", e.TimestampPropertyName) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type EventSourceCommonProperties. -func (e *EventSourceCommonProperties) UnmarshalJSON(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 "creationTime": - err = unpopulateTimeRFC3339(val, "CreationTime", &e.CreationTime) - delete(rawMsg, key) - case "ingressStartAt": - err = unpopulate(val, "IngressStartAt", &e.IngressStartAt) - delete(rawMsg, key) - case "localTimestamp": - err = unpopulate(val, "LocalTimestamp", &e.LocalTimestamp) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) - delete(rawMsg, key) - case "timestampPropertyName": - err = unpopulate(val, "TimestampPropertyName", &e.TimestampPropertyName) - 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 EventSourceCreateOrUpdateParameters. -func (e EventSourceCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["kind"] = e.Kind - populate(objectMap, "localTimestamp", e.LocalTimestamp) - populate(objectMap, "location", e.Location) - populate(objectMap, "tags", e.Tags) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type EventSourceListResponse. -func (e *EventSourceListResponse) UnmarshalJSON(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 "value": - e.Value, err = unmarshalEventSourceResourceClassificationArray(val) - 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 EventSourceUpdateParameters. -func (e EventSourceUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["kind"] = e.Kind - populate(objectMap, "tags", e.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type Gen1EnvironmentCreateOrUpdateParameters. -func (g Gen1EnvironmentCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["kind"] = EnvironmentKindGen1 - populate(objectMap, "location", g.Location) - populate(objectMap, "properties", g.Properties) - populate(objectMap, "sku", g.SKU) - populate(objectMap, "tags", g.Tags) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Gen1EnvironmentCreateOrUpdateParameters. -func (g *Gen1EnvironmentCreateOrUpdateParameters) UnmarshalJSON(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 "kind": - err = unpopulate(val, "Kind", &g.Kind) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &g.Location) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &g.Properties) - delete(rawMsg, key) - case "sku": - err = unpopulate(val, "SKU", &g.SKU) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &g.Tags) - 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 Gen1EnvironmentCreationProperties. -func (g Gen1EnvironmentCreationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "dataRetentionTime", g.DataRetentionTime) - populate(objectMap, "partitionKeyProperties", g.PartitionKeyProperties) - populate(objectMap, "storageLimitExceededBehavior", g.StorageLimitExceededBehavior) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Gen1EnvironmentResource. -func (g *Gen1EnvironmentResource) UnmarshalJSON(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 "kind": - err = unpopulate(val, "Kind", &g.Kind) - 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 "sku": - err = unpopulate(val, "SKU", &g.SKU) - 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 Gen1EnvironmentResourceProperties. -func (g Gen1EnvironmentResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "creationTime", g.CreationTime) - populate(objectMap, "dataAccessFqdn", g.DataAccessFqdn) - populate(objectMap, "dataAccessId", g.DataAccessID) - populate(objectMap, "dataRetentionTime", g.DataRetentionTime) - populate(objectMap, "partitionKeyProperties", g.PartitionKeyProperties) - populate(objectMap, "provisioningState", g.ProvisioningState) - populate(objectMap, "status", g.Status) - populate(objectMap, "storageLimitExceededBehavior", g.StorageLimitExceededBehavior) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Gen1EnvironmentResourceProperties. -func (g *Gen1EnvironmentResourceProperties) UnmarshalJSON(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 "creationTime": - err = unpopulateTimeRFC3339(val, "CreationTime", &g.CreationTime) - delete(rawMsg, key) - case "dataAccessFqdn": - err = unpopulate(val, "DataAccessFqdn", &g.DataAccessFqdn) - delete(rawMsg, key) - case "dataAccessId": - err = unpopulate(val, "DataAccessID", &g.DataAccessID) - delete(rawMsg, key) - case "dataRetentionTime": - err = unpopulate(val, "DataRetentionTime", &g.DataRetentionTime) - delete(rawMsg, key) - case "partitionKeyProperties": - err = unpopulate(val, "PartitionKeyProperties", &g.PartitionKeyProperties) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &g.ProvisioningState) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &g.Status) - delete(rawMsg, key) - case "storageLimitExceededBehavior": - err = unpopulate(val, "StorageLimitExceededBehavior", &g.StorageLimitExceededBehavior) - 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 Gen1EnvironmentUpdateParameters. -func (g Gen1EnvironmentUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["kind"] = EnvironmentKindGen1 - populate(objectMap, "properties", g.Properties) - populate(objectMap, "sku", g.SKU) - populate(objectMap, "tags", g.Tags) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Gen1EnvironmentUpdateParameters. -func (g *Gen1EnvironmentUpdateParameters) UnmarshalJSON(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 "kind": - err = unpopulate(val, "Kind", &g.Kind) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &g.Properties) - delete(rawMsg, key) - case "sku": - err = unpopulate(val, "SKU", &g.SKU) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &g.Tags) - 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 Gen2EnvironmentCreateOrUpdateParameters. -func (g Gen2EnvironmentCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["kind"] = EnvironmentKindGen2 - populate(objectMap, "location", g.Location) - populate(objectMap, "properties", g.Properties) - populate(objectMap, "sku", g.SKU) - populate(objectMap, "tags", g.Tags) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Gen2EnvironmentCreateOrUpdateParameters. -func (g *Gen2EnvironmentCreateOrUpdateParameters) UnmarshalJSON(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 "kind": - err = unpopulate(val, "Kind", &g.Kind) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &g.Location) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &g.Properties) - delete(rawMsg, key) - case "sku": - err = unpopulate(val, "SKU", &g.SKU) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &g.Tags) - 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 Gen2EnvironmentCreationProperties. -func (g Gen2EnvironmentCreationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "storageConfiguration", g.StorageConfiguration) - populate(objectMap, "timeSeriesIdProperties", g.TimeSeriesIDProperties) - populate(objectMap, "warmStoreConfiguration", g.WarmStoreConfiguration) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Gen2EnvironmentResource. -func (g *Gen2EnvironmentResource) UnmarshalJSON(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 "kind": - err = unpopulate(val, "Kind", &g.Kind) - 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 "sku": - err = unpopulate(val, "SKU", &g.SKU) - 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 Gen2EnvironmentResourceProperties. -func (g Gen2EnvironmentResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "creationTime", g.CreationTime) - populate(objectMap, "dataAccessFqdn", g.DataAccessFqdn) - populate(objectMap, "dataAccessId", g.DataAccessID) - populate(objectMap, "provisioningState", g.ProvisioningState) - populate(objectMap, "status", g.Status) - populate(objectMap, "storageConfiguration", g.StorageConfiguration) - populate(objectMap, "timeSeriesIdProperties", g.TimeSeriesIDProperties) - populate(objectMap, "warmStoreConfiguration", g.WarmStoreConfiguration) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Gen2EnvironmentResourceProperties. -func (g *Gen2EnvironmentResourceProperties) UnmarshalJSON(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 "creationTime": - err = unpopulateTimeRFC3339(val, "CreationTime", &g.CreationTime) - delete(rawMsg, key) - case "dataAccessFqdn": - err = unpopulate(val, "DataAccessFqdn", &g.DataAccessFqdn) - delete(rawMsg, key) - case "dataAccessId": - err = unpopulate(val, "DataAccessID", &g.DataAccessID) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &g.ProvisioningState) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &g.Status) - delete(rawMsg, key) - case "storageConfiguration": - err = unpopulate(val, "StorageConfiguration", &g.StorageConfiguration) - delete(rawMsg, key) - case "timeSeriesIdProperties": - err = unpopulate(val, "TimeSeriesIDProperties", &g.TimeSeriesIDProperties) - delete(rawMsg, key) - case "warmStoreConfiguration": - err = unpopulate(val, "WarmStoreConfiguration", &g.WarmStoreConfiguration) - 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 Gen2EnvironmentUpdateParameters. -func (g Gen2EnvironmentUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["kind"] = EnvironmentKindGen2 - populate(objectMap, "properties", g.Properties) - populate(objectMap, "tags", g.Tags) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Gen2EnvironmentUpdateParameters. -func (g *Gen2EnvironmentUpdateParameters) UnmarshalJSON(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 "kind": - err = unpopulate(val, "Kind", &g.Kind) - 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) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", g, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type IoTHubEventSourceCommonProperties. -func (i IoTHubEventSourceCommonProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "consumerGroupName", i.ConsumerGroupName) - populateTimeRFC3339(objectMap, "creationTime", i.CreationTime) - populate(objectMap, "eventSourceResourceId", i.EventSourceResourceID) - populate(objectMap, "ingressStartAt", i.IngressStartAt) - populate(objectMap, "iotHubName", i.IotHubName) - populate(objectMap, "keyName", i.KeyName) - populate(objectMap, "localTimestamp", i.LocalTimestamp) - populate(objectMap, "provisioningState", i.ProvisioningState) - populate(objectMap, "timestampPropertyName", i.TimestampPropertyName) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type IoTHubEventSourceCommonProperties. -func (i *IoTHubEventSourceCommonProperties) UnmarshalJSON(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 "consumerGroupName": - err = unpopulate(val, "ConsumerGroupName", &i.ConsumerGroupName) - delete(rawMsg, key) - case "creationTime": - err = unpopulateTimeRFC3339(val, "CreationTime", &i.CreationTime) - delete(rawMsg, key) - case "eventSourceResourceId": - err = unpopulate(val, "EventSourceResourceID", &i.EventSourceResourceID) - delete(rawMsg, key) - case "ingressStartAt": - err = unpopulate(val, "IngressStartAt", &i.IngressStartAt) - delete(rawMsg, key) - case "iotHubName": - err = unpopulate(val, "IotHubName", &i.IotHubName) - delete(rawMsg, key) - case "keyName": - err = unpopulate(val, "KeyName", &i.KeyName) - delete(rawMsg, key) - case "localTimestamp": - err = unpopulate(val, "LocalTimestamp", &i.LocalTimestamp) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &i.ProvisioningState) - delete(rawMsg, key) - case "timestampPropertyName": - err = unpopulate(val, "TimestampPropertyName", &i.TimestampPropertyName) - 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 IoTHubEventSourceCreateOrUpdateParameters. -func (i IoTHubEventSourceCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["kind"] = EventSourceKindMicrosoftIoTHub - populate(objectMap, "localTimestamp", i.LocalTimestamp) - populate(objectMap, "location", i.Location) - populate(objectMap, "properties", i.Properties) - populate(objectMap, "tags", i.Tags) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type IoTHubEventSourceCreateOrUpdateParameters. -func (i *IoTHubEventSourceCreateOrUpdateParameters) UnmarshalJSON(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 "kind": - err = unpopulate(val, "Kind", &i.Kind) - delete(rawMsg, key) - case "localTimestamp": - err = unpopulate(val, "LocalTimestamp", &i.LocalTimestamp) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &i.Location) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &i.Properties) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &i.Tags) - 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 IoTHubEventSourceCreationProperties. -func (i IoTHubEventSourceCreationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "consumerGroupName", i.ConsumerGroupName) - populateTimeRFC3339(objectMap, "creationTime", i.CreationTime) - populate(objectMap, "eventSourceResourceId", i.EventSourceResourceID) - populate(objectMap, "ingressStartAt", i.IngressStartAt) - populate(objectMap, "iotHubName", i.IotHubName) - populate(objectMap, "keyName", i.KeyName) - populate(objectMap, "localTimestamp", i.LocalTimestamp) - populate(objectMap, "provisioningState", i.ProvisioningState) - populate(objectMap, "sharedAccessKey", i.SharedAccessKey) - populate(objectMap, "timestampPropertyName", i.TimestampPropertyName) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type IoTHubEventSourceCreationProperties. -func (i *IoTHubEventSourceCreationProperties) UnmarshalJSON(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 "consumerGroupName": - err = unpopulate(val, "ConsumerGroupName", &i.ConsumerGroupName) - delete(rawMsg, key) - case "creationTime": - err = unpopulateTimeRFC3339(val, "CreationTime", &i.CreationTime) - delete(rawMsg, key) - case "eventSourceResourceId": - err = unpopulate(val, "EventSourceResourceID", &i.EventSourceResourceID) - delete(rawMsg, key) - case "ingressStartAt": - err = unpopulate(val, "IngressStartAt", &i.IngressStartAt) - delete(rawMsg, key) - case "iotHubName": - err = unpopulate(val, "IotHubName", &i.IotHubName) - delete(rawMsg, key) - case "keyName": - err = unpopulate(val, "KeyName", &i.KeyName) - delete(rawMsg, key) - case "localTimestamp": - err = unpopulate(val, "LocalTimestamp", &i.LocalTimestamp) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &i.ProvisioningState) - delete(rawMsg, key) - case "sharedAccessKey": - err = unpopulate(val, "SharedAccessKey", &i.SharedAccessKey) - delete(rawMsg, key) - case "timestampPropertyName": - err = unpopulate(val, "TimestampPropertyName", &i.TimestampPropertyName) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type IoTHubEventSourceResource. -func (i *IoTHubEventSourceResource) UnmarshalJSON(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 "id": - err = unpopulate(val, "ID", &i.ID) - delete(rawMsg, key) - case "kind": - err = unpopulate(val, "Kind", &i.Kind) - 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) - case "properties": - err = unpopulate(val, "Properties", &i.Properties) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &i.Tags) - 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 IoTHubEventSourceResourceProperties. -func (i IoTHubEventSourceResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "consumerGroupName", i.ConsumerGroupName) - populateTimeRFC3339(objectMap, "creationTime", i.CreationTime) - populate(objectMap, "eventSourceResourceId", i.EventSourceResourceID) - populate(objectMap, "ingressStartAt", i.IngressStartAt) - populate(objectMap, "iotHubName", i.IotHubName) - populate(objectMap, "keyName", i.KeyName) - populate(objectMap, "localTimestamp", i.LocalTimestamp) - populate(objectMap, "provisioningState", i.ProvisioningState) - populate(objectMap, "timestampPropertyName", i.TimestampPropertyName) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type IoTHubEventSourceResourceProperties. -func (i *IoTHubEventSourceResourceProperties) UnmarshalJSON(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 "consumerGroupName": - err = unpopulate(val, "ConsumerGroupName", &i.ConsumerGroupName) - delete(rawMsg, key) - case "creationTime": - err = unpopulateTimeRFC3339(val, "CreationTime", &i.CreationTime) - delete(rawMsg, key) - case "eventSourceResourceId": - err = unpopulate(val, "EventSourceResourceID", &i.EventSourceResourceID) - delete(rawMsg, key) - case "ingressStartAt": - err = unpopulate(val, "IngressStartAt", &i.IngressStartAt) - delete(rawMsg, key) - case "iotHubName": - err = unpopulate(val, "IotHubName", &i.IotHubName) - delete(rawMsg, key) - case "keyName": - err = unpopulate(val, "KeyName", &i.KeyName) - delete(rawMsg, key) - case "localTimestamp": - err = unpopulate(val, "LocalTimestamp", &i.LocalTimestamp) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &i.ProvisioningState) - delete(rawMsg, key) - case "timestampPropertyName": - err = unpopulate(val, "TimestampPropertyName", &i.TimestampPropertyName) - 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 IoTHubEventSourceUpdateParameters. -func (i IoTHubEventSourceUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - objectMap["kind"] = EventSourceKindMicrosoftIoTHub - populate(objectMap, "properties", i.Properties) - populate(objectMap, "tags", i.Tags) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type IoTHubEventSourceUpdateParameters. -func (i *IoTHubEventSourceUpdateParameters) UnmarshalJSON(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 "kind": - err = unpopulate(val, "Kind", &i.Kind) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &i.Properties) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &i.Tags) - 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 ReferenceDataSetCreateOrUpdateParameters. -func (r ReferenceDataSetCreateOrUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "location", r.Location) - populate(objectMap, "properties", r.Properties) - populate(objectMap, "tags", r.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ReferenceDataSetCreationProperties. -func (r ReferenceDataSetCreationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "dataStringComparisonBehavior", r.DataStringComparisonBehavior) - populate(objectMap, "keyProperties", r.KeyProperties) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ReferenceDataSetResourceProperties. -func (r ReferenceDataSetResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "creationTime", r.CreationTime) - populate(objectMap, "dataStringComparisonBehavior", r.DataStringComparisonBehavior) - populate(objectMap, "keyProperties", r.KeyProperties) - populate(objectMap, "provisioningState", r.ProvisioningState) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ReferenceDataSetResourceProperties. -func (r *ReferenceDataSetResourceProperties) UnmarshalJSON(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 "creationTime": - err = unpopulateTimeRFC3339(val, "CreationTime", &r.CreationTime) - delete(rawMsg, key) - case "dataStringComparisonBehavior": - err = unpopulate(val, "DataStringComparisonBehavior", &r.DataStringComparisonBehavior) - delete(rawMsg, key) - case "keyProperties": - err = unpopulate(val, "KeyProperties", &r.KeyProperties) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) - 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 ReferenceDataSetUpdateParameters. -func (r ReferenceDataSetUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", r.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ResourceProperties. -func (r ResourceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "creationTime", r.CreationTime) - populate(objectMap, "provisioningState", r.ProvisioningState) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProperties. -func (r *ResourceProperties) UnmarshalJSON(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 "creationTime": - err = unpopulateTimeRFC3339(val, "CreationTime", &r.CreationTime) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, 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/trafficmanager/armtrafficmanager/CHANGELOG.md b/sdk/resourcemanager/trafficmanager/armtrafficmanager/CHANGELOG.md index 86509d59b86b..19895dc57d94 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/CHANGELOG.md +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0-beta.2 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.1.0-beta.1 (2022-10-31) ### Features Added diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/README.md b/sdk/resourcemanager/trafficmanager/armtrafficmanager/README.md index aabec39da707..5be18fcb1505 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/README.md +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/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 Traffic Manager modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Traffic Manager module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armtrafficmanager.NewHeatMapClient(, cred, nil) +clientFactory, err := armtrafficmanager.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 := armtrafficmanager.NewHeatMapClient(, cred, &options) +clientFactory, err := armtrafficmanager.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.NewHeatMapClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/autorest.md b/sdk/resourcemanager/trafficmanager/armtrafficmanager/autorest.md index de66ba397661..85c33c0bc804 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/autorest.md +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.1.0-beta.1 +module-version: 1.1.0-beta.2 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/client_factory.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/client_factory.go new file mode 100644 index 000000000000..677da7831069 --- /dev/null +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/client_factory.go @@ -0,0 +1,64 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armtrafficmanager + +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) NewEndpointsClient() *EndpointsClient { + subClient, _ := NewEndpointsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewProfilesClient() *ProfilesClient { + subClient, _ := NewProfilesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewGeographicHierarchiesClient() *GeographicHierarchiesClient { + subClient, _ := NewGeographicHierarchiesClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewHeatMapClient() *HeatMapClient { + subClient, _ := NewHeatMapClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewUserMetricsKeysClient() *UserMetricsKeysClient { + subClient, _ := NewUserMetricsKeysClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/constants.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/constants.go index 8082154ac306..9aac2c71301d 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/constants.go +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/constants.go @@ -11,7 +11,7 @@ package armtrafficmanager const ( moduleName = "armtrafficmanager" - moduleVersion = "v1.1.0-beta.1" + moduleVersion = "v1.1.0-beta.2" ) // AllowedEndpointRecordType - The allowed type DNS record types for this profile. diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/endpoints_client.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/endpoints_client.go index a8f980e2de96..3d59eb815ef9 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/endpoints_client.go +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/endpoints_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,51 +24,43 @@ import ( // EndpointsClient contains the methods for the Endpoints group. // Don't use this type directly, use NewEndpointsClient() instead. type EndpointsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewEndpointsClient creates a new instance of EndpointsClient 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 NewEndpointsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EndpointsClient, 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+".EndpointsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &EndpointsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or update a Traffic Manager endpoint. // 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. -// profileName - The name of the Traffic Manager profile. -// endpointType - The type of the Traffic Manager endpoint to be created or updated. -// endpointName - The name of the Traffic Manager endpoint to be created or updated. -// parameters - The Traffic Manager endpoint parameters supplied to the CreateOrUpdate operation. -// options - EndpointsClientCreateOrUpdateOptions contains the optional parameters for the EndpointsClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - profileName - The name of the Traffic Manager profile. +// - endpointType - The type of the Traffic Manager endpoint to be created or updated. +// - endpointName - The name of the Traffic Manager endpoint to be created or updated. +// - parameters - The Traffic Manager endpoint parameters supplied to the CreateOrUpdate operation. +// - options - EndpointsClientCreateOrUpdateOptions contains the optional parameters for the EndpointsClient.CreateOrUpdate +// method. func (client *EndpointsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, profileName string, endpointType EndpointType, endpointName string, parameters Endpoint, options *EndpointsClientCreateOrUpdateOptions) (EndpointsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, profileName, endpointType, endpointName, parameters, options) if err != nil { return EndpointsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return EndpointsClientCreateOrUpdateResponse{}, err } @@ -103,7 +93,7 @@ func (client *EndpointsClient) 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 } @@ -125,18 +115,19 @@ func (client *EndpointsClient) createOrUpdateHandleResponse(resp *http.Response) // Delete - Deletes a Traffic Manager endpoint. // 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. -// profileName - The name of the Traffic Manager profile. -// endpointType - The type of the Traffic Manager endpoint to be deleted. -// endpointName - The name of the Traffic Manager endpoint to be deleted. -// options - EndpointsClientDeleteOptions contains the optional parameters for the EndpointsClient.Delete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - profileName - The name of the Traffic Manager profile. +// - endpointType - The type of the Traffic Manager endpoint to be deleted. +// - endpointName - The name of the Traffic Manager endpoint to be deleted. +// - options - EndpointsClientDeleteOptions contains the optional parameters for the EndpointsClient.Delete method. func (client *EndpointsClient) Delete(ctx context.Context, resourceGroupName string, profileName string, endpointType EndpointType, endpointName string, options *EndpointsClientDeleteOptions) (EndpointsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, profileName, endpointType, endpointName, options) if err != nil { return EndpointsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return EndpointsClientDeleteResponse{}, err } @@ -169,7 +160,7 @@ func (client *EndpointsClient) deleteCreateRequest(ctx context.Context, resource return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.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 } @@ -191,18 +182,19 @@ func (client *EndpointsClient) deleteHandleResponse(resp *http.Response) (Endpoi // Get - Gets a Traffic Manager endpoint. // 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. -// profileName - The name of the Traffic Manager profile. -// endpointType - The type of the Traffic Manager endpoint. -// endpointName - The name of the Traffic Manager endpoint. -// options - EndpointsClientGetOptions contains the optional parameters for the EndpointsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - profileName - The name of the Traffic Manager profile. +// - endpointType - The type of the Traffic Manager endpoint. +// - endpointName - The name of the Traffic Manager endpoint. +// - options - EndpointsClientGetOptions contains the optional parameters for the EndpointsClient.Get method. func (client *EndpointsClient) Get(ctx context.Context, resourceGroupName string, profileName string, endpointType EndpointType, endpointName string, options *EndpointsClientGetOptions) (EndpointsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, profileName, endpointType, endpointName, options) if err != nil { return EndpointsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return EndpointsClientGetResponse{}, err } @@ -235,7 +227,7 @@ func (client *EndpointsClient) getCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -257,19 +249,20 @@ func (client *EndpointsClient) getHandleResponse(resp *http.Response) (Endpoints // Update - Update a Traffic Manager endpoint. // 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. -// profileName - The name of the Traffic Manager profile. -// endpointType - The type of the Traffic Manager endpoint to be updated. -// endpointName - The name of the Traffic Manager endpoint to be updated. -// parameters - The Traffic Manager endpoint parameters supplied to the Update operation. -// options - EndpointsClientUpdateOptions contains the optional parameters for the EndpointsClient.Update method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - profileName - The name of the Traffic Manager profile. +// - endpointType - The type of the Traffic Manager endpoint to be updated. +// - endpointName - The name of the Traffic Manager endpoint to be updated. +// - parameters - The Traffic Manager endpoint parameters supplied to the Update operation. +// - options - EndpointsClientUpdateOptions contains the optional parameters for the EndpointsClient.Update method. func (client *EndpointsClient) Update(ctx context.Context, resourceGroupName string, profileName string, endpointType EndpointType, endpointName string, parameters Endpoint, options *EndpointsClientUpdateOptions) (EndpointsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, profileName, endpointType, endpointName, parameters, options) if err != nil { return EndpointsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return EndpointsClientUpdateResponse{}, err } @@ -302,7 +295,7 @@ func (client *EndpointsClient) updateCreateRequest(ctx context.Context, resource return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/endpoints_client_example_test.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/endpoints_client_example_test.go index 775a62e5e4b9..905861a5eb7f 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/endpoints_client_example_test.go +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/endpoints_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 armtrafficmanager_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/trafficmanager/armtrafficmanager" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-PATCH-External-Target.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-PATCH-External-Target.json func ExampleEndpointsClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewEndpointsClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "azuresdkfornetautoresttrafficmanager1421", "azsmnet6386", armtrafficmanager.EndpointTypeExternalEndpoints, "azsmnet7187", armtrafficmanager.Endpoint{ + res, err := clientFactory.NewEndpointsClient().Update(ctx, "azuresdkfornetautoresttrafficmanager1421", "azsmnet6386", armtrafficmanager.EndpointTypeExternalEndpoints, "azsmnet7187", armtrafficmanager.Endpoint{ Name: to.Ptr("azsmnet7187"), Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1421/providers/Microsoft.Network/trafficManagerProfiles/azsmnet6386/externalEndpoints/azsmnet7187"), @@ -39,79 +40,145 @@ func ExampleEndpointsClient_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.Endpoint = armtrafficmanager.Endpoint{ + // Name: to.Ptr("azsmnet7187"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1421/providers/Microsoft.Network/trafficManagerProfiles/azsmnet6386/externalEndpoints/azsmnet7187"), + // Properties: &armtrafficmanager.EndpointProperties{ + // EndpointLocation: to.Ptr("North Europe"), + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusCheckingEndpoint), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("another.foobar.contoso.com"), + // Weight: to.Ptr[int64](1), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-GET-External-WithGeoMapping.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-GET-External-WithGeoMapping.json func ExampleEndpointsClient_Get_endpointGetExternalWithGeoMapping() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewEndpointsClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "azuresdkfornetautoresttrafficmanager2191", "azuresdkfornetautoresttrafficmanager8224", armtrafficmanager.EndpointTypeExternalEndpoints, "My%20external%20endpoint", nil) + res, err := clientFactory.NewEndpointsClient().Get(ctx, "azuresdkfornetautoresttrafficmanager2191", "azuresdkfornetautoresttrafficmanager8224", armtrafficmanager.EndpointTypeExternalEndpoints, "My%20external%20endpoint", 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.Endpoint = armtrafficmanager.Endpoint{ + // Name: to.Ptr("My external endpoint"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager2191/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager8224/externalEndpoints/My external endpoint"), + // Properties: &armtrafficmanager.EndpointProperties{ + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusCheckingEndpoint), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // GeoMapping: []*string{ + // to.Ptr("GEO-AS"), + // to.Ptr("GEO-AF")}, + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("foobar.contoso.com"), + // Weight: to.Ptr[int64](1), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-GET-External-WithLocation.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-GET-External-WithLocation.json func ExampleEndpointsClient_Get_endpointGetExternalWithLocation() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewEndpointsClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "azuresdkfornetautoresttrafficmanager1421", "azsmnet6386", armtrafficmanager.EndpointTypeExternalEndpoints, "azsmnet7187", nil) + res, err := clientFactory.NewEndpointsClient().Get(ctx, "azuresdkfornetautoresttrafficmanager1421", "azsmnet6386", armtrafficmanager.EndpointTypeExternalEndpoints, "azsmnet7187", 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.Endpoint = armtrafficmanager.Endpoint{ + // Name: to.Ptr("azsmnet7187"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1421/providers/Microsoft.Network/trafficManagerProfiles/azsmnet6386/externalEndpoints/azsmnet7187"), + // Properties: &armtrafficmanager.EndpointProperties{ + // EndpointLocation: to.Ptr("North Europe"), + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusCheckingEndpoint), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("foobar.contoso.com"), + // Weight: to.Ptr[int64](1), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-GET-External-WithSubnetMapping.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-GET-External-WithSubnetMapping.json func ExampleEndpointsClient_Get_endpointGetExternalWithSubnetMapping() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewEndpointsClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "azuresdkfornetautoresttrafficmanager2191", "azuresdkfornetautoresttrafficmanager8224", armtrafficmanager.EndpointTypeExternalEndpoints, "My%20external%20endpoint", nil) + res, err := clientFactory.NewEndpointsClient().Get(ctx, "azuresdkfornetautoresttrafficmanager2191", "azuresdkfornetautoresttrafficmanager8224", armtrafficmanager.EndpointTypeExternalEndpoints, "My%20external%20endpoint", 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.Endpoint = armtrafficmanager.Endpoint{ + // Name: to.Ptr("My external endpoint"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager2191/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager8224/externalEndpoints/My external endpoint"), + // Properties: &armtrafficmanager.EndpointProperties{ + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusCheckingEndpoint), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // Priority: to.Ptr[int64](1), + // Subnets: []*armtrafficmanager.EndpointPropertiesSubnetsItem{ + // { + // First: to.Ptr("1.2.3.0"), + // Scope: to.Ptr[int32](24), + // }, + // { + // First: to.Ptr("25.26.27.28"), + // Last: to.Ptr("29.30.31.32"), + // }}, + // Target: to.Ptr("foobar.contoso.com"), + // Weight: to.Ptr[int64](1), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-PUT-External-WithAlwaysServe.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-PUT-External-WithAlwaysServe.json func ExampleEndpointsClient_CreateOrUpdate_endpointPutExternalWithAlwaysServe() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewEndpointsClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager1421", "azsmnet6386", armtrafficmanager.EndpointTypeExternalEndpoints, "azsmnet7187", armtrafficmanager.Endpoint{ + res, err := clientFactory.NewEndpointsClient().CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager1421", "azsmnet6386", armtrafficmanager.EndpointTypeExternalEndpoints, "azsmnet7187", armtrafficmanager.Endpoint{ Name: to.Ptr("azsmnet7187"), Type: to.Ptr("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), Properties: &armtrafficmanager.EndpointProperties{ @@ -124,22 +191,37 @@ func ExampleEndpointsClient_CreateOrUpdate_endpointPutExternalWithAlwaysServe() 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.Endpoint = armtrafficmanager.Endpoint{ + // Name: to.Ptr("azsmnet7187"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1421/providers/Microsoft.Network/trafficManagerProfiles/azsmnet6386/externalEndpoints/azsmnet7187"), + // Properties: &armtrafficmanager.EndpointProperties{ + // AlwaysServe: to.Ptr(armtrafficmanager.AlwaysServeEnabled), + // EndpointLocation: to.Ptr("North Europe"), + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusCheckingEndpoint), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("foobar.contoso.com"), + // Weight: to.Ptr[int64](1), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-PUT-External-WithCustomHeaders.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-PUT-External-WithCustomHeaders.json func ExampleEndpointsClient_CreateOrUpdate_endpointPutExternalWithCustomHeaders() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewEndpointsClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager1421", "azsmnet6386", armtrafficmanager.EndpointTypeExternalEndpoints, "azsmnet7187", armtrafficmanager.Endpoint{ + res, err := clientFactory.NewEndpointsClient().CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager1421", "azsmnet6386", armtrafficmanager.EndpointTypeExternalEndpoints, "azsmnet7187", armtrafficmanager.Endpoint{ Name: to.Ptr("azsmnet7187"), Type: to.Ptr("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), Properties: &armtrafficmanager.EndpointProperties{ @@ -160,22 +242,45 @@ func ExampleEndpointsClient_CreateOrUpdate_endpointPutExternalWithCustomHeaders( 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.Endpoint = armtrafficmanager.Endpoint{ + // Name: to.Ptr("azsmnet7187"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1421/providers/Microsoft.Network/trafficManagerProfiles/azsmnet6386/externalEndpoints/azsmnet7187"), + // Properties: &armtrafficmanager.EndpointProperties{ + // CustomHeaders: []*armtrafficmanager.EndpointPropertiesCustomHeadersItem{ + // { + // Name: to.Ptr("header-1"), + // Value: to.Ptr("value-1"), + // }, + // { + // Name: to.Ptr("header-2"), + // Value: to.Ptr("value-2"), + // }}, + // EndpointLocation: to.Ptr("North Europe"), + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusCheckingEndpoint), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("foobar.contoso.com"), + // Weight: to.Ptr[int64](1), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-PUT-External-WithGeoMapping.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-PUT-External-WithGeoMapping.json func ExampleEndpointsClient_CreateOrUpdate_endpointPutExternalWithGeoMapping() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewEndpointsClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager2191", "azuresdkfornetautoresttrafficmanager8224", armtrafficmanager.EndpointTypeExternalEndpoints, "My%20external%20endpoint", armtrafficmanager.Endpoint{ + res, err := clientFactory.NewEndpointsClient().CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager2191", "azuresdkfornetautoresttrafficmanager8224", armtrafficmanager.EndpointTypeExternalEndpoints, "My%20external%20endpoint", armtrafficmanager.Endpoint{ Name: to.Ptr("My external endpoint"), Type: to.Ptr("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), Properties: &armtrafficmanager.EndpointProperties{ @@ -189,22 +294,38 @@ func ExampleEndpointsClient_CreateOrUpdate_endpointPutExternalWithGeoMapping() { 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.Endpoint = armtrafficmanager.Endpoint{ + // Name: to.Ptr("My external endpoint"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager2191/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager8224/externalEndpoints/My external endpoint"), + // Properties: &armtrafficmanager.EndpointProperties{ + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusCheckingEndpoint), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // GeoMapping: []*string{ + // to.Ptr("GEO-AS"), + // to.Ptr("GEO-AF")}, + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("foobar.contoso.com"), + // Weight: to.Ptr[int64](1), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-PUT-External-WithLocation.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-PUT-External-WithLocation.json func ExampleEndpointsClient_CreateOrUpdate_endpointPutExternalWithLocation() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewEndpointsClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager1421", "azsmnet6386", armtrafficmanager.EndpointTypeExternalEndpoints, "azsmnet7187", armtrafficmanager.Endpoint{ + res, err := clientFactory.NewEndpointsClient().CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager1421", "azsmnet6386", armtrafficmanager.EndpointTypeExternalEndpoints, "azsmnet7187", armtrafficmanager.Endpoint{ Name: to.Ptr("azsmnet7187"), Type: to.Ptr("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), Properties: &armtrafficmanager.EndpointProperties{ @@ -216,22 +337,36 @@ func ExampleEndpointsClient_CreateOrUpdate_endpointPutExternalWithLocation() { 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.Endpoint = armtrafficmanager.Endpoint{ + // Name: to.Ptr("azsmnet7187"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1421/providers/Microsoft.Network/trafficManagerProfiles/azsmnet6386/externalEndpoints/azsmnet7187"), + // Properties: &armtrafficmanager.EndpointProperties{ + // EndpointLocation: to.Ptr("North Europe"), + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusCheckingEndpoint), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("foobar.contoso.com"), + // Weight: to.Ptr[int64](1), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-PUT-External-WithSubnetMapping.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-PUT-External-WithSubnetMapping.json func ExampleEndpointsClient_CreateOrUpdate_endpointPutExternalWithSubnetMapping() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewEndpointsClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager2191", "azuresdkfornetautoresttrafficmanager8224", armtrafficmanager.EndpointTypeExternalEndpoints, "My%20external%20endpoint", armtrafficmanager.Endpoint{ + res, err := clientFactory.NewEndpointsClient().CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager2191", "azuresdkfornetautoresttrafficmanager8224", armtrafficmanager.EndpointTypeExternalEndpoints, "My%20external%20endpoint", armtrafficmanager.Endpoint{ Name: to.Ptr("My external endpoint"), Type: to.Ptr("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), Properties: &armtrafficmanager.EndpointProperties{ @@ -251,25 +386,50 @@ func ExampleEndpointsClient_CreateOrUpdate_endpointPutExternalWithSubnetMapping( 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.Endpoint = armtrafficmanager.Endpoint{ + // Name: to.Ptr("My external endpoint"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager2191/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager8224/externalEndpoints/My external endpoint"), + // Properties: &armtrafficmanager.EndpointProperties{ + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusCheckingEndpoint), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // Priority: to.Ptr[int64](1), + // Subnets: []*armtrafficmanager.EndpointPropertiesSubnetsItem{ + // { + // First: to.Ptr("1.2.3.0"), + // Scope: to.Ptr[int32](24), + // }, + // { + // First: to.Ptr("25.26.27.28"), + // Last: to.Ptr("29.30.31.32"), + // }}, + // Target: to.Ptr("foobar.contoso.com"), + // Weight: to.Ptr[int64](1), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-DELETE-External.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Endpoint-DELETE-External.json func ExampleEndpointsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewEndpointsClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Delete(ctx, "azuresdkfornetautoresttrafficmanager1421", "azsmnet6386", armtrafficmanager.EndpointTypeExternalEndpoints, "azsmnet7187", nil) + res, err := clientFactory.NewEndpointsClient().Delete(ctx, "azuresdkfornetautoresttrafficmanager1421", "azsmnet6386", armtrafficmanager.EndpointTypeExternalEndpoints, "azsmnet7187", 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.DeleteOperationResult = armtrafficmanager.DeleteOperationResult{ + // } } diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/geographichierarchies_client.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/geographichierarchies_client.go index df74885fc0b7..233457f67b53 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/geographichierarchies_client.go +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/geographichierarchies_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,43 +21,35 @@ import ( // GeographicHierarchiesClient contains the methods for the GeographicHierarchies group. // Don't use this type directly, use NewGeographicHierarchiesClient() instead. type GeographicHierarchiesClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewGeographicHierarchiesClient creates a new instance of GeographicHierarchiesClient 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 NewGeographicHierarchiesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*GeographicHierarchiesClient, 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+".GeographicHierarchiesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &GeographicHierarchiesClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // GetDefault - Gets the default Geographic Hierarchy used by the Geographic traffic routing method. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-04-01-preview -// options - GeographicHierarchiesClientGetDefaultOptions contains the optional parameters for the GeographicHierarchiesClient.GetDefault -// method. +// - options - GeographicHierarchiesClientGetDefaultOptions contains the optional parameters for the GeographicHierarchiesClient.GetDefault +// method. func (client *GeographicHierarchiesClient) GetDefault(ctx context.Context, options *GeographicHierarchiesClientGetDefaultOptions) (GeographicHierarchiesClientGetDefaultResponse, error) { req, err := client.getDefaultCreateRequest(ctx, options) if err != nil { return GeographicHierarchiesClientGetDefaultResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GeographicHierarchiesClientGetDefaultResponse{}, err } @@ -72,7 +62,7 @@ func (client *GeographicHierarchiesClient) GetDefault(ctx context.Context, optio // getDefaultCreateRequest creates the GetDefault request. func (client *GeographicHierarchiesClient) getDefaultCreateRequest(ctx context.Context, options *GeographicHierarchiesClientGetDefaultOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Network/trafficManagerGeographicHierarchies/default" - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/trafficmanager/armtrafficmanager/geographichierarchies_client_example_test.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/geographichierarchies_client_example_test.go index d298377c48ba..0ae2bdfc4108 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/geographichierarchies_client_example_test.go +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/geographichierarchies_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 armtrafficmanager_test @@ -16,21 +17,73 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/trafficmanager/armtrafficmanager" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/GeographicHierarchy-GET-default.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/GeographicHierarchy-GET-default.json func ExampleGeographicHierarchiesClient_GetDefault() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewGeographicHierarchiesClient(cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.GetDefault(ctx, nil) + res, err := clientFactory.NewGeographicHierarchiesClient().GetDefault(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.GeographicHierarchy = armtrafficmanager.GeographicHierarchy{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Network/trafficManagerGeographicHierarchies"), + // ID: to.Ptr("/providers/Microsoft.Network/trafficManagerGeographicHierarchies/default"), + // Properties: &armtrafficmanager.GeographicHierarchyProperties{ + // GeographicHierarchy: &armtrafficmanager.Region{ + // Name: to.Ptr("World"), + // Code: to.Ptr("WORLD"), + // Regions: []*armtrafficmanager.Region{ + // { + // Name: to.Ptr("Middle East"), + // Code: to.Ptr("GEO-ME"), + // Regions: []*armtrafficmanager.Region{ + // { + // Name: to.Ptr("United Arab Emirates"), + // Code: to.Ptr("AE"), + // Regions: []*armtrafficmanager.Region{ + // }, + // }}, + // }, + // { + // Name: to.Ptr("Australia / Pacific"), + // Code: to.Ptr("GEO-AP"), + // Regions: []*armtrafficmanager.Region{ + // { + // Name: to.Ptr("Australia"), + // Code: to.Ptr("AU"), + // Regions: []*armtrafficmanager.Region{ + // { + // Name: to.Ptr("Australian Capital Territory"), + // Code: to.Ptr("AU-ACT"), + // Regions: []*armtrafficmanager.Region{ + // }, + // }, + // { + // Name: to.Ptr("New South Wales"), + // Code: to.Ptr("AU-NSW"), + // Regions: []*armtrafficmanager.Region{ + // }, + // }}, + // }, + // { + // Name: to.Ptr("Cook Islands"), + // Code: to.Ptr("CK"), + // Regions: []*armtrafficmanager.Region{ + // }, + // }}, + // }}, + // }, + // }, + // } } diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/go.mod b/sdk/resourcemanager/trafficmanager/armtrafficmanager/go.mod index d84e94fba66f..2f2102289587 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/go.mod +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/trafficmanager/armt 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/trafficmanager/armtrafficmanager/go.sum b/sdk/resourcemanager/trafficmanager/armtrafficmanager/go.sum index 8828b17b1853..8ba445a8c4da 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/go.sum +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/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/trafficmanager/armtrafficmanager/heatmap_client.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/heatmap_client.go index 0761a2c3fb47..004aeca3741a 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/heatmap_client.go +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/heatmap_client.go @@ -15,8 +15,6 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,47 +25,39 @@ import ( // HeatMapClient contains the methods for the HeatMap group. // Don't use this type directly, use NewHeatMapClient() instead. type HeatMapClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewHeatMapClient creates a new instance of HeatMapClient 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 NewHeatMapClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*HeatMapClient, 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+".HeatMapClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &HeatMapClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets latest heatmap for Traffic Manager profile. // 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. -// profileName - The name of the Traffic Manager profile. -// options - HeatMapClientGetOptions contains the optional parameters for the HeatMapClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - profileName - The name of the Traffic Manager profile. +// - options - HeatMapClientGetOptions contains the optional parameters for the HeatMapClient.Get method. func (client *HeatMapClient) Get(ctx context.Context, resourceGroupName string, profileName string, options *HeatMapClientGetOptions) (HeatMapClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, profileName, options) if err != nil { return HeatMapClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HeatMapClientGetResponse{}, err } @@ -93,7 +83,7 @@ func (client *HeatMapClient) getCreateRequest(ctx context.Context, resourceGroup } urlPath = strings.ReplaceAll(urlPath, "{profileName}", url.PathEscape(profileName)) urlPath = strings.ReplaceAll(urlPath, "{heatMapType}", url.PathEscape("default")) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/trafficmanager/armtrafficmanager/heatmap_client_example_test.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/heatmap_client_example_test.go index 579df153b59f..4e4660441825 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/heatmap_client_example_test.go +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/heatmap_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 armtrafficmanager_test @@ -16,60 +17,163 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/trafficmanager/armtrafficmanager" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/HeatMap-GET.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/HeatMap-GET.json func ExampleHeatMapClient_Get_heatMapGet() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewHeatMapClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "azuresdkfornetautoresttrafficmanager1323", "azuresdkfornetautoresttrafficmanager3880", &armtrafficmanager.HeatMapClientGetOptions{TopLeft: []float64{}, + res, err := clientFactory.NewHeatMapClient().Get(ctx, "azuresdkfornetautoresttrafficmanager1323", "azuresdkfornetautoresttrafficmanager3880", &armtrafficmanager.HeatMapClientGetOptions{TopLeft: []float64{}, BotRight: []float64{}, }) 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.HeatMapModel = armtrafficmanager.HeatMapModel{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/heatMaps/latencyVolumeByLocation"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1323/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager3880/heatMaps/latencyVolumeByLocation"), + // Properties: &armtrafficmanager.HeatMapProperties{ + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-22T12:50:00Z"); return t}()), + // Endpoints: []*armtrafficmanager.HeatMapEndpoint{ + // { + // EndpointID: to.Ptr[int32](1), + // ResourceID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1323/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager3880/externalEndpoints/azuresdkfornetautoresttrafficmanager3880"), + // }, + // { + // EndpointID: to.Ptr[int32](2), + // ResourceID: to.Ptr("/subscriptions/562d4115-c01e-4m67-9bbd-c11c2d58ad73/resourceGroups/azuresdkfornetautoresttrafficmanager1300/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager3885/externalEndpoints/azuresdkfornetautoresttrafficmanager3881"), + // }}, + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-15T12:00:00Z"); return t}()), + // TrafficFlows: []*armtrafficmanager.TrafficFlow{ + // { + // Latitude: to.Ptr[float64](99.99), + // Longitude: to.Ptr[float64](0), + // QueryExperiences: []*armtrafficmanager.QueryExperience{ + // { + // EndpointID: to.Ptr[int32](1), + // Latency: to.Ptr[float64](99.222), + // QueryCount: to.Ptr[int32](1000000), + // }, + // { + // EndpointID: to.Ptr[int32](2), + // Latency: to.Ptr[float64](1.222), + // QueryCount: to.Ptr[int32](1), + // }}, + // SourceIP: to.Ptr("1.1.1.1"), + // }, + // { + // Latitude: to.Ptr[float64](-99.99), + // Longitude: to.Ptr[float64](1), + // QueryExperiences: []*armtrafficmanager.QueryExperience{ + // { + // EndpointID: to.Ptr[int32](1), + // Latency: to.Ptr[float64](96.222), + // QueryCount: to.Ptr[int32](100), + // }, + // { + // EndpointID: to.Ptr[int32](2), + // Latency: to.Ptr[float64](4.222), + // QueryCount: to.Ptr[int32](500), + // }}, + // SourceIP: to.Ptr("2.255.1.1"), + // }}, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/HeatMap-GET-With-Null-Values.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/HeatMap-GET-With-Null-Values.json func ExampleHeatMapClient_Get_heatMapGetWithNullValues() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewHeatMapClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "azuresdkfornetautoresttrafficmanager1323", "azuresdkfornetautoresttrafficmanager3880", &armtrafficmanager.HeatMapClientGetOptions{TopLeft: []float64{}, + res, err := clientFactory.NewHeatMapClient().Get(ctx, "azuresdkfornetautoresttrafficmanager1323", "azuresdkfornetautoresttrafficmanager3880", &armtrafficmanager.HeatMapClientGetOptions{TopLeft: []float64{}, BotRight: []float64{}, }) 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.HeatMapModel = armtrafficmanager.HeatMapModel{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/heatMaps/default"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1323/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager3880/heatMaps/default"), + // Properties: &armtrafficmanager.HeatMapProperties{ + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-22T12:50:00Z"); return t}()), + // Endpoints: []*armtrafficmanager.HeatMapEndpoint{ + // { + // EndpointID: to.Ptr[int32](0), + // ResourceID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1323/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager3880/externalEndpoints/azuresdkfornetautoresttrafficmanager3880"), + // }, + // { + // EndpointID: to.Ptr[int32](1), + // ResourceID: to.Ptr("/subscriptions/562d4115-c01e-4m67-9bbd-c11c2d58ad73/resourceGroups/azuresdkfornetautoresttrafficmanager1300/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager3885/externalEndpoints/azuresdkfornetautoresttrafficmanager3881"), + // }}, + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-15T12:00:00Z"); return t}()), + // TrafficFlows: []*armtrafficmanager.TrafficFlow{ + // { + // Latitude: to.Ptr[float64](99.99), + // Longitude: to.Ptr[float64](0), + // QueryExperiences: []*armtrafficmanager.QueryExperience{ + // { + // EndpointID: to.Ptr[int32](0), + // Latency: to.Ptr[float64](99), + // QueryCount: to.Ptr[int32](1000000), + // }, + // { + // EndpointID: to.Ptr[int32](1), + // Latency: to.Ptr[float64](1), + // QueryCount: to.Ptr[int32](1), + // }}, + // SourceIP: to.Ptr("1.1.1.1"), + // }, + // { + // Latitude: to.Ptr[float64](1.11), + // Longitude: to.Ptr[float64](-2.35), + // QueryExperiences: []*armtrafficmanager.QueryExperience{ + // { + // EndpointID: to.Ptr[int32](0), + // QueryCount: to.Ptr[int32](100), + // }, + // { + // EndpointID: to.Ptr[int32](1), + // Latency: to.Ptr[float64](4.222), + // QueryCount: to.Ptr[int32](500), + // }}, + // SourceIP: to.Ptr("2.255.1.1"), + // }}, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/HeatMap-GET-With-TopLeft-BotRight.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/HeatMap-GET-With-TopLeft-BotRight.json func ExampleHeatMapClient_Get_heatMapGetWithTopLeftBotRight() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewHeatMapClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "azuresdkfornetautoresttrafficmanager1323", "azuresdkfornetautoresttrafficmanager3880", &armtrafficmanager.HeatMapClientGetOptions{TopLeft: []float64{ + res, err := clientFactory.NewHeatMapClient().Get(ctx, "azuresdkfornetautoresttrafficmanager1323", "azuresdkfornetautoresttrafficmanager3880", &armtrafficmanager.HeatMapClientGetOptions{TopLeft: []float64{ 10, 50.001}, BotRight: []float64{ @@ -79,6 +183,58 @@ func ExampleHeatMapClient_Get_heatMapGetWithTopLeftBotRight() { 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.HeatMapModel = armtrafficmanager.HeatMapModel{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/heatMaps/latencyVolumeByLocation"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1323/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager3880/heatMaps/latencyVolumeByLocation"), + // Properties: &armtrafficmanager.HeatMapProperties{ + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-22T12:50:00Z"); return t}()), + // Endpoints: []*armtrafficmanager.HeatMapEndpoint{ + // { + // EndpointID: to.Ptr[int32](1), + // ResourceID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1323/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager3880/externalEndpoints/azuresdkfornetautoresttrafficmanager3880"), + // }, + // { + // EndpointID: to.Ptr[int32](2), + // ResourceID: to.Ptr("/subscriptions/562d4115-c01e-4m67-9bbd-c11c2d58ad73/resourceGroups/azuresdkfornetautoresttrafficmanager1300/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager3885/externalEndpoints/azuresdkfornetautoresttrafficmanager3881"), + // }}, + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-15T12:00:00Z"); return t}()), + // TrafficFlows: []*armtrafficmanager.TrafficFlow{ + // { + // Latitude: to.Ptr[float64](9.99), + // Longitude: to.Ptr[float64](75.01), + // QueryExperiences: []*armtrafficmanager.QueryExperience{ + // { + // EndpointID: to.Ptr[int32](1), + // Latency: to.Ptr[float64](99.222), + // QueryCount: to.Ptr[int32](1000000), + // }, + // { + // EndpointID: to.Ptr[int32](2), + // Latency: to.Ptr[float64](1.222), + // QueryCount: to.Ptr[int32](1), + // }}, + // SourceIP: to.Ptr("1.1.1.1"), + // }, + // { + // Latitude: to.Ptr[float64](-49.99), + // Longitude: to.Ptr[float64](51), + // QueryExperiences: []*armtrafficmanager.QueryExperience{ + // { + // EndpointID: to.Ptr[int32](1), + // Latency: to.Ptr[float64](96.222), + // QueryCount: to.Ptr[int32](100), + // }, + // { + // EndpointID: to.Ptr[int32](2), + // Latency: to.Ptr[float64](4.222), + // QueryCount: to.Ptr[int32](500), + // }}, + // SourceIP: to.Ptr("2.255.1.1"), + // }}, + // }, + // } } diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/models.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/models.go index 72ceacddacbe..7e296485253f 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/models.go +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/models.go @@ -375,12 +375,14 @@ type ProfilesClientGetOptions struct { // placeholder for future optional parameters } -// ProfilesClientListByResourceGroupOptions contains the optional parameters for the ProfilesClient.ListByResourceGroup method. +// ProfilesClientListByResourceGroupOptions contains the optional parameters for the ProfilesClient.NewListByResourceGroupPager +// method. type ProfilesClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// ProfilesClientListBySubscriptionOptions contains the optional parameters for the ProfilesClient.ListBySubscription method. +// ProfilesClientListBySubscriptionOptions contains the optional parameters for the ProfilesClient.NewListBySubscriptionPager +// method. type ProfilesClientListBySubscriptionOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/models_serde.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/models_serde.go index 9805bb32fa68..5182d4084058 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/models_serde.go +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/models_serde.go @@ -18,7 +18,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type CheckTrafficManagerRelativeDNSNameAvailabilityParameters. func (c CheckTrafficManagerRelativeDNSNameAvailabilityParameters) 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) @@ -49,7 +49,7 @@ func (c *CheckTrafficManagerRelativeDNSNameAvailabilityParameters) UnmarshalJSON // MarshalJSON implements the json.Marshaller interface for type DNSConfig. func (d DNSConfig) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "fqdn", d.Fqdn) populate(objectMap, "relativeName", d.RelativeName) populate(objectMap, "ttl", d.TTL) @@ -84,7 +84,7 @@ func (d *DNSConfig) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DeleteOperationResult. func (d DeleteOperationResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "boolean", d.OperationResult) return json.Marshal(objectMap) } @@ -111,7 +111,7 @@ func (d *DeleteOperationResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Endpoint. func (e Endpoint) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", e.ID) populate(objectMap, "name", e.Name) populate(objectMap, "properties", e.Properties) @@ -150,7 +150,7 @@ func (e *Endpoint) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EndpointProperties. func (e EndpointProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "alwaysServe", e.AlwaysServe) populate(objectMap, "customHeaders", e.CustomHeaders) populate(objectMap, "endpointLocation", e.EndpointLocation) @@ -229,7 +229,7 @@ func (e *EndpointProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EndpointPropertiesCustomHeadersItem. func (e EndpointPropertiesCustomHeadersItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", e.Name) populate(objectMap, "value", e.Value) return json.Marshal(objectMap) @@ -260,7 +260,7 @@ func (e *EndpointPropertiesCustomHeadersItem) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EndpointPropertiesSubnetsItem. func (e EndpointPropertiesSubnetsItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "first", e.First) populate(objectMap, "last", e.Last) populate(objectMap, "scope", e.Scope) @@ -295,7 +295,7 @@ func (e *EndpointPropertiesSubnetsItem) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GeographicHierarchy. func (g GeographicHierarchy) 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) @@ -334,7 +334,7 @@ func (g *GeographicHierarchy) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GeographicHierarchyProperties. func (g GeographicHierarchyProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "geographicHierarchy", g.GeographicHierarchy) return json.Marshal(objectMap) } @@ -361,7 +361,7 @@ func (g *GeographicHierarchyProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HeatMapEndpoint. func (h HeatMapEndpoint) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "endpointId", h.EndpointID) populate(objectMap, "resourceId", h.ResourceID) return json.Marshal(objectMap) @@ -392,7 +392,7 @@ func (h *HeatMapEndpoint) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HeatMapModel. func (h HeatMapModel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", h.ID) populate(objectMap, "name", h.Name) populate(objectMap, "properties", h.Properties) @@ -431,7 +431,7 @@ func (h *HeatMapModel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HeatMapProperties. func (h HeatMapProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "endTime", h.EndTime) populate(objectMap, "endpoints", h.Endpoints) populateTimeRFC3339(objectMap, "startTime", h.StartTime) @@ -470,7 +470,7 @@ func (h *HeatMapProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitorConfig. func (m MonitorConfig) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "customHeaders", m.CustomHeaders) populate(objectMap, "expectedStatusCodeRanges", m.ExpectedStatusCodeRanges) populate(objectMap, "intervalInSeconds", m.IntervalInSeconds) @@ -529,7 +529,7 @@ func (m *MonitorConfig) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitorConfigCustomHeadersItem. func (m MonitorConfigCustomHeadersItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", m.Name) populate(objectMap, "value", m.Value) return json.Marshal(objectMap) @@ -560,7 +560,7 @@ func (m *MonitorConfigCustomHeadersItem) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitorConfigExpectedStatusCodeRangesItem. func (m MonitorConfigExpectedStatusCodeRangesItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "max", m.Max) populate(objectMap, "min", m.Min) return json.Marshal(objectMap) @@ -591,7 +591,7 @@ func (m *MonitorConfigExpectedStatusCodeRangesItem) UnmarshalJSON(data []byte) e // MarshalJSON implements the json.Marshaller interface for type NameAvailability. func (n NameAvailability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "message", n.Message) populate(objectMap, "name", n.Name) populate(objectMap, "nameAvailable", n.NameAvailable) @@ -634,7 +634,7 @@ func (n *NameAvailability) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Profile. func (p Profile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "location", p.Location) populate(objectMap, "name", p.Name) @@ -681,7 +681,7 @@ func (p *Profile) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ProfileListResult. func (p ProfileListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "value", p.Value) return json.Marshal(objectMap) } @@ -708,7 +708,7 @@ func (p *ProfileListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ProfileProperties. func (p ProfileProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allowedEndpointRecordTypes", p.AllowedEndpointRecordTypes) populate(objectMap, "dnsConfig", p.DNSConfig) populate(objectMap, "endpoints", p.Endpoints) @@ -763,7 +763,7 @@ func (p *ProfileProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ProxyResource. func (p ProxyResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) populate(objectMap, "type", p.Type) @@ -798,7 +798,7 @@ func (p *ProxyResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type QueryExperience. func (q QueryExperience) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "endpointId", q.EndpointID) populate(objectMap, "latency", q.Latency) populate(objectMap, "queryCount", q.QueryCount) @@ -833,7 +833,7 @@ func (q *QueryExperience) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Region. func (r Region) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "code", r.Code) populate(objectMap, "name", r.Name) populate(objectMap, "regions", r.Regions) @@ -868,7 +868,7 @@ func (r *Region) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Resource. func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "name", r.Name) populate(objectMap, "type", r.Type) @@ -903,7 +903,7 @@ func (r *Resource) 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) @@ -946,7 +946,7 @@ func (t *TrackedResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrafficFlow. func (t TrafficFlow) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "latitude", t.Latitude) populate(objectMap, "longitude", t.Longitude) populate(objectMap, "queryExperiences", t.QueryExperiences) @@ -985,7 +985,7 @@ func (t *TrafficFlow) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UserMetricsModel. func (u UserMetricsModel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", u.ID) populate(objectMap, "name", u.Name) populate(objectMap, "properties", u.Properties) @@ -1024,7 +1024,7 @@ func (u *UserMetricsModel) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UserMetricsProperties. func (u UserMetricsProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "key", u.Key) return json.Marshal(objectMap) } @@ -1049,7 +1049,7 @@ func (u *UserMetricsProperties) 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) { @@ -1059,7 +1059,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/trafficmanager/armtrafficmanager/profiles_client.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/profiles_client.go index d5bca4a78e91..03b97396f335 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/profiles_client.go +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/profiles_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 ( // ProfilesClient contains the methods for the Profiles group. // Don't use this type directly, use NewProfilesClient() instead. type ProfilesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewProfilesClient creates a new instance of ProfilesClient 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 NewProfilesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProfilesClient, 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+".ProfilesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ProfilesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CheckTrafficManagerRelativeDNSNameAvailability - Checks the availability of a Traffic Manager Relative DNS name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-04-01-preview -// parameters - The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. -// options - ProfilesClientCheckTrafficManagerRelativeDNSNameAvailabilityOptions contains the optional parameters for the -// ProfilesClient.CheckTrafficManagerRelativeDNSNameAvailability method. +// - parameters - The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. +// - options - ProfilesClientCheckTrafficManagerRelativeDNSNameAvailabilityOptions contains the optional parameters for the +// ProfilesClient.CheckTrafficManagerRelativeDNSNameAvailability method. func (client *ProfilesClient) CheckTrafficManagerRelativeDNSNameAvailability(ctx context.Context, parameters CheckTrafficManagerRelativeDNSNameAvailabilityParameters, options *ProfilesClientCheckTrafficManagerRelativeDNSNameAvailabilityOptions) (ProfilesClientCheckTrafficManagerRelativeDNSNameAvailabilityResponse, error) { req, err := client.checkTrafficManagerRelativeDNSNameAvailabilityCreateRequest(ctx, parameters, options) if err != nil { return ProfilesClientCheckTrafficManagerRelativeDNSNameAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProfilesClientCheckTrafficManagerRelativeDNSNameAvailabilityResponse{}, err } @@ -79,7 +69,7 @@ func (client *ProfilesClient) CheckTrafficManagerRelativeDNSNameAvailability(ctx // checkTrafficManagerRelativeDNSNameAvailabilityCreateRequest creates the CheckTrafficManagerRelativeDNSNameAvailability request. func (client *ProfilesClient) checkTrafficManagerRelativeDNSNameAvailabilityCreateRequest(ctx context.Context, parameters CheckTrafficManagerRelativeDNSNameAvailabilityParameters, options *ProfilesClientCheckTrafficManagerRelativeDNSNameAvailabilityOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Network/checkTrafficManagerNameAvailability" - 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 } @@ -101,17 +91,18 @@ func (client *ProfilesClient) checkTrafficManagerRelativeDNSNameAvailabilityHand // CreateOrUpdate - Create or update a Traffic Manager profile. // 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. -// profileName - The name of the Traffic Manager profile. -// parameters - The Traffic Manager profile parameters supplied to the CreateOrUpdate operation. -// options - ProfilesClientCreateOrUpdateOptions contains the optional parameters for the ProfilesClient.CreateOrUpdate method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - profileName - The name of the Traffic Manager profile. +// - parameters - The Traffic Manager profile parameters supplied to the CreateOrUpdate operation. +// - options - ProfilesClientCreateOrUpdateOptions contains the optional parameters for the ProfilesClient.CreateOrUpdate method. func (client *ProfilesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, profileName string, parameters Profile, options *ProfilesClientCreateOrUpdateOptions) (ProfilesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, profileName, parameters, options) if err != nil { return ProfilesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProfilesClientCreateOrUpdateResponse{}, err } @@ -136,7 +127,7 @@ func (client *ProfilesClient) createOrUpdateCreateRequest(ctx context.Context, r return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -158,16 +149,17 @@ func (client *ProfilesClient) createOrUpdateHandleResponse(resp *http.Response) // Delete - Deletes a Traffic Manager profile. // 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. -// profileName - The name of the Traffic Manager profile to be deleted. -// options - ProfilesClientDeleteOptions contains the optional parameters for the ProfilesClient.Delete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - profileName - The name of the Traffic Manager profile to be deleted. +// - options - ProfilesClientDeleteOptions contains the optional parameters for the ProfilesClient.Delete method. func (client *ProfilesClient) Delete(ctx context.Context, resourceGroupName string, profileName string, options *ProfilesClientDeleteOptions) (ProfilesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, profileName, options) if err != nil { return ProfilesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProfilesClientDeleteResponse{}, err } @@ -192,7 +184,7 @@ func (client *ProfilesClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -214,16 +206,17 @@ func (client *ProfilesClient) deleteHandleResponse(resp *http.Response) (Profile // Get - Gets a Traffic Manager profile. // 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. -// profileName - The name of the Traffic Manager profile. -// options - ProfilesClientGetOptions contains the optional parameters for the ProfilesClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - profileName - The name of the Traffic Manager profile. +// - options - ProfilesClientGetOptions contains the optional parameters for the ProfilesClient.Get method. func (client *ProfilesClient) Get(ctx context.Context, resourceGroupName string, profileName string, options *ProfilesClientGetOptions) (ProfilesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, profileName, options) if err != nil { return ProfilesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProfilesClientGetResponse{}, err } @@ -248,7 +241,7 @@ func (client *ProfilesClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -269,10 +262,11 @@ func (client *ProfilesClient) getHandleResponse(resp *http.Response) (ProfilesCl } // NewListByResourceGroupPager - Lists all Traffic Manager profiles 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 - ProfilesClientListByResourceGroupOptions contains the optional parameters for the ProfilesClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ProfilesClientListByResourceGroupOptions contains the optional parameters for the ProfilesClient.NewListByResourceGroupPager +// method. func (client *ProfilesClient) NewListByResourceGroupPager(resourceGroupName string, options *ProfilesClientListByResourceGroupOptions) *runtime.Pager[ProfilesClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[ProfilesClientListByResourceGroupResponse]{ More: func(page ProfilesClientListByResourceGroupResponse) bool { @@ -283,7 +277,7 @@ func (client *ProfilesClient) NewListByResourceGroupPager(resourceGroupName stri if err != nil { return ProfilesClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProfilesClientListByResourceGroupResponse{}, err } @@ -306,7 +300,7 @@ func (client *ProfilesClient) 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 } @@ -327,9 +321,10 @@ func (client *ProfilesClient) listByResourceGroupHandleResponse(resp *http.Respo } // NewListBySubscriptionPager - Lists all Traffic Manager profiles within a subscription. +// // Generated from API version 2022-04-01-preview -// options - ProfilesClientListBySubscriptionOptions contains the optional parameters for the ProfilesClient.ListBySubscription -// method. +// - options - ProfilesClientListBySubscriptionOptions contains the optional parameters for the ProfilesClient.NewListBySubscriptionPager +// method. func (client *ProfilesClient) NewListBySubscriptionPager(options *ProfilesClientListBySubscriptionOptions) *runtime.Pager[ProfilesClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[ProfilesClientListBySubscriptionResponse]{ More: func(page ProfilesClientListBySubscriptionResponse) bool { @@ -340,7 +335,7 @@ func (client *ProfilesClient) NewListBySubscriptionPager(options *ProfilesClient if err != nil { return ProfilesClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProfilesClientListBySubscriptionResponse{}, err } @@ -359,7 +354,7 @@ func (client *ProfilesClient) 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 } @@ -381,17 +376,18 @@ func (client *ProfilesClient) listBySubscriptionHandleResponse(resp *http.Respon // Update - Update a Traffic Manager profile. // 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. -// profileName - The name of the Traffic Manager profile. -// parameters - The Traffic Manager profile parameters supplied to the Update operation. -// options - ProfilesClientUpdateOptions contains the optional parameters for the ProfilesClient.Update method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - profileName - The name of the Traffic Manager profile. +// - parameters - The Traffic Manager profile parameters supplied to the Update operation. +// - options - ProfilesClientUpdateOptions contains the optional parameters for the ProfilesClient.Update method. func (client *ProfilesClient) Update(ctx context.Context, resourceGroupName string, profileName string, parameters Profile, options *ProfilesClientUpdateOptions) (ProfilesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, profileName, parameters, options) if err != nil { return ProfilesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProfilesClientUpdateResponse{}, err } @@ -416,7 +412,7 @@ func (client *ProfilesClient) updateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.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/trafficmanager/armtrafficmanager/profiles_client_example_test.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/profiles_client_example_test.go index 8bb9aa210a3e..82b809fcb349 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/profiles_client_example_test.go +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/profiles_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 armtrafficmanager_test @@ -17,167 +18,504 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/trafficmanager/armtrafficmanager" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/NameAvailabilityTest_NameAvailable-POST-example-21.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/NameAvailabilityTest_NameAvailable-POST-example-21.json func ExampleProfilesClient_CheckTrafficManagerRelativeDNSNameAvailability_nameAvailabilityTestNameAvailablePost21() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewProfilesClient("", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CheckTrafficManagerRelativeDNSNameAvailability(ctx, armtrafficmanager.CheckTrafficManagerRelativeDNSNameAvailabilityParameters{ + res, err := clientFactory.NewProfilesClient().CheckTrafficManagerRelativeDNSNameAvailability(ctx, armtrafficmanager.CheckTrafficManagerRelativeDNSNameAvailabilityParameters{ Name: to.Ptr("azsmnet5403"), Type: to.Ptr("microsoft.network/trafficmanagerprofiles"), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.NameAvailability = armtrafficmanager.NameAvailability{ + // Name: to.Ptr("azsmnet5403"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles"), + // NameAvailable: to.Ptr(true), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/NameAvailabilityTest_NameNotAvailable-POST-example-23.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/NameAvailabilityTest_NameNotAvailable-POST-example-23.json func ExampleProfilesClient_CheckTrafficManagerRelativeDNSNameAvailability_nameAvailabilityTestNameNotAvailablePost23() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewProfilesClient("", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CheckTrafficManagerRelativeDNSNameAvailability(ctx, armtrafficmanager.CheckTrafficManagerRelativeDNSNameAvailabilityParameters{ + res, err := clientFactory.NewProfilesClient().CheckTrafficManagerRelativeDNSNameAvailability(ctx, armtrafficmanager.CheckTrafficManagerRelativeDNSNameAvailabilityParameters{ Name: to.Ptr("azsmnet4696"), Type: to.Ptr("microsoft.network/trafficmanagerprofiles"), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // You could use response here. We use blank identifier for just demo purposes. _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.NameAvailability = armtrafficmanager.NameAvailability{ + // Name: to.Ptr("azsmnet4696"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles"), + // Message: to.Ptr("Domain name azsmnet4696.tmpreview.watmtest.azure-test.net already exists. Please choose a different DNS prefix."), + // NameAvailable: to.Ptr(false), + // Reason: to.Ptr("AlreadyExists"), + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-GET-ByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-GET-ByResourceGroup.json func ExampleProfilesClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewProfilesClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("azuresdkfornetautoresttrafficmanager3640", nil) + pager := clientFactory.NewProfilesClient().NewListByResourceGroupPager("azuresdkfornetautoresttrafficmanager3640", 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.ProfileListResult = armtrafficmanager.ProfileListResult{ + // Value: []*armtrafficmanager.Profile{ + // { + // Name: to.Ptr("azuresdkfornetautoresttrafficmanager1005"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager3640/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager1005"), + // Location: to.Ptr("global"), + // Tags: map[string]*string{ + // }, + // Properties: &armtrafficmanager.ProfileProperties{ + // DNSConfig: &armtrafficmanager.DNSConfig{ + // Fqdn: to.Ptr("azuresdkfornetautoresttrafficmanager1005.tmpreview.watmtest.azure-test.net"), + // RelativeName: to.Ptr("azuresdkfornetautoresttrafficmanager1005"), + // TTL: to.Ptr[int64](35), + // }, + // Endpoints: []*armtrafficmanager.Endpoint{ + // { + // Name: to.Ptr("My external endpoint"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager3640/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager1005/externalEndpoints/My external endpoint"), + // Properties: &armtrafficmanager.EndpointProperties{ + // EndpointLocation: to.Ptr("North Europe"), + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusCheckingEndpoint), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("foobar.contoso.com"), + // Weight: to.Ptr[int64](1), + // }, + // }}, + // MonitorConfig: &armtrafficmanager.MonitorConfig{ + // Path: to.Ptr("/testpath.aspx"), + // IntervalInSeconds: to.Ptr[int64](30), + // Port: to.Ptr[int64](80), + // ProfileMonitorStatus: to.Ptr(armtrafficmanager.ProfileMonitorStatusOnline), + // TimeoutInSeconds: to.Ptr[int64](10), + // ToleratedNumberOfFailures: to.Ptr[int64](3), + // Protocol: to.Ptr(armtrafficmanager.MonitorProtocolHTTP), + // }, + // ProfileStatus: to.Ptr(armtrafficmanager.ProfileStatusEnabled), + // TrafficRoutingMethod: to.Ptr(armtrafficmanager.TrafficRoutingMethodPerformance), + // }, + // }, + // { + // Name: to.Ptr("azuresdkfornetautoresttrafficmanager959"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager3640/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager959"), + // Location: to.Ptr("global"), + // Tags: map[string]*string{ + // }, + // Properties: &armtrafficmanager.ProfileProperties{ + // DNSConfig: &armtrafficmanager.DNSConfig{ + // Fqdn: to.Ptr("azuresdkfornetautoresttrafficmanager959.tmpreview.watmtest.azure-test.net"), + // RelativeName: to.Ptr("azuresdkfornetautoresttrafficmanager959"), + // TTL: to.Ptr[int64](35), + // }, + // Endpoints: []*armtrafficmanager.Endpoint{ + // { + // Name: to.Ptr("My external endpoint"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager3640/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager959/externalEndpoints/My external endpoint"), + // Properties: &armtrafficmanager.EndpointProperties{ + // EndpointLocation: to.Ptr("North Europe"), + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusOnline), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("foobar.contoso.com"), + // Weight: to.Ptr[int64](1), + // }, + // }}, + // MonitorConfig: &armtrafficmanager.MonitorConfig{ + // Path: to.Ptr("/testpath.aspx"), + // IntervalInSeconds: to.Ptr[int64](30), + // Port: to.Ptr[int64](80), + // ProfileMonitorStatus: to.Ptr(armtrafficmanager.ProfileMonitorStatusOnline), + // TimeoutInSeconds: to.Ptr[int64](10), + // ToleratedNumberOfFailures: to.Ptr[int64](3), + // Protocol: to.Ptr(armtrafficmanager.MonitorProtocolHTTP), + // }, + // ProfileStatus: to.Ptr(armtrafficmanager.ProfileStatusEnabled), + // TrafficRoutingMethod: to.Ptr(armtrafficmanager.TrafficRoutingMethodPerformance), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-GET-BySubscription.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-GET-BySubscription.json func ExampleProfilesClient_NewListBySubscriptionPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewProfilesClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListBySubscriptionPager(nil) + pager := clientFactory.NewProfilesClient().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.ProfileListResult = armtrafficmanager.ProfileListResult{ + // Value: []*armtrafficmanager.Profile{ + // { + // Name: to.Ptr("azsmnet5183"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azsmnet1719/providers/Microsoft.Network/trafficManagerProfiles/azsmnet5183"), + // Location: to.Ptr("global"), + // Tags: map[string]*string{ + // }, + // Properties: &armtrafficmanager.ProfileProperties{ + // DNSConfig: &armtrafficmanager.DNSConfig{ + // Fqdn: to.Ptr("azsmnet4696.tmpreview.watmtest.azure-test.net"), + // RelativeName: to.Ptr("azsmnet4696"), + // TTL: to.Ptr[int64](35), + // }, + // Endpoints: []*armtrafficmanager.Endpoint{ + // }, + // MonitorConfig: &armtrafficmanager.MonitorConfig{ + // Path: to.Ptr("/testpath.aspx"), + // IntervalInSeconds: to.Ptr[int64](30), + // Port: to.Ptr[int64](80), + // ProfileMonitorStatus: to.Ptr(armtrafficmanager.ProfileMonitorStatusOnline), + // TimeoutInSeconds: to.Ptr[int64](10), + // ToleratedNumberOfFailures: to.Ptr[int64](3), + // Protocol: to.Ptr(armtrafficmanager.MonitorProtocolHTTP), + // }, + // ProfileStatus: to.Ptr(armtrafficmanager.ProfileStatusEnabled), + // TrafficRoutingMethod: to.Ptr(armtrafficmanager.TrafficRoutingMethodPerformance), + // }, + // }, + // { + // Name: to.Ptr("azuresdkfornetautoresttrafficmanager3440"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager5168/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager3440"), + // Location: to.Ptr("global"), + // Tags: map[string]*string{ + // }, + // Properties: &armtrafficmanager.ProfileProperties{ + // DNSConfig: &armtrafficmanager.DNSConfig{ + // Fqdn: to.Ptr("azuresdkfornetautoresttrafficmanager3440.tmpreview.watmtest.azure-test.net"), + // RelativeName: to.Ptr("azuresdkfornetautoresttrafficmanager3440"), + // TTL: to.Ptr[int64](35), + // }, + // Endpoints: []*armtrafficmanager.Endpoint{ + // { + // Name: to.Ptr("My external endpoint"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager5168/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager3440/externalEndpoints/My external endpoint"), + // Properties: &armtrafficmanager.EndpointProperties{ + // EndpointLocation: to.Ptr("North Europe"), + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusOnline), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("foobar.contoso.com"), + // Weight: to.Ptr[int64](1), + // }, + // }}, + // MonitorConfig: &armtrafficmanager.MonitorConfig{ + // Path: to.Ptr("/testpath.aspx"), + // IntervalInSeconds: to.Ptr[int64](30), + // Port: to.Ptr[int64](80), + // ProfileMonitorStatus: to.Ptr(armtrafficmanager.ProfileMonitorStatusOnline), + // TimeoutInSeconds: to.Ptr[int64](10), + // ToleratedNumberOfFailures: to.Ptr[int64](3), + // Protocol: to.Ptr(armtrafficmanager.MonitorProtocolHTTP), + // }, + // ProfileStatus: to.Ptr(armtrafficmanager.ProfileStatusEnabled), + // TrafficRoutingMethod: to.Ptr(armtrafficmanager.TrafficRoutingMethodPerformance), + // }, + // }, + // { + // Name: to.Ptr("onesdk8819"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/onesdk9785/providers/Microsoft.Network/trafficManagerProfiles/onesdk8819"), + // Location: to.Ptr("global"), + // Tags: map[string]*string{ + // }, + // Properties: &armtrafficmanager.ProfileProperties{ + // DNSConfig: &armtrafficmanager.DNSConfig{ + // Fqdn: to.Ptr("onesdk7242.tmpreview.watmtest.azure-test.net"), + // RelativeName: to.Ptr("onesdk7242"), + // TTL: to.Ptr[int64](51), + // }, + // Endpoints: []*armtrafficmanager.Endpoint{ + // { + // Name: to.Ptr("MyNestedEndpoint"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/nestedEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/onesdk9785/providers/Microsoft.Network/trafficManagerProfiles/onesdk8819/nestedEndpoints/MyNestedEndpoint"), + // Properties: &armtrafficmanager.EndpointProperties{ + // EndpointLocation: to.Ptr("West Europe"), + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusStopped), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // MinChildEndpoints: to.Ptr[int64](1), + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("onesdk4285.tmpreview.watmtest.azure-test.net"), + // TargetResourceID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/onesdk9785/providers/Microsoft.Network/trafficManagerProfiles/onesdk1792"), + // Weight: to.Ptr[int64](1), + // }, + // }}, + // MonitorConfig: &armtrafficmanager.MonitorConfig{ + // Path: to.Ptr("/testparent.asp"), + // IntervalInSeconds: to.Ptr[int64](30), + // Port: to.Ptr[int64](111), + // ProfileMonitorStatus: to.Ptr(armtrafficmanager.ProfileMonitorStatusOnline), + // TimeoutInSeconds: to.Ptr[int64](10), + // ToleratedNumberOfFailures: to.Ptr[int64](3), + // Protocol: to.Ptr(armtrafficmanager.MonitorProtocolHTTPS), + // }, + // ProfileStatus: to.Ptr(armtrafficmanager.ProfileStatusEnabled), + // TrafficRoutingMethod: to.Ptr(armtrafficmanager.TrafficRoutingMethodPerformance), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-GET-WithEndpoints.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-GET-WithEndpoints.json func ExampleProfilesClient_Get_profileGetWithEndpoints() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewProfilesClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "azuresdkfornetautoresttrafficmanager1323", "azuresdkfornetautoresttrafficmanager3880", nil) + res, err := clientFactory.NewProfilesClient().Get(ctx, "azuresdkfornetautoresttrafficmanager1323", "azuresdkfornetautoresttrafficmanager3880", 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.Profile = armtrafficmanager.Profile{ + // Name: to.Ptr("azuresdkfornetautoresttrafficmanager3880"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1323/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager3880"), + // Location: to.Ptr("global"), + // Tags: map[string]*string{ + // }, + // Properties: &armtrafficmanager.ProfileProperties{ + // DNSConfig: &armtrafficmanager.DNSConfig{ + // Fqdn: to.Ptr("azuresdkfornetautoresttrafficmanager3880.tmpreview.watmtest.azure-test.net"), + // RelativeName: to.Ptr("azuresdkfornetautoresttrafficmanager3880"), + // TTL: to.Ptr[int64](35), + // }, + // Endpoints: []*armtrafficmanager.Endpoint{ + // { + // Name: to.Ptr("My external endpoint"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1323/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager3880/externalEndpoints/My external endpoint"), + // Properties: &armtrafficmanager.EndpointProperties{ + // EndpointLocation: to.Ptr("North Europe"), + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusCheckingEndpoint), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("foobar.contoso.com"), + // Weight: to.Ptr[int64](1), + // }, + // }}, + // MonitorConfig: &armtrafficmanager.MonitorConfig{ + // Path: to.Ptr("/testpath.aspx"), + // IntervalInSeconds: to.Ptr[int64](30), + // Port: to.Ptr[int64](80), + // ProfileMonitorStatus: to.Ptr(armtrafficmanager.ProfileMonitorStatusCheckingEndpoints), + // TimeoutInSeconds: to.Ptr[int64](10), + // ToleratedNumberOfFailures: to.Ptr[int64](3), + // Protocol: to.Ptr(armtrafficmanager.MonitorProtocolHTTP), + // }, + // ProfileStatus: to.Ptr(armtrafficmanager.ProfileStatusEnabled), + // TrafficRoutingMethod: to.Ptr(armtrafficmanager.TrafficRoutingMethodPerformance), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-GET-WithTrafficViewDisabled.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-GET-WithTrafficViewDisabled.json func ExampleProfilesClient_Get_profileGetWithTrafficViewDisabled() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewProfilesClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "azuresdkfornetautoresttrafficmanager1323", "azuresdkfornetautoresttrafficmanager3880", nil) + res, err := clientFactory.NewProfilesClient().Get(ctx, "azuresdkfornetautoresttrafficmanager1323", "azuresdkfornetautoresttrafficmanager3880", 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.Profile = armtrafficmanager.Profile{ + // Name: to.Ptr("azuresdkfornetautoresttrafficmanager3880"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1323/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager3880"), + // Location: to.Ptr("global"), + // Tags: map[string]*string{ + // }, + // Properties: &armtrafficmanager.ProfileProperties{ + // DNSConfig: &armtrafficmanager.DNSConfig{ + // Fqdn: to.Ptr("azuresdkfornetautoresttrafficmanager3880.tmpreview.watmtest.azure-test.net"), + // RelativeName: to.Ptr("azuresdkfornetautoresttrafficmanager3880"), + // TTL: to.Ptr[int64](35), + // }, + // Endpoints: []*armtrafficmanager.Endpoint{ + // { + // Name: to.Ptr("My external endpoint"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1323/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager3880/externalEndpoints/My external endpoint"), + // Properties: &armtrafficmanager.EndpointProperties{ + // EndpointLocation: to.Ptr("North Europe"), + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusCheckingEndpoint), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("foobar.contoso.com"), + // Weight: to.Ptr[int64](1), + // }, + // }}, + // MonitorConfig: &armtrafficmanager.MonitorConfig{ + // Path: to.Ptr("/testpath.aspx"), + // IntervalInSeconds: to.Ptr[int64](30), + // Port: to.Ptr[int64](80), + // ProfileMonitorStatus: to.Ptr(armtrafficmanager.ProfileMonitorStatusCheckingEndpoints), + // TimeoutInSeconds: to.Ptr[int64](10), + // ToleratedNumberOfFailures: to.Ptr[int64](3), + // Protocol: to.Ptr(armtrafficmanager.MonitorProtocolHTTP), + // }, + // ProfileStatus: to.Ptr(armtrafficmanager.ProfileStatusEnabled), + // TrafficRoutingMethod: to.Ptr(armtrafficmanager.TrafficRoutingMethodPerformance), + // TrafficViewEnrollmentStatus: to.Ptr(armtrafficmanager.TrafficViewEnrollmentStatusDisabled), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-GET-WithTrafficViewEnabled.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-GET-WithTrafficViewEnabled.json func ExampleProfilesClient_Get_profileGetWithTrafficViewEnabled() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewProfilesClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "azuresdkfornetautoresttrafficmanager1323", "azuresdkfornetautoresttrafficmanager3880", nil) + res, err := clientFactory.NewProfilesClient().Get(ctx, "azuresdkfornetautoresttrafficmanager1323", "azuresdkfornetautoresttrafficmanager3880", 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.Profile = armtrafficmanager.Profile{ + // Name: to.Ptr("azuresdkfornetautoresttrafficmanager3880"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1323/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager3880"), + // Location: to.Ptr("global"), + // Tags: map[string]*string{ + // }, + // Properties: &armtrafficmanager.ProfileProperties{ + // DNSConfig: &armtrafficmanager.DNSConfig{ + // Fqdn: to.Ptr("azuresdkfornetautoresttrafficmanager3880.tmpreview.watmtest.azure-test.net"), + // RelativeName: to.Ptr("azuresdkfornetautoresttrafficmanager3880"), + // TTL: to.Ptr[int64](35), + // }, + // Endpoints: []*armtrafficmanager.Endpoint{ + // { + // Name: to.Ptr("My external endpoint"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1323/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager3880/externalEndpoints/My external endpoint"), + // Properties: &armtrafficmanager.EndpointProperties{ + // EndpointLocation: to.Ptr("North Europe"), + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusCheckingEndpoint), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("foobar.contoso.com"), + // Weight: to.Ptr[int64](1), + // }, + // }}, + // MonitorConfig: &armtrafficmanager.MonitorConfig{ + // Path: to.Ptr("/testpath.aspx"), + // IntervalInSeconds: to.Ptr[int64](30), + // Port: to.Ptr[int64](80), + // ProfileMonitorStatus: to.Ptr(armtrafficmanager.ProfileMonitorStatusCheckingEndpoints), + // TimeoutInSeconds: to.Ptr[int64](10), + // ToleratedNumberOfFailures: to.Ptr[int64](3), + // Protocol: to.Ptr(armtrafficmanager.MonitorProtocolHTTP), + // }, + // ProfileStatus: to.Ptr(armtrafficmanager.ProfileStatusEnabled), + // TrafficRoutingMethod: to.Ptr(armtrafficmanager.TrafficRoutingMethodPerformance), + // TrafficViewEnrollmentStatus: to.Ptr(armtrafficmanager.TrafficViewEnrollmentStatusEnabled), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-PUT-MultiValue.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-PUT-MultiValue.json func ExampleProfilesClient_CreateOrUpdate_profilePutMultiValue() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewProfilesClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager1421", "azsmnet6386", armtrafficmanager.Profile{ + res, err := clientFactory.NewProfilesClient().CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager1421", "azsmnet6386", armtrafficmanager.Profile{ Location: to.Ptr("global"), Properties: &armtrafficmanager.ProfileProperties{ DNSConfig: &armtrafficmanager.DNSConfig{ @@ -198,22 +536,51 @@ func ExampleProfilesClient_CreateOrUpdate_profilePutMultiValue() { 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.Profile = armtrafficmanager.Profile{ + // Name: to.Ptr("azsmnet6386"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1421/providers/Microsoft.Network/trafficManagerProfiles/azsmnet6386"), + // Location: to.Ptr("global"), + // Properties: &armtrafficmanager.ProfileProperties{ + // DNSConfig: &armtrafficmanager.DNSConfig{ + // Fqdn: to.Ptr("azsmnet6386.tmpreview.watmtest.azure-test.net"), + // RelativeName: to.Ptr("azsmnet6386"), + // TTL: to.Ptr[int64](35), + // }, + // Endpoints: []*armtrafficmanager.Endpoint{ + // }, + // MaxReturn: to.Ptr[int64](2), + // MonitorConfig: &armtrafficmanager.MonitorConfig{ + // Path: to.Ptr("/testpath.aspx"), + // IntervalInSeconds: to.Ptr[int64](30), + // Port: to.Ptr[int64](80), + // ProfileMonitorStatus: to.Ptr(armtrafficmanager.ProfileMonitorStatusInactive), + // TimeoutInSeconds: to.Ptr[int64](10), + // ToleratedNumberOfFailures: to.Ptr[int64](3), + // Protocol: to.Ptr(armtrafficmanager.MonitorProtocolHTTP), + // }, + // ProfileStatus: to.Ptr(armtrafficmanager.ProfileStatusEnabled), + // TrafficRoutingMethod: to.Ptr(armtrafficmanager.TrafficRoutingMethodMultiValue), + // TrafficViewEnrollmentStatus: to.Ptr(armtrafficmanager.TrafficViewEnrollmentStatusDisabled), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-PUT-NoEndpoints.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-PUT-NoEndpoints.json func ExampleProfilesClient_CreateOrUpdate_profilePutNoEndpoints() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewProfilesClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager1421", "azsmnet6386", armtrafficmanager.Profile{ + res, err := clientFactory.NewProfilesClient().CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager1421", "azsmnet6386", armtrafficmanager.Profile{ Location: to.Ptr("global"), Properties: &armtrafficmanager.ProfileProperties{ DNSConfig: &armtrafficmanager.DNSConfig{ @@ -232,22 +599,49 @@ func ExampleProfilesClient_CreateOrUpdate_profilePutNoEndpoints() { 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.Profile = armtrafficmanager.Profile{ + // Name: to.Ptr("azsmnet6386"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1421/providers/Microsoft.Network/trafficManagerProfiles/azsmnet6386"), + // Location: to.Ptr("global"), + // Properties: &armtrafficmanager.ProfileProperties{ + // DNSConfig: &armtrafficmanager.DNSConfig{ + // Fqdn: to.Ptr("azsmnet6386.tmpreview.watmtest.azure-test.net"), + // RelativeName: to.Ptr("azsmnet6386"), + // TTL: to.Ptr[int64](35), + // }, + // Endpoints: []*armtrafficmanager.Endpoint{ + // }, + // MonitorConfig: &armtrafficmanager.MonitorConfig{ + // Path: to.Ptr("/testpath.aspx"), + // IntervalInSeconds: to.Ptr[int64](30), + // Port: to.Ptr[int64](80), + // ProfileMonitorStatus: to.Ptr(armtrafficmanager.ProfileMonitorStatusInactive), + // TimeoutInSeconds: to.Ptr[int64](10), + // ToleratedNumberOfFailures: to.Ptr[int64](3), + // Protocol: to.Ptr(armtrafficmanager.MonitorProtocolHTTP), + // }, + // ProfileStatus: to.Ptr(armtrafficmanager.ProfileStatusEnabled), + // TrafficRoutingMethod: to.Ptr(armtrafficmanager.TrafficRoutingMethodPerformance), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-PUT-WithAliasing.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-PUT-WithAliasing.json func ExampleProfilesClient_CreateOrUpdate_profilePutWithAliasing() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewProfilesClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager2583", "azuresdkfornetautoresttrafficmanager6192", armtrafficmanager.Profile{ + res, err := clientFactory.NewProfilesClient().CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager2583", "azuresdkfornetautoresttrafficmanager6192", armtrafficmanager.Profile{ Location: to.Ptr("global"), Properties: &armtrafficmanager.ProfileProperties{ AllowedEndpointRecordTypes: []*armtrafficmanager.AllowedEndpointRecordType{ @@ -281,22 +675,77 @@ func ExampleProfilesClient_CreateOrUpdate_profilePutWithAliasing() { 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.Profile = armtrafficmanager.Profile{ + // Name: to.Ptr("azuresdkfornetautoresttrafficmanager6192"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager2583/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager6192"), + // Location: to.Ptr("global"), + // Properties: &armtrafficmanager.ProfileProperties{ + // AllowedEndpointRecordTypes: []*armtrafficmanager.AllowedEndpointRecordType{ + // to.Ptr(armtrafficmanager.AllowedEndpointRecordTypeDomainName)}, + // DNSConfig: &armtrafficmanager.DNSConfig{ + // Fqdn: to.Ptr("azuresdkfornetautoresttrafficmanager6192.tmpreview.watmtest.azure-test.net"), + // RelativeName: to.Ptr("azuresdkfornetautoresttrafficmanager6192"), + // TTL: to.Ptr[int64](35), + // }, + // Endpoints: []*armtrafficmanager.Endpoint{ + // { + // Name: to.Ptr("My external endpoint"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager2583/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager6192/externalEndpoints/My external endpoint"), + // Properties: &armtrafficmanager.EndpointProperties{ + // CustomHeaders: []*armtrafficmanager.EndpointPropertiesCustomHeadersItem{ + // { + // Name: to.Ptr("header-2"), + // Value: to.Ptr("value-2-overridden"), + // }}, + // EndpointLocation: to.Ptr("North Europe"), + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusCheckingEndpoint), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("foobar.contoso.com"), + // Weight: to.Ptr[int64](1), + // }, + // }}, + // MonitorConfig: &armtrafficmanager.MonitorConfig{ + // Path: to.Ptr("/testpath.aspx"), + // CustomHeaders: []*armtrafficmanager.MonitorConfigCustomHeadersItem{ + // { + // Name: to.Ptr("header-1"), + // Value: to.Ptr("value-1"), + // }, + // { + // Name: to.Ptr("header-2"), + // Value: to.Ptr("value-2"), + // }}, + // IntervalInSeconds: to.Ptr[int64](10), + // Port: to.Ptr[int64](80), + // ProfileMonitorStatus: to.Ptr(armtrafficmanager.ProfileMonitorStatusCheckingEndpoints), + // TimeoutInSeconds: to.Ptr[int64](5), + // ToleratedNumberOfFailures: to.Ptr[int64](2), + // Protocol: to.Ptr(armtrafficmanager.MonitorProtocolHTTP), + // }, + // ProfileStatus: to.Ptr(armtrafficmanager.ProfileStatusEnabled), + // TrafficRoutingMethod: to.Ptr(armtrafficmanager.TrafficRoutingMethodPerformance), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-PUT-WithCustomHeaders.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-PUT-WithCustomHeaders.json func ExampleProfilesClient_CreateOrUpdate_profilePutWithCustomHeaders() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewProfilesClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager2583", "azuresdkfornetautoresttrafficmanager6192", armtrafficmanager.Profile{ + res, err := clientFactory.NewProfilesClient().CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager2583", "azuresdkfornetautoresttrafficmanager6192", armtrafficmanager.Profile{ Location: to.Ptr("global"), Properties: &armtrafficmanager.ProfileProperties{ DNSConfig: &armtrafficmanager.DNSConfig{ @@ -352,22 +801,76 @@ func ExampleProfilesClient_CreateOrUpdate_profilePutWithCustomHeaders() { 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.Profile = armtrafficmanager.Profile{ + // Name: to.Ptr("azuresdkfornetautoresttrafficmanager6192"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager2583/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager6192"), + // Location: to.Ptr("global"), + // Properties: &armtrafficmanager.ProfileProperties{ + // DNSConfig: &armtrafficmanager.DNSConfig{ + // Fqdn: to.Ptr("azuresdkfornetautoresttrafficmanager6192.tmpreview.watmtest.azure-test.net"), + // RelativeName: to.Ptr("azuresdkfornetautoresttrafficmanager6192"), + // TTL: to.Ptr[int64](35), + // }, + // Endpoints: []*armtrafficmanager.Endpoint{ + // { + // Name: to.Ptr("My external endpoint"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager2583/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager6192/externalEndpoints/My external endpoint"), + // Properties: &armtrafficmanager.EndpointProperties{ + // CustomHeaders: []*armtrafficmanager.EndpointPropertiesCustomHeadersItem{ + // { + // Name: to.Ptr("header-2"), + // Value: to.Ptr("value-2-overridden"), + // }}, + // EndpointLocation: to.Ptr("North Europe"), + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusCheckingEndpoint), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("foobar.contoso.com"), + // Weight: to.Ptr[int64](1), + // }, + // }}, + // MonitorConfig: &armtrafficmanager.MonitorConfig{ + // Path: to.Ptr("/testpath.aspx"), + // CustomHeaders: []*armtrafficmanager.MonitorConfigCustomHeadersItem{ + // { + // Name: to.Ptr("header-1"), + // Value: to.Ptr("value-1"), + // }, + // { + // Name: to.Ptr("header-2"), + // Value: to.Ptr("value-2"), + // }}, + // IntervalInSeconds: to.Ptr[int64](10), + // Port: to.Ptr[int64](80), + // ProfileMonitorStatus: to.Ptr(armtrafficmanager.ProfileMonitorStatusCheckingEndpoints), + // TimeoutInSeconds: to.Ptr[int64](5), + // ToleratedNumberOfFailures: to.Ptr[int64](2), + // Protocol: to.Ptr(armtrafficmanager.MonitorProtocolHTTP), + // }, + // ProfileStatus: to.Ptr(armtrafficmanager.ProfileStatusEnabled), + // TrafficRoutingMethod: to.Ptr(armtrafficmanager.TrafficRoutingMethodPerformance), + // TrafficViewEnrollmentStatus: to.Ptr(armtrafficmanager.TrafficViewEnrollmentStatusDisabled), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-PUT-WithEndpoints.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-PUT-WithEndpoints.json func ExampleProfilesClient_CreateOrUpdate_profilePutWithEndpoints() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewProfilesClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager2583", "azuresdkfornetautoresttrafficmanager6192", armtrafficmanager.Profile{ + res, err := clientFactory.NewProfilesClient().CreateOrUpdate(ctx, "azuresdkfornetautoresttrafficmanager2583", "azuresdkfornetautoresttrafficmanager6192", armtrafficmanager.Profile{ Location: to.Ptr("global"), Properties: &armtrafficmanager.ProfileProperties{ DNSConfig: &armtrafficmanager.DNSConfig{ @@ -399,22 +902,61 @@ func ExampleProfilesClient_CreateOrUpdate_profilePutWithEndpoints() { 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.Profile = armtrafficmanager.Profile{ + // Name: to.Ptr("azuresdkfornetautoresttrafficmanager6192"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager2583/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager6192"), + // Location: to.Ptr("global"), + // Properties: &armtrafficmanager.ProfileProperties{ + // DNSConfig: &armtrafficmanager.DNSConfig{ + // Fqdn: to.Ptr("azuresdkfornetautoresttrafficmanager6192.tmpreview.watmtest.azure-test.net"), + // RelativeName: to.Ptr("azuresdkfornetautoresttrafficmanager6192"), + // TTL: to.Ptr[int64](35), + // }, + // Endpoints: []*armtrafficmanager.Endpoint{ + // { + // Name: to.Ptr("My external endpoint"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager2583/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager6192/externalEndpoints/My external endpoint"), + // Properties: &armtrafficmanager.EndpointProperties{ + // EndpointLocation: to.Ptr("North Europe"), + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusCheckingEndpoint), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("foobar.contoso.com"), + // Weight: to.Ptr[int64](1), + // }, + // }}, + // MonitorConfig: &armtrafficmanager.MonitorConfig{ + // Path: to.Ptr("/testpath.aspx"), + // IntervalInSeconds: to.Ptr[int64](10), + // Port: to.Ptr[int64](80), + // ProfileMonitorStatus: to.Ptr(armtrafficmanager.ProfileMonitorStatusCheckingEndpoints), + // TimeoutInSeconds: to.Ptr[int64](5), + // ToleratedNumberOfFailures: to.Ptr[int64](2), + // Protocol: to.Ptr(armtrafficmanager.MonitorProtocolHTTP), + // }, + // ProfileStatus: to.Ptr(armtrafficmanager.ProfileStatusEnabled), + // TrafficRoutingMethod: to.Ptr(armtrafficmanager.TrafficRoutingMethodPerformance), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-PUT-WithNestedEndpoints.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-PUT-WithNestedEndpoints.json func ExampleProfilesClient_CreateOrUpdate_profilePutWithNestedEndpoints() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewProfilesClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "myresourcegroup", "parentprofile", armtrafficmanager.Profile{ + res, err := clientFactory.NewProfilesClient().CreateOrUpdate(ctx, "myresourcegroup", "parentprofile", armtrafficmanager.Profile{ Location: to.Ptr("global"), Properties: &armtrafficmanager.ProfileProperties{ DNSConfig: &armtrafficmanager.DNSConfig{ @@ -463,41 +1005,100 @@ func ExampleProfilesClient_CreateOrUpdate_profilePutWithNestedEndpoints() { 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.Profile = armtrafficmanager.Profile{ + // Name: to.Ptr("parentprofile"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myresourcegroup/providers/Microsoft.Network/trafficManagerProfiles/parentprofile"), + // Location: to.Ptr("global"), + // Properties: &armtrafficmanager.ProfileProperties{ + // DNSConfig: &armtrafficmanager.DNSConfig{ + // Fqdn: to.Ptr("parentprofile.tmpreview.watmtest.azure-test.net"), + // RelativeName: to.Ptr("parentprofile"), + // TTL: to.Ptr[int64](35), + // }, + // Endpoints: []*armtrafficmanager.Endpoint{ + // { + // Name: to.Ptr("MyFirstNestedEndpoint"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/nestedEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myresourcegroup/providers/Microsoft.Network/trafficManagerProfiles/parentprofile/nestedEndpoints/MyFirstNestedEndpoint"), + // Properties: &armtrafficmanager.EndpointProperties{ + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusCheckingEndpoint), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // MinChildEndpoints: to.Ptr[int64](2), + // MinChildEndpointsIPv4: to.Ptr[int64](1), + // MinChildEndpointsIPv6: to.Ptr[int64](2), + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("firstnestedprofile.tmpreview.watmtest.azure-test.net"), + // Weight: to.Ptr[int64](1), + // }, + // }, + // { + // Name: to.Ptr("MySecondNestedEndpoint"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/nestedEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myresourcegroup/providers/Microsoft.Network/trafficManagerProfiles/parentprofile/nestedEndpoints/MySecondNestedEndpoint"), + // Properties: &armtrafficmanager.EndpointProperties{ + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusCheckingEndpoint), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // MinChildEndpoints: to.Ptr[int64](2), + // MinChildEndpointsIPv4: to.Ptr[int64](2), + // MinChildEndpointsIPv6: to.Ptr[int64](1), + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("secondnestedprofile.tmpreview.watmtest.azure-test.net"), + // Weight: to.Ptr[int64](1), + // }, + // }}, + // MonitorConfig: &armtrafficmanager.MonitorConfig{ + // Path: to.Ptr("/testpath.aspx"), + // IntervalInSeconds: to.Ptr[int64](10), + // Port: to.Ptr[int64](80), + // ProfileMonitorStatus: to.Ptr(armtrafficmanager.ProfileMonitorStatusCheckingEndpoints), + // TimeoutInSeconds: to.Ptr[int64](5), + // ToleratedNumberOfFailures: to.Ptr[int64](2), + // Protocol: to.Ptr(armtrafficmanager.MonitorProtocolHTTP), + // }, + // ProfileStatus: to.Ptr(armtrafficmanager.ProfileStatusEnabled), + // TrafficRoutingMethod: to.Ptr(armtrafficmanager.TrafficRoutingMethodPriority), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-DELETE.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-DELETE.json func ExampleProfilesClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewProfilesClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Delete(ctx, "azuresdkfornetautoresttrafficmanager1323", "azuresdkfornetautoresttrafficmanager3880", nil) + res, err := clientFactory.NewProfilesClient().Delete(ctx, "azuresdkfornetautoresttrafficmanager1323", "azuresdkfornetautoresttrafficmanager3880", 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.DeleteOperationResult = armtrafficmanager.DeleteOperationResult{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-PATCH-MonitorConfig.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/Profile-PATCH-MonitorConfig.json func ExampleProfilesClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewProfilesClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "azuresdkfornetautoresttrafficmanager2583", "azuresdkfornetautoresttrafficmanager6192", armtrafficmanager.Profile{ + res, err := clientFactory.NewProfilesClient().Update(ctx, "azuresdkfornetautoresttrafficmanager2583", "azuresdkfornetautoresttrafficmanager6192", armtrafficmanager.Profile{ Properties: &armtrafficmanager.ProfileProperties{ MonitorConfig: &armtrafficmanager.MonitorConfig{ Path: to.Ptr("/testpath.aspx"), @@ -521,6 +1122,56 @@ func ExampleProfilesClient_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.Profile = armtrafficmanager.Profile{ + // Name: to.Ptr("azuresdkfornetautoresttrafficmanager6192"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager2583/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager6192"), + // Location: to.Ptr("global"), + // Tags: map[string]*string{ + // }, + // Properties: &armtrafficmanager.ProfileProperties{ + // DNSConfig: &armtrafficmanager.DNSConfig{ + // Fqdn: to.Ptr("azuresdkfornetautoresttrafficmanager6192.tmpreview.watmtest.azure-test.net"), + // RelativeName: to.Ptr("azuresdkfornetautoresttrafficmanager6192"), + // TTL: to.Ptr[int64](35), + // }, + // Endpoints: []*armtrafficmanager.Endpoint{ + // { + // Name: to.Ptr("My external endpoint"), + // Type: to.Ptr("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager2583/providers/Microsoft.Network/trafficManagerProfiles/azuresdkfornetautoresttrafficmanager6192/externalEndpoints/My external endpoint"), + // Properties: &armtrafficmanager.EndpointProperties{ + // EndpointLocation: to.Ptr("North Europe"), + // EndpointMonitorStatus: to.Ptr(armtrafficmanager.EndpointMonitorStatusCheckingEndpoint), + // EndpointStatus: to.Ptr(armtrafficmanager.EndpointStatusEnabled), + // Priority: to.Ptr[int64](1), + // Target: to.Ptr("foobar.contoso.com"), + // Weight: to.Ptr[int64](1), + // }, + // }}, + // MonitorConfig: &armtrafficmanager.MonitorConfig{ + // Path: to.Ptr("/testpath.aspx"), + // CustomHeaders: []*armtrafficmanager.MonitorConfigCustomHeadersItem{ + // { + // Name: to.Ptr("header-1"), + // Value: to.Ptr("value-1"), + // }, + // { + // Name: to.Ptr("header-2"), + // Value: to.Ptr("value-2"), + // }}, + // IntervalInSeconds: to.Ptr[int64](30), + // Port: to.Ptr[int64](80), + // ProfileMonitorStatus: to.Ptr(armtrafficmanager.ProfileMonitorStatusCheckingEndpoints), + // TimeoutInSeconds: to.Ptr[int64](6), + // ToleratedNumberOfFailures: to.Ptr[int64](4), + // Protocol: to.Ptr(armtrafficmanager.MonitorProtocolHTTP), + // }, + // ProfileStatus: to.Ptr(armtrafficmanager.ProfileStatusEnabled), + // TrafficRoutingMethod: to.Ptr(armtrafficmanager.TrafficRoutingMethodPerformance), + // }, + // } } diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/response_types.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/response_types.go index 068f5d4d10a6..aa5160fabb1f 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/response_types.go +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/response_types.go @@ -59,12 +59,12 @@ type ProfilesClientGetResponse struct { Profile } -// ProfilesClientListByResourceGroupResponse contains the response from method ProfilesClient.ListByResourceGroup. +// ProfilesClientListByResourceGroupResponse contains the response from method ProfilesClient.NewListByResourceGroupPager. type ProfilesClientListByResourceGroupResponse struct { ProfileListResult } -// ProfilesClientListBySubscriptionResponse contains the response from method ProfilesClient.ListBySubscription. +// ProfilesClientListBySubscriptionResponse contains the response from method ProfilesClient.NewListBySubscriptionPager. type ProfilesClientListBySubscriptionResponse struct { ProfileListResult } diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/time_rfc3339.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/time_rfc3339.go index 8b294f086263..ba38cac44569 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/time_rfc3339.go +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/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/trafficmanager/armtrafficmanager/usermetricskeys_client.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/usermetricskeys_client.go index f84537d959b2..c411daf00eb4 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/usermetricskeys_client.go +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/usermetricskeys_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 ( // UserMetricsKeysClient contains the methods for the TrafficManagerUserMetricsKeys group. // Don't use this type directly, use NewUserMetricsKeysClient() instead. type UserMetricsKeysClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewUserMetricsKeysClient creates a new instance of UserMetricsKeysClient 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 NewUserMetricsKeysClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*UserMetricsKeysClient, 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+".UserMetricsKeysClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &UserMetricsKeysClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or update a subscription-level key used for Real User Metrics collection. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-04-01-preview -// options - UserMetricsKeysClientCreateOrUpdateOptions contains the optional parameters for the UserMetricsKeysClient.CreateOrUpdate -// method. +// - options - UserMetricsKeysClientCreateOrUpdateOptions contains the optional parameters for the UserMetricsKeysClient.CreateOrUpdate +// method. func (client *UserMetricsKeysClient) CreateOrUpdate(ctx context.Context, options *UserMetricsKeysClientCreateOrUpdateOptions) (UserMetricsKeysClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, options) if err != nil { return UserMetricsKeysClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return UserMetricsKeysClientCreateOrUpdateResponse{}, err } @@ -82,7 +72,7 @@ func (client *UserMetricsKeysClient) createOrUpdateCreateRequest(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.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 } @@ -104,14 +94,15 @@ func (client *UserMetricsKeysClient) createOrUpdateHandleResponse(resp *http.Res // Delete - Delete a subscription-level key used for Real User Metrics collection. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-04-01-preview -// options - UserMetricsKeysClientDeleteOptions contains the optional parameters for the UserMetricsKeysClient.Delete method. +// - options - UserMetricsKeysClientDeleteOptions contains the optional parameters for the UserMetricsKeysClient.Delete method. func (client *UserMetricsKeysClient) Delete(ctx context.Context, options *UserMetricsKeysClientDeleteOptions) (UserMetricsKeysClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, options) if err != nil { return UserMetricsKeysClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return UserMetricsKeysClientDeleteResponse{}, err } @@ -128,7 +119,7 @@ func (client *UserMetricsKeysClient) deleteCreateRequest(ctx context.Context, op 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 } @@ -150,14 +141,15 @@ func (client *UserMetricsKeysClient) deleteHandleResponse(resp *http.Response) ( // Get - Get the subscription-level key used for Real User Metrics collection. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-04-01-preview -// options - UserMetricsKeysClientGetOptions contains the optional parameters for the UserMetricsKeysClient.Get method. +// - options - UserMetricsKeysClientGetOptions contains the optional parameters for the UserMetricsKeysClient.Get method. func (client *UserMetricsKeysClient) Get(ctx context.Context, options *UserMetricsKeysClientGetOptions) (UserMetricsKeysClientGetResponse, error) { req, err := client.getCreateRequest(ctx, options) if err != nil { return UserMetricsKeysClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return UserMetricsKeysClientGetResponse{}, err } @@ -174,7 +166,7 @@ func (client *UserMetricsKeysClient) getCreateRequest(ctx context.Context, optio return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/trafficmanager/armtrafficmanager/usermetricskeys_client_example_test.go b/sdk/resourcemanager/trafficmanager/armtrafficmanager/usermetricskeys_client_example_test.go index c404baddb8c1..9623158063b4 100644 --- a/sdk/resourcemanager/trafficmanager/armtrafficmanager/usermetricskeys_client_example_test.go +++ b/sdk/resourcemanager/trafficmanager/armtrafficmanager/usermetricskeys_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 armtrafficmanager_test @@ -16,57 +17,69 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/trafficmanager/armtrafficmanager" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/TrafficManagerUserMetricsKeys-GET.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/TrafficManagerUserMetricsKeys-GET.json func ExampleUserMetricsKeysClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewUserMetricsKeysClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, nil) + res, err := clientFactory.NewUserMetricsKeysClient().Get(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.UserMetricsModel = armtrafficmanager.UserMetricsModel{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Network/trafficManagerUserMetricsKeys"), + // ID: to.Ptr("/providers/Microsoft.Network/trafficManagerUserMetricsKeys/default"), + // Properties: &armtrafficmanager.UserMetricsProperties{ + // Key: to.Ptr("9ea056eb38f145a0891b5d5dc15e9aa2"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/TrafficManagerUserMetricsKeys-PUT.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/TrafficManagerUserMetricsKeys-PUT.json func ExampleUserMetricsKeysClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewUserMetricsKeysClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.CreateOrUpdate(ctx, nil) + _, err = clientFactory.NewUserMetricsKeysClient().CreateOrUpdate(ctx, 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/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/TrafficManagerUserMetricsKeys-DELETE.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/abd5d0016f12f6862cae88ef70f1333e84e20c07/specification/trafficmanager/resource-manager/Microsoft.Network/preview/2022-04-01-preview/examples/TrafficManagerUserMetricsKeys-DELETE.json func ExampleUserMetricsKeysClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armtrafficmanager.NewUserMetricsKeysClient("{subscription-id}", cred, nil) + clientFactory, err := armtrafficmanager.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Delete(ctx, nil) + res, err := clientFactory.NewUserMetricsKeysClient().Delete(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.DeleteOperationResult = armtrafficmanager.DeleteOperationResult{ + // } } diff --git a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/CHANGELOG.md b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/CHANGELOG.md index 4e36fafc5d8e..9489ebe10b7c 100644 --- a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/CHANGELOG.md +++ b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.2.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.1.0 (2022-05-30) ### Features Added diff --git a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/README.md b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/README.md index 353ed816d250..b6dc7c126f6d 100644 --- a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/README.md +++ b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/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 Virtual Machine Image Builder 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 Virtual Machine Image Builder 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 := armvirtualmachineimagebuilder.NewVirtualMachineImageTemplatesClient(, cred, nil) +clientFactory, err := armvirtualmachineimagebuilder.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 := armvirtualmachineimagebuilder.NewVirtualMachineImageTemplatesClient(, cred, &options) +clientFactory, err := armvirtualmachineimagebuilder.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.NewVirtualMachineImageTemplatesClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/autorest.md b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/autorest.md index 9ce2b567696d..edf88c695219 100644 --- a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/autorest.md +++ b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/078b90617e5e08137d0395963bd4119f4561a910/specification/imagebuilder/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/078b90617e5e08137d0395963bd4119f4561a910/specification/imagebuilder/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.1.0 +module-version: 1.2.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/client_factory.go b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/client_factory.go new file mode 100644 index 000000000000..83342f180c04 --- /dev/null +++ b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/client_factory.go @@ -0,0 +1,50 @@ +//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 armvirtualmachineimagebuilder + +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 - Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription Id forms +// part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewVirtualMachineImageTemplatesClient() *VirtualMachineImageTemplatesClient { + subClient, _ := NewVirtualMachineImageTemplatesClient(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/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_constants.go b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/constants.go similarity index 99% rename from sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_constants.go rename to sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/constants.go index 9af704cc8432..25f3a187b654 100644 --- a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_constants.go +++ b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/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 armvirtualmachineimagebuilder const ( moduleName = "armvirtualmachineimagebuilder" - moduleVersion = "v1.1.0" + moduleVersion = "v1.2.0" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/go.mod b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/go.mod index e69512498ae1..fcf7c8dd3918 100644 --- a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/go.mod +++ b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/virtualmachineimage 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/virtualmachineimagebuilder/armvirtualmachineimagebuilder/go.sum b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/go.sum +++ b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/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/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_models.go b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/models.go similarity index 97% rename from sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_models.go rename to sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/models.go index b25518ca261f..7881e17504c6 100644 --- a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_models.go +++ b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/models.go @@ -5,32 +5,12 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armvirtualmachineimagebuilder import "time" -// CloudError - An error response from the Azure VM Image Builder service. -type CloudError struct { - // Details about the error. - Error *CloudErrorBody `json:"error,omitempty"` -} - -// CloudErrorBody - An error response from the Azure VM Image Builder service. -type CloudErrorBody struct { - // An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - Code *string `json:"code,omitempty"` - - // A list of additional details about the error. - Details []*CloudErrorBody `json:"details,omitempty"` - - // A message describing the error, intended to be suitable for display in a user interface. - Message *string `json:"message,omitempty"` - - // The target of the particular error. For example, the name of the property in error. - Target *string `json:"target,omitempty"` -} - type ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties struct { // READ-ONLY; The client id of user assigned identity. ClientID *string `json:"clientId,omitempty" azure:"ro"` @@ -654,7 +634,7 @@ type Operation struct { Origin *string `json:"origin,omitempty"` // Properties of the operation. - Properties interface{} `json:"properties,omitempty"` + Properties any `json:"properties,omitempty"` } // OperationDisplay - The object that describes the operation. @@ -682,7 +662,7 @@ type OperationListResult struct { Value []*Operation `json:"value,omitempty"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -868,19 +848,19 @@ type VirtualMachineImageTemplatesClientGetRunOutputOptions struct { // placeholder for future optional parameters } -// VirtualMachineImageTemplatesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.ListByResourceGroup +// VirtualMachineImageTemplatesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.NewListByResourceGroupPager // method. type VirtualMachineImageTemplatesClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// VirtualMachineImageTemplatesClientListOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.List +// VirtualMachineImageTemplatesClientListOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.NewListPager // method. type VirtualMachineImageTemplatesClientListOptions struct { // placeholder for future optional parameters } -// VirtualMachineImageTemplatesClientListRunOutputsOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.ListRunOutputs +// VirtualMachineImageTemplatesClientListRunOutputsOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.NewListRunOutputsPager // method. type VirtualMachineImageTemplatesClientListRunOutputsOptions struct { // placeholder for future optional parameters diff --git a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_models_serde.go b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/models_serde.go similarity index 55% rename from sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_models_serde.go rename to sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/models_serde.go index 95757c6804e1..7274d681972e 100644 --- a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_models_serde.go +++ b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/models_serde.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 armvirtualmachineimagebuilder @@ -15,9 +16,40 @@ import ( "reflect" ) +// MarshalJSON implements the json.Marshaller interface for type ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties. +func (c ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientId", c.ClientID) + populate(objectMap, "principalId", c.PrincipalID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties. +func (c *ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties) UnmarshalJSON(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 "clientId": + err = unpopulate(val, "ClientID", &c.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &c.PrincipalID) + 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 ImageTemplate. func (i ImageTemplate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", i.ID) populate(objectMap, "identity", i.Identity) populate(objectMap, "location", i.Location) @@ -29,18 +61,116 @@ func (i ImageTemplate) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageTemplate. +func (i *ImageTemplate) UnmarshalJSON(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 "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &i.Identity) + 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) + case "properties": + err = unpopulate(val, "Properties", &i.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &i.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &i.Tags) + 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 ImageTemplateCustomizer. +func (i ImageTemplateCustomizer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", i.Name) + objectMap["type"] = i.Type + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageTemplateCustomizer. +func (i *ImageTemplateCustomizer) UnmarshalJSON(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) + 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 ImageTemplateDistributor. func (i ImageTemplateDistributor) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "artifactTags", i.ArtifactTags) populate(objectMap, "runOutputName", i.RunOutputName) objectMap["type"] = i.Type return json.Marshal(objectMap) } +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageTemplateDistributor. +func (i *ImageTemplateDistributor) UnmarshalJSON(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 "artifactTags": + err = unpopulate(val, "ArtifactTags", &i.ArtifactTags) + delete(rawMsg, key) + case "runOutputName": + err = unpopulate(val, "RunOutputName", &i.RunOutputName) + 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 ImageTemplateFileCustomizer. func (i ImageTemplateFileCustomizer) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "destination", i.Destination) populate(objectMap, "name", i.Name) populate(objectMap, "sha256Checksum", i.SHA256Checksum) @@ -83,15 +213,69 @@ func (i *ImageTemplateFileCustomizer) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ImageTemplateIdentity. func (i ImageTemplateIdentity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "type", i.Type) populate(objectMap, "userAssignedIdentities", i.UserAssignedIdentities) return json.Marshal(objectMap) } +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageTemplateIdentity. +func (i *ImageTemplateIdentity) UnmarshalJSON(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 "type": + err = unpopulate(val, "Type", &i.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &i.UserAssignedIdentities) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImageTemplateInVMValidator. +func (i ImageTemplateInVMValidator) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", i.Name) + objectMap["type"] = i.Type + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageTemplateInVMValidator. +func (i *ImageTemplateInVMValidator) UnmarshalJSON(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) + 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 ImageTemplateLastRunStatus. func (i ImageTemplateLastRunStatus) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "endTime", i.EndTime) populate(objectMap, "message", i.Message) populate(objectMap, "runState", i.RunState) @@ -132,9 +316,40 @@ func (i *ImageTemplateLastRunStatus) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ImageTemplateListResult. +func (i ImageTemplateListResult) 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 ImageTemplateListResult. +func (i *ImageTemplateListResult) UnmarshalJSON(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 ImageTemplateManagedImageDistributor. func (i ImageTemplateManagedImageDistributor) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "artifactTags", i.ArtifactTags) populate(objectMap, "imageId", i.ImageID) populate(objectMap, "location", i.Location) @@ -177,7 +392,7 @@ func (i *ImageTemplateManagedImageDistributor) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type ImageTemplateManagedImageSource. func (i ImageTemplateManagedImageSource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "imageId", i.ImageID) objectMap["type"] = "ManagedImage" return json.Marshal(objectMap) @@ -208,7 +423,7 @@ func (i *ImageTemplateManagedImageSource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ImageTemplatePlatformImageSource. func (i ImageTemplatePlatformImageSource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "exactVersion", i.ExactVersion) populate(objectMap, "offer", i.Offer) populate(objectMap, "planInfo", i.PlanInfo) @@ -259,7 +474,7 @@ func (i *ImageTemplatePlatformImageSource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ImageTemplatePowerShellCustomizer. func (i ImageTemplatePowerShellCustomizer) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "inline", i.Inline) populate(objectMap, "name", i.Name) populate(objectMap, "runAsSystem", i.RunAsSystem) @@ -314,7 +529,7 @@ func (i *ImageTemplatePowerShellCustomizer) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ImageTemplatePowerShellValidator. func (i ImageTemplatePowerShellValidator) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "inline", i.Inline) populate(objectMap, "name", i.Name) populate(objectMap, "runAsSystem", i.RunAsSystem) @@ -369,7 +584,7 @@ func (i *ImageTemplatePowerShellValidator) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ImageTemplateProperties. func (i ImageTemplateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "buildTimeoutInMinutes", i.BuildTimeoutInMinutes) populate(objectMap, "customize", i.Customize) populate(objectMap, "distribute", i.Distribute) @@ -436,7 +651,7 @@ func (i *ImageTemplateProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ImageTemplatePropertiesValidate. func (i ImageTemplatePropertiesValidate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "continueDistributeOnFailure", i.ContinueDistributeOnFailure) populate(objectMap, "inVMValidations", i.InVMValidations) populate(objectMap, "sourceValidationOnly", i.SourceValidationOnly) @@ -471,7 +686,7 @@ func (i *ImageTemplatePropertiesValidate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ImageTemplateRestartCustomizer. func (i ImageTemplateRestartCustomizer) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", i.Name) populate(objectMap, "restartCheckCommand", i.RestartCheckCommand) populate(objectMap, "restartCommand", i.RestartCommand) @@ -514,7 +729,7 @@ func (i *ImageTemplateRestartCustomizer) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ImageTemplateSharedImageDistributor. func (i ImageTemplateSharedImageDistributor) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "artifactTags", i.ArtifactTags) populate(objectMap, "excludeFromLatest", i.ExcludeFromLatest) populate(objectMap, "galleryImageId", i.GalleryImageID) @@ -565,7 +780,7 @@ func (i *ImageTemplateSharedImageDistributor) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ImageTemplateSharedImageVersionSource. func (i ImageTemplateSharedImageVersionSource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "imageVersionId", i.ImageVersionID) objectMap["type"] = "SharedImageVersion" return json.Marshal(objectMap) @@ -596,7 +811,7 @@ func (i *ImageTemplateSharedImageVersionSource) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type ImageTemplateShellCustomizer. func (i ImageTemplateShellCustomizer) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "inline", i.Inline) populate(objectMap, "name", i.Name) populate(objectMap, "sha256Checksum", i.SHA256Checksum) @@ -639,7 +854,7 @@ func (i *ImageTemplateShellCustomizer) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ImageTemplateShellValidator. func (i ImageTemplateShellValidator) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "inline", i.Inline) populate(objectMap, "name", i.Name) populate(objectMap, "sha256Checksum", i.SHA256Checksum) @@ -680,17 +895,67 @@ func (i *ImageTemplateShellValidator) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ImageTemplateSource. +func (i ImageTemplateSource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["type"] = i.Type + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageTemplateSource. +func (i *ImageTemplateSource) UnmarshalJSON(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 "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 ImageTemplateUpdateParameters. func (i ImageTemplateUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "identity", i.Identity) populate(objectMap, "tags", i.Tags) return json.Marshal(objectMap) } +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageTemplateUpdateParameters. +func (i *ImageTemplateUpdateParameters) UnmarshalJSON(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 "identity": + err = unpopulate(val, "Identity", &i.Identity) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &i.Tags) + 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 ImageTemplateVMProfile. func (i ImageTemplateVMProfile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "osDiskSizeGB", i.OSDiskSizeGB) populate(objectMap, "userAssignedIdentities", i.UserAssignedIdentities) populate(objectMap, "vmSize", i.VMSize) @@ -698,9 +963,38 @@ func (i ImageTemplateVMProfile) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageTemplateVMProfile. +func (i *ImageTemplateVMProfile) UnmarshalJSON(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 "osDiskSizeGB": + err = unpopulate(val, "OSDiskSizeGB", &i.OSDiskSizeGB) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &i.UserAssignedIdentities) + delete(rawMsg, key) + case "vmSize": + err = unpopulate(val, "VMSize", &i.VMSize) + delete(rawMsg, key) + case "vnetConfig": + err = unpopulate(val, "VnetConfig", &i.VnetConfig) + 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 ImageTemplateVhdDistributor. func (i ImageTemplateVhdDistributor) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "artifactTags", i.ArtifactTags) populate(objectMap, "runOutputName", i.RunOutputName) objectMap["type"] = "VHD" @@ -735,7 +1029,7 @@ func (i *ImageTemplateVhdDistributor) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ImageTemplateWindowsUpdateCustomizer. func (i ImageTemplateWindowsUpdateCustomizer) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "filters", i.Filters) populate(objectMap, "name", i.Name) populate(objectMap, "searchCriteria", i.SearchCriteria) @@ -776,9 +1070,375 @@ func (i *ImageTemplateWindowsUpdateCustomizer) UnmarshalJSON(data []byte) error return nil } +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + populate(objectMap, "properties", &o.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type 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 PlatformImagePurchasePlan. +func (p PlatformImagePurchasePlan) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "planName", p.PlanName) + populate(objectMap, "planProduct", p.PlanProduct) + populate(objectMap, "planPublisher", p.PlanPublisher) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PlatformImagePurchasePlan. +func (p *PlatformImagePurchasePlan) UnmarshalJSON(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 "planName": + err = unpopulate(val, "PlanName", &p.PlanName) + delete(rawMsg, key) + case "planProduct": + err = unpopulate(val, "PlanProduct", &p.PlanProduct) + delete(rawMsg, key) + case "planPublisher": + err = unpopulate(val, "PlanPublisher", &p.PlanPublisher) + 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 ProvisioningError. +func (p ProvisioningError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", p.Message) + populate(objectMap, "provisioningErrorCode", p.ProvisioningErrorCode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisioningError. +func (p *ProvisioningError) UnmarshalJSON(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 "message": + err = unpopulate(val, "Message", &p.Message) + delete(rawMsg, key) + case "provisioningErrorCode": + err = unpopulate(val, "ProvisioningErrorCode", &p.ProvisioningErrorCode) + 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, "systemData", p.SystemData) + 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 "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 Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "systemData", r.SystemData) + 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 "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + 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 RunOutput. +func (r RunOutput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RunOutput. +func (r *RunOutput) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + 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 RunOutputCollection. +func (r RunOutputCollection) 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 RunOutputCollection. +func (r *RunOutputCollection) UnmarshalJSON(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 RunOutputProperties. +func (r RunOutputProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "artifactId", r.ArtifactID) + populate(objectMap, "artifactUri", r.ArtifactURI) + populate(objectMap, "provisioningState", r.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RunOutputProperties. +func (r *RunOutputProperties) UnmarshalJSON(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 "artifactId": + err = unpopulate(val, "ArtifactID", &r.ArtifactID) + delete(rawMsg, key) + case "artifactUri": + err = unpopulate(val, "ArtifactURI", &r.ArtifactURI) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) + 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]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) @@ -825,7 +1485,7 @@ func (s *SystemData) 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) @@ -835,7 +1495,73 @@ func (t TrackedResource) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -func populate(m map[string]interface{}, k string, v interface{}) { +// 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 "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + 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 VirtualNetworkConfig. +func (v VirtualNetworkConfig) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "proxyVmSize", v.ProxyVMSize) + populate(objectMap, "subnetId", v.SubnetID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworkConfig. +func (v *VirtualNetworkConfig) UnmarshalJSON(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 "proxyVmSize": + err = unpopulate(val, "ProxyVMSize", &v.ProxyVMSize) + delete(rawMsg, key) + case "subnetId": + err = unpopulate(val, "SubnetID", &v.SubnetID) + 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) { @@ -845,7 +1571,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/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_operations_client.go b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/operations_client.go similarity index 77% rename from sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_operations_client.go rename to sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/operations_client.go index 44e5933a596d..344096525b14 100644 --- a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_operations_client.go +++ b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/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 armvirtualmachineimagebuilder @@ -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 available operations for the Microsoft.VirtualMachineImages provider -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-14 -// 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.VirtualMachineImages/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/virtualmachineimagebuilder/armvirtualmachineimagebuilder/operations_client_example_test.go b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/operations_client_example_test.go new file mode 100644 index 000000000000..09b6f507ab59 --- /dev/null +++ b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/operations_client_example_test.go @@ -0,0 +1,144 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armvirtualmachineimagebuilder_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/078b90617e5e08137d0395963bd4119f4561a910/specification/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/OperationsList.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualmachineimagebuilder.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 = armvirtualmachineimagebuilder.OperationListResult{ + // Value: []*armvirtualmachineimagebuilder.Operation{ + // { + // Name: to.Ptr("Microsoft.VirtualMachineImages/register/action"), + // Display: &armvirtualmachineimagebuilder.OperationDisplay{ + // Description: to.Ptr("Register Virtual Machine Image Builder RP"), + // Operation: to.Ptr("Register Virtual Machine Image Builder RP"), + // Provider: to.Ptr("Virtual Machine Image Builder"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.VirtualMachineImages/unregister/action"), + // Display: &armvirtualmachineimagebuilder.OperationDisplay{ + // Description: to.Ptr("Unregister Virtual Machine Image Builder RP"), + // Operation: to.Ptr("Unregister Virtual Machine Image Builder RP"), + // Provider: to.Ptr("Virtual Machine Image Builder"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.VirtualMachineImages/imageTemplates/read"), + // Display: &armvirtualmachineimagebuilder.OperationDisplay{ + // Description: to.Ptr("Get a VM image template instance resource"), + // Operation: to.Ptr("Get a VM image template instance resource"), + // Provider: to.Ptr("Virtual Machine Image Builder"), + // Resource: to.Ptr("VM Image template"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.VirtualMachineImages/imageTemplates/write"), + // Display: &armvirtualmachineimagebuilder.OperationDisplay{ + // Description: to.Ptr("Create or update a VM image template instance resource"), + // Operation: to.Ptr("Create or update a VM image template instance resource"), + // Provider: to.Ptr("Virtual Machine Image Builder"), + // Resource: to.Ptr("VM Image template"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.VirtualMachineImages/imageTemplates/delete"), + // Display: &armvirtualmachineimagebuilder.OperationDisplay{ + // Description: to.Ptr("Delete a VM image template instance resource"), + // Operation: to.Ptr("Delete a VM image template instance resource"), + // Provider: to.Ptr("Virtual Machine Image Builder"), + // Resource: to.Ptr("VM Image template"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.VirtualMachineImages/imageTemplates/run/action"), + // Display: &armvirtualmachineimagebuilder.OperationDisplay{ + // Description: to.Ptr("Execute a VM image template to produce its outputs"), + // Operation: to.Ptr("Execute a VM image template to produce its outputs"), + // Provider: to.Ptr("Virtual Machine Image Builder"), + // Resource: to.Ptr("VM Image template"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.VirtualMachineImages/imageTemplates/runOutputs/read"), + // Display: &armvirtualmachineimagebuilder.OperationDisplay{ + // Description: to.Ptr("Get a VM image template run output resource"), + // Operation: to.Ptr("Get a VM image template run output resource"), + // Provider: to.Ptr("Virtual Machine Image Builder"), + // Resource: to.Ptr("VM Image template run output"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.VirtualMachineImages/operations/read"), + // Display: &armvirtualmachineimagebuilder.OperationDisplay{ + // Description: to.Ptr("List available Virtual Machine Image Builder Operations"), + // Operation: to.Ptr("List available Virtual Machine Image Builder Operations"), + // Provider: to.Ptr("Virtual Machine Image Builder"), + // Resource: to.Ptr("Operation"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.VirtualMachineImages/locations/operations/read"), + // Display: &armvirtualmachineimagebuilder.OperationDisplay{ + // Description: to.Ptr("Get the status of an asynchronous operation"), + // Operation: to.Ptr("Get the status of an asynchronous operation"), + // Provider: to.Ptr("Virtual Machine Image Builder"), + // Resource: to.Ptr("Asynchronous Operation"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.VirtualMachineImages/imageTemplates/cancel/action"), + // Display: &armvirtualmachineimagebuilder.OperationDisplay{ + // Description: to.Ptr("Cancel a running image build"), + // Operation: to.Ptr("Cancel a running image build"), + // Provider: to.Ptr("Virtual Machine Image Builder"), + // Resource: to.Ptr("VM Image template"), + // }, + // IsDataAction: to.Ptr(false), + // }}, + // } + } +} diff --git a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_polymorphic_helpers.go b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/polymorphic_helpers.go similarity index 97% rename from sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_polymorphic_helpers.go rename to sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/polymorphic_helpers.go index b4ed5d172006..72a661e9555c 100644 --- a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_polymorphic_helpers.go +++ b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/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 armvirtualmachineimagebuilder @@ -14,7 +15,7 @@ func unmarshalImageTemplateCustomizerClassification(rawMsg json.RawMessage) (Ima 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 } @@ -59,7 +60,7 @@ func unmarshalImageTemplateDistributorClassification(rawMsg json.RawMessage) (Im 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 } @@ -100,7 +101,7 @@ func unmarshalImageTemplateInVMValidatorClassification(rawMsg json.RawMessage) ( if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } @@ -139,7 +140,7 @@ func unmarshalImageTemplateSourceClassification(rawMsg json.RawMessage) (ImageTe 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/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_response_types.go b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/response_types.go similarity index 83% rename from sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_response_types.go rename to sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/response_types.go index a3525390a7db..cd0dd57d4600 100644 --- a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_response_types.go +++ b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/response_types.go @@ -5,25 +5,26 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armvirtualmachineimagebuilder -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationListResult } -// VirtualMachineImageTemplatesClientCancelResponse contains the response from method VirtualMachineImageTemplatesClient.Cancel. +// VirtualMachineImageTemplatesClientCancelResponse contains the response from method VirtualMachineImageTemplatesClient.BeginCancel. type VirtualMachineImageTemplatesClientCancelResponse struct { // placeholder for future response values } -// VirtualMachineImageTemplatesClientCreateOrUpdateResponse contains the response from method VirtualMachineImageTemplatesClient.CreateOrUpdate. +// VirtualMachineImageTemplatesClientCreateOrUpdateResponse contains the response from method VirtualMachineImageTemplatesClient.BeginCreateOrUpdate. type VirtualMachineImageTemplatesClientCreateOrUpdateResponse struct { ImageTemplate } -// VirtualMachineImageTemplatesClientDeleteResponse contains the response from method VirtualMachineImageTemplatesClient.Delete. +// VirtualMachineImageTemplatesClientDeleteResponse contains the response from method VirtualMachineImageTemplatesClient.BeginDelete. type VirtualMachineImageTemplatesClientDeleteResponse struct { // placeholder for future response values } @@ -38,27 +39,27 @@ type VirtualMachineImageTemplatesClientGetRunOutputResponse struct { RunOutput } -// VirtualMachineImageTemplatesClientListByResourceGroupResponse contains the response from method VirtualMachineImageTemplatesClient.ListByResourceGroup. +// VirtualMachineImageTemplatesClientListByResourceGroupResponse contains the response from method VirtualMachineImageTemplatesClient.NewListByResourceGroupPager. type VirtualMachineImageTemplatesClientListByResourceGroupResponse struct { ImageTemplateListResult } -// VirtualMachineImageTemplatesClientListResponse contains the response from method VirtualMachineImageTemplatesClient.List. +// VirtualMachineImageTemplatesClientListResponse contains the response from method VirtualMachineImageTemplatesClient.NewListPager. type VirtualMachineImageTemplatesClientListResponse struct { ImageTemplateListResult } -// VirtualMachineImageTemplatesClientListRunOutputsResponse contains the response from method VirtualMachineImageTemplatesClient.ListRunOutputs. +// VirtualMachineImageTemplatesClientListRunOutputsResponse contains the response from method VirtualMachineImageTemplatesClient.NewListRunOutputsPager. type VirtualMachineImageTemplatesClientListRunOutputsResponse struct { RunOutputCollection } -// VirtualMachineImageTemplatesClientRunResponse contains the response from method VirtualMachineImageTemplatesClient.Run. +// VirtualMachineImageTemplatesClientRunResponse contains the response from method VirtualMachineImageTemplatesClient.BeginRun. type VirtualMachineImageTemplatesClientRunResponse struct { // placeholder for future response values } -// VirtualMachineImageTemplatesClientUpdateResponse contains the response from method VirtualMachineImageTemplatesClient.Update. +// VirtualMachineImageTemplatesClientUpdateResponse contains the response from method VirtualMachineImageTemplatesClient.BeginUpdate. type VirtualMachineImageTemplatesClientUpdateResponse struct { ImageTemplate } diff --git a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_time_rfc3339.go b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/time_rfc3339.go index 0c365d041988..b58e7f418b38 100644 --- a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/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 armvirtualmachineimagebuilder @@ -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/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_virtualmachineimagetemplates_client.go b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/virtualmachineimagetemplates_client.go similarity index 85% rename from sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_virtualmachineimagetemplates_client.go rename to sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/virtualmachineimagetemplates_client.go index 9269d4d542fe..afec5a230093 100644 --- a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/zz_generated_virtualmachineimagetemplates_client.go +++ b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/virtualmachineimagetemplates_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 armvirtualmachineimagebuilder @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,66 +24,59 @@ import ( // VirtualMachineImageTemplatesClient contains the methods for the VirtualMachineImageTemplates group. // Don't use this type directly, use NewVirtualMachineImageTemplatesClient() instead. type VirtualMachineImageTemplatesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewVirtualMachineImageTemplatesClient creates a new instance of VirtualMachineImageTemplatesClient with the specified values. -// subscriptionID - Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription Id forms -// part of the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription Id forms +// part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewVirtualMachineImageTemplatesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualMachineImageTemplatesClient, 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+".VirtualMachineImageTemplatesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &VirtualMachineImageTemplatesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCancel - Cancel the long running image build based on the image template // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-14 -// resourceGroupName - The name of the resource group. -// imageTemplateName - The name of the image Template -// options - VirtualMachineImageTemplatesClientBeginCancelOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.BeginCancel -// method. +// - resourceGroupName - The name of the resource group. +// - imageTemplateName - The name of the image Template +// - options - VirtualMachineImageTemplatesClientBeginCancelOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.BeginCancel +// method. func (client *VirtualMachineImageTemplatesClient) BeginCancel(ctx context.Context, resourceGroupName string, imageTemplateName string, options *VirtualMachineImageTemplatesClientBeginCancelOptions) (*runtime.Poller[VirtualMachineImageTemplatesClientCancelResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.cancel(ctx, resourceGroupName, imageTemplateName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[VirtualMachineImageTemplatesClientCancelResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineImageTemplatesClientCancelResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[VirtualMachineImageTemplatesClientCancelResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachineImageTemplatesClientCancelResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Cancel - Cancel the long running image build based on the image template // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-14 func (client *VirtualMachineImageTemplatesClient) cancel(ctx context.Context, resourceGroupName string, imageTemplateName string, options *VirtualMachineImageTemplatesClientBeginCancelOptions) (*http.Response, error) { req, err := client.cancelCreateRequest(ctx, resourceGroupName, imageTemplateName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -109,7 +101,7 @@ func (client *VirtualMachineImageTemplatesClient) cancelCreateRequest(ctx contex return nil, errors.New("parameter imageTemplateName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{imageTemplateName}", url.PathEscape(imageTemplateName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -122,35 +114,37 @@ func (client *VirtualMachineImageTemplatesClient) cancelCreateRequest(ctx contex // BeginCreateOrUpdate - Create or update a virtual machine image template // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-14 -// resourceGroupName - The name of the resource group. -// imageTemplateName - The name of the image Template -// parameters - Parameters supplied to the CreateImageTemplate operation -// options - VirtualMachineImageTemplatesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - imageTemplateName - The name of the image Template +// - parameters - Parameters supplied to the CreateImageTemplate operation +// - options - VirtualMachineImageTemplatesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.BeginCreateOrUpdate +// method. func (client *VirtualMachineImageTemplatesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, imageTemplateName string, parameters ImageTemplate, options *VirtualMachineImageTemplatesClientBeginCreateOrUpdateOptions) (*runtime.Poller[VirtualMachineImageTemplatesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, imageTemplateName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[VirtualMachineImageTemplatesClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineImageTemplatesClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[VirtualMachineImageTemplatesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachineImageTemplatesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create or update a virtual machine image template // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-14 func (client *VirtualMachineImageTemplatesClient) createOrUpdate(ctx context.Context, resourceGroupName string, imageTemplateName string, parameters ImageTemplate, options *VirtualMachineImageTemplatesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, imageTemplateName, 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 } @@ -175,7 +169,7 @@ func (client *VirtualMachineImageTemplatesClient) createOrUpdateCreateRequest(ct return nil, errors.New("parameter imageTemplateName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{imageTemplateName}", url.PathEscape(imageTemplateName)) - 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 } @@ -188,34 +182,36 @@ func (client *VirtualMachineImageTemplatesClient) createOrUpdateCreateRequest(ct // BeginDelete - Delete a virtual machine image template // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-14 -// resourceGroupName - The name of the resource group. -// imageTemplateName - The name of the image Template -// options - VirtualMachineImageTemplatesClientBeginDeleteOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. +// - imageTemplateName - The name of the image Template +// - options - VirtualMachineImageTemplatesClientBeginDeleteOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.BeginDelete +// method. func (client *VirtualMachineImageTemplatesClient) BeginDelete(ctx context.Context, resourceGroupName string, imageTemplateName string, options *VirtualMachineImageTemplatesClientBeginDeleteOptions) (*runtime.Poller[VirtualMachineImageTemplatesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, imageTemplateName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[VirtualMachineImageTemplatesClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineImageTemplatesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[VirtualMachineImageTemplatesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachineImageTemplatesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete a virtual machine image template // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-14 func (client *VirtualMachineImageTemplatesClient) deleteOperation(ctx context.Context, resourceGroupName string, imageTemplateName string, options *VirtualMachineImageTemplatesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, imageTemplateName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -240,7 +236,7 @@ func (client *VirtualMachineImageTemplatesClient) deleteCreateRequest(ctx contex return nil, errors.New("parameter imageTemplateName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{imageTemplateName}", url.PathEscape(imageTemplateName)) - 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 } @@ -253,17 +249,18 @@ func (client *VirtualMachineImageTemplatesClient) deleteCreateRequest(ctx contex // Get - Get information about a virtual machine image template // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-14 -// resourceGroupName - The name of the resource group. -// imageTemplateName - The name of the image Template -// options - VirtualMachineImageTemplatesClientGetOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.Get -// method. +// - resourceGroupName - The name of the resource group. +// - imageTemplateName - The name of the image Template +// - options - VirtualMachineImageTemplatesClientGetOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.Get +// method. func (client *VirtualMachineImageTemplatesClient) Get(ctx context.Context, resourceGroupName string, imageTemplateName string, options *VirtualMachineImageTemplatesClientGetOptions) (VirtualMachineImageTemplatesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, imageTemplateName, options) if err != nil { return VirtualMachineImageTemplatesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachineImageTemplatesClientGetResponse{}, err } @@ -288,7 +285,7 @@ func (client *VirtualMachineImageTemplatesClient) getCreateRequest(ctx context.C return nil, errors.New("parameter imageTemplateName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{imageTemplateName}", url.PathEscape(imageTemplateName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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,18 +307,19 @@ func (client *VirtualMachineImageTemplatesClient) getHandleResponse(resp *http.R // GetRunOutput - Get the specified run output for the specified image template resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-14 -// resourceGroupName - The name of the resource group. -// imageTemplateName - The name of the image Template -// runOutputName - The name of the run output -// options - VirtualMachineImageTemplatesClientGetRunOutputOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.GetRunOutput -// method. +// - resourceGroupName - The name of the resource group. +// - imageTemplateName - The name of the image Template +// - runOutputName - The name of the run output +// - options - VirtualMachineImageTemplatesClientGetRunOutputOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.GetRunOutput +// method. func (client *VirtualMachineImageTemplatesClient) GetRunOutput(ctx context.Context, resourceGroupName string, imageTemplateName string, runOutputName string, options *VirtualMachineImageTemplatesClientGetRunOutputOptions) (VirtualMachineImageTemplatesClientGetRunOutputResponse, error) { req, err := client.getRunOutputCreateRequest(ctx, resourceGroupName, imageTemplateName, runOutputName, options) if err != nil { return VirtualMachineImageTemplatesClientGetRunOutputResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachineImageTemplatesClientGetRunOutputResponse{}, err } @@ -350,7 +348,7 @@ func (client *VirtualMachineImageTemplatesClient) getRunOutputCreateRequest(ctx return nil, errors.New("parameter runOutputName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{runOutputName}", url.PathEscape(runOutputName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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,10 +369,10 @@ func (client *VirtualMachineImageTemplatesClient) getRunOutputHandleResponse(res } // NewListPager - Gets information about the VM image templates associated with the subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-14 -// options - VirtualMachineImageTemplatesClientListOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.List -// method. +// - options - VirtualMachineImageTemplatesClientListOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.NewListPager +// method. func (client *VirtualMachineImageTemplatesClient) NewListPager(options *VirtualMachineImageTemplatesClientListOptions) *runtime.Pager[VirtualMachineImageTemplatesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[VirtualMachineImageTemplatesClientListResponse]{ More: func(page VirtualMachineImageTemplatesClientListResponse) bool { @@ -391,7 +389,7 @@ func (client *VirtualMachineImageTemplatesClient) NewListPager(options *VirtualM if err != nil { return VirtualMachineImageTemplatesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachineImageTemplatesClientListResponse{}, err } @@ -410,7 +408,7 @@ func (client *VirtualMachineImageTemplatesClient) listCreateRequest(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 } @@ -431,11 +429,11 @@ func (client *VirtualMachineImageTemplatesClient) listHandleResponse(resp *http. } // NewListByResourceGroupPager - Gets information about the VM image templates associated with the specified resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-14 -// resourceGroupName - The name of the resource group. -// options - VirtualMachineImageTemplatesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. +// - options - VirtualMachineImageTemplatesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.NewListByResourceGroupPager +// method. func (client *VirtualMachineImageTemplatesClient) NewListByResourceGroupPager(resourceGroupName string, options *VirtualMachineImageTemplatesClientListByResourceGroupOptions) *runtime.Pager[VirtualMachineImageTemplatesClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[VirtualMachineImageTemplatesClientListByResourceGroupResponse]{ More: func(page VirtualMachineImageTemplatesClientListByResourceGroupResponse) bool { @@ -452,7 +450,7 @@ func (client *VirtualMachineImageTemplatesClient) NewListByResourceGroupPager(re if err != nil { return VirtualMachineImageTemplatesClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachineImageTemplatesClientListByResourceGroupResponse{}, err } @@ -475,7 +473,7 @@ func (client *VirtualMachineImageTemplatesClient) listByResourceGroupCreateReque 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 } @@ -496,12 +494,12 @@ func (client *VirtualMachineImageTemplatesClient) listByResourceGroupHandleRespo } // NewListRunOutputsPager - List all run outputs for the specified Image Template resource -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-14 -// resourceGroupName - The name of the resource group. -// imageTemplateName - The name of the image Template -// options - VirtualMachineImageTemplatesClientListRunOutputsOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.ListRunOutputs -// method. +// - resourceGroupName - The name of the resource group. +// - imageTemplateName - The name of the image Template +// - options - VirtualMachineImageTemplatesClientListRunOutputsOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.NewListRunOutputsPager +// method. func (client *VirtualMachineImageTemplatesClient) NewListRunOutputsPager(resourceGroupName string, imageTemplateName string, options *VirtualMachineImageTemplatesClientListRunOutputsOptions) *runtime.Pager[VirtualMachineImageTemplatesClientListRunOutputsResponse] { return runtime.NewPager(runtime.PagingHandler[VirtualMachineImageTemplatesClientListRunOutputsResponse]{ More: func(page VirtualMachineImageTemplatesClientListRunOutputsResponse) bool { @@ -518,7 +516,7 @@ func (client *VirtualMachineImageTemplatesClient) NewListRunOutputsPager(resourc if err != nil { return VirtualMachineImageTemplatesClientListRunOutputsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachineImageTemplatesClientListRunOutputsResponse{}, err } @@ -545,7 +543,7 @@ func (client *VirtualMachineImageTemplatesClient) listRunOutputsCreateRequest(ct return nil, errors.New("parameter imageTemplateName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{imageTemplateName}", url.PathEscape(imageTemplateName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -567,34 +565,36 @@ func (client *VirtualMachineImageTemplatesClient) listRunOutputsHandleResponse(r // BeginRun - Create artifacts from a existing image template // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-14 -// resourceGroupName - The name of the resource group. -// imageTemplateName - The name of the image Template -// options - VirtualMachineImageTemplatesClientBeginRunOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.BeginRun -// method. +// - resourceGroupName - The name of the resource group. +// - imageTemplateName - The name of the image Template +// - options - VirtualMachineImageTemplatesClientBeginRunOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.BeginRun +// method. func (client *VirtualMachineImageTemplatesClient) BeginRun(ctx context.Context, resourceGroupName string, imageTemplateName string, options *VirtualMachineImageTemplatesClientBeginRunOptions) (*runtime.Poller[VirtualMachineImageTemplatesClientRunResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.run(ctx, resourceGroupName, imageTemplateName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[VirtualMachineImageTemplatesClientRunResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineImageTemplatesClientRunResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[VirtualMachineImageTemplatesClientRunResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachineImageTemplatesClientRunResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Run - Create artifacts from a existing image template // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-14 func (client *VirtualMachineImageTemplatesClient) run(ctx context.Context, resourceGroupName string, imageTemplateName string, options *VirtualMachineImageTemplatesClientBeginRunOptions) (*http.Response, error) { req, err := client.runCreateRequest(ctx, resourceGroupName, imageTemplateName, 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 } @@ -619,7 +619,7 @@ func (client *VirtualMachineImageTemplatesClient) runCreateRequest(ctx context.C return nil, errors.New("parameter imageTemplateName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{imageTemplateName}", url.PathEscape(imageTemplateName)) - 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 } @@ -632,35 +632,37 @@ func (client *VirtualMachineImageTemplatesClient) runCreateRequest(ctx context.C // BeginUpdate - Update the tags for this Virtual Machine Image Template // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-14 -// resourceGroupName - The name of the resource group. -// imageTemplateName - The name of the image Template -// parameters - Additional parameters for Image Template update. -// options - VirtualMachineImageTemplatesClientBeginUpdateOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.BeginUpdate -// method. +// - resourceGroupName - The name of the resource group. +// - imageTemplateName - The name of the image Template +// - parameters - Additional parameters for Image Template update. +// - options - VirtualMachineImageTemplatesClientBeginUpdateOptions contains the optional parameters for the VirtualMachineImageTemplatesClient.BeginUpdate +// method. func (client *VirtualMachineImageTemplatesClient) BeginUpdate(ctx context.Context, resourceGroupName string, imageTemplateName string, parameters ImageTemplateUpdateParameters, options *VirtualMachineImageTemplatesClientBeginUpdateOptions) (*runtime.Poller[VirtualMachineImageTemplatesClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, imageTemplateName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[VirtualMachineImageTemplatesClientUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachineImageTemplatesClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[VirtualMachineImageTemplatesClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachineImageTemplatesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Update the tags for this Virtual Machine Image Template // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-02-14 func (client *VirtualMachineImageTemplatesClient) update(ctx context.Context, resourceGroupName string, imageTemplateName string, parameters ImageTemplateUpdateParameters, options *VirtualMachineImageTemplatesClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, imageTemplateName, 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 } @@ -685,7 +687,7 @@ func (client *VirtualMachineImageTemplatesClient) updateCreateRequest(ctx contex return nil, errors.New("parameter imageTemplateName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{imageTemplateName}", url.PathEscape(imageTemplateName)) - 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/virtualmachineimagebuilder/armvirtualmachineimagebuilder/virtualmachineimagetemplates_client_example_test.go b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/virtualmachineimagetemplates_client_example_test.go new file mode 100644 index 000000000000..8e885201e30f --- /dev/null +++ b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/virtualmachineimagetemplates_client_example_test.go @@ -0,0 +1,945 @@ +//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 armvirtualmachineimagebuilder_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/virtualmachineimagebuilder/armvirtualmachineimagebuilder" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/078b90617e5e08137d0395963bd4119f4561a910/specification/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/ListImageTemplates.json +func ExampleVirtualMachineImageTemplatesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualmachineimagebuilder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewVirtualMachineImageTemplatesClient().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.ImageTemplateListResult = armvirtualmachineimagebuilder.ImageTemplateListResult{ + // Value: []*armvirtualmachineimagebuilder.ImageTemplate{ + // { + // Name: to.Ptr("myImageTemplate"), + // Type: to.Ptr("Microsoft.VirtualMachineImages/imageTemplate"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.VirtualMachineImages/imageTemplates/myImageTemplate"), + // Location: to.Ptr("westus"), + // Identity: &armvirtualmachineimagebuilder.ImageTemplateIdentity{ + // Type: to.Ptr(armvirtualmachineimagebuilder.ResourceIdentityTypeUserAssigned), + // UserAssignedIdentities: map[string]*armvirtualmachineimagebuilder.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity_1": &armvirtualmachineimagebuilder.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Properties: &armvirtualmachineimagebuilder.ImageTemplateProperties{ + // Customize: []armvirtualmachineimagebuilder.ImageTemplateCustomizerClassification{ + // &armvirtualmachineimagebuilder.ImageTemplateShellCustomizer{ + // Name: to.Ptr("Shell customization example"), + // Type: to.Ptr("Shell"), + // ScriptURI: to.Ptr("https://example.com/path/to/script.sh"), + // }}, + // Distribute: []armvirtualmachineimagebuilder.ImageTemplateDistributorClassification{ + // &armvirtualmachineimagebuilder.ImageTemplateManagedImageDistributor{ + // Type: to.Ptr("ManagedImage"), + // ArtifactTags: map[string]*string{ + // "tagName": to.Ptr("value"), + // }, + // RunOutputName: to.Ptr("image_it_pir_1"), + // ImageID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/images/image_it_1"), + // Location: to.Ptr("1_location"), + // }}, + // Source: &armvirtualmachineimagebuilder.ImageTemplateManagedImageSource{ + // Type: to.Ptr("ManagedImage"), + // ImageID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/source_rg/providers/Microsoft.Compute/images/source_image"), + // }, + // VMProfile: &armvirtualmachineimagebuilder.ImageTemplateVMProfile{ + // OSDiskSizeGB: to.Ptr[int32](64), + // VMSize: to.Ptr("Standard_D2s_v3"), + // }, + // }, + // }, + // { + // Name: to.Ptr("mySecondImageTemplate"), + // Type: to.Ptr("Microsoft.VirtualMachineImages/imageTemplate"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myOtherResourceGroup/providers/Microsoft.VirtualMachineImages/imageTemplates/mySecondImageTemplate"), + // Location: to.Ptr("westus"), + // Identity: &armvirtualmachineimagebuilder.ImageTemplateIdentity{ + // Type: to.Ptr(armvirtualmachineimagebuilder.ResourceIdentityTypeUserAssigned), + // UserAssignedIdentities: map[string]*armvirtualmachineimagebuilder.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity_1": &armvirtualmachineimagebuilder.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Properties: &armvirtualmachineimagebuilder.ImageTemplateProperties{ + // Customize: []armvirtualmachineimagebuilder.ImageTemplateCustomizerClassification{ + // &armvirtualmachineimagebuilder.ImageTemplateShellCustomizer{ + // Name: to.Ptr("Shell customization example"), + // Type: to.Ptr("Shell"), + // ScriptURI: to.Ptr("https://example.com/path/to/script.sh"), + // }}, + // Distribute: []armvirtualmachineimagebuilder.ImageTemplateDistributorClassification{ + // &armvirtualmachineimagebuilder.ImageTemplateManagedImageDistributor{ + // Type: to.Ptr("ManagedImage"), + // ArtifactTags: map[string]*string{ + // "stage": to.Ptr("development"), + // }, + // RunOutputName: to.Ptr("eus"), + // ImageID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/images/mySecondImage-eus"), + // Location: to.Ptr("eastus"), + // }}, + // Source: &armvirtualmachineimagebuilder.ImageTemplatePlatformImageSource{ + // Type: to.Ptr("PlatformImage"), + // Offer: to.Ptr("UbuntuServer"), + // PlanInfo: &armvirtualmachineimagebuilder.PlatformImagePurchasePlan{ + // PlanName: to.Ptr("example_plan_name"), + // PlanProduct: to.Ptr("example_plan_product"), + // PlanPublisher: to.Ptr("example_plan_publisher"), + // }, + // Publisher: to.Ptr("Canonical"), + // SKU: to.Ptr("18.04-LTS"), + // Version: to.Ptr("18.04.201902121"), + // }, + // VMProfile: &armvirtualmachineimagebuilder.ImageTemplateVMProfile{ + // OSDiskSizeGB: to.Ptr[int32](32), + // VMSize: to.Ptr("Standard_D8s_v3"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/078b90617e5e08137d0395963bd4119f4561a910/specification/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/ListImageTemplatesByRg.json +func ExampleVirtualMachineImageTemplatesClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualmachineimagebuilder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewVirtualMachineImageTemplatesClient().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.ImageTemplateListResult = armvirtualmachineimagebuilder.ImageTemplateListResult{ + // Value: []*armvirtualmachineimagebuilder.ImageTemplate{ + // { + // Name: to.Ptr("myImageTemplate"), + // Type: to.Ptr("Microsoft.VirtualMachineImages/imageTemplate"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.VirtualMachineImages/imageTemplates/myImageTemplate"), + // Location: to.Ptr("westus"), + // Identity: &armvirtualmachineimagebuilder.ImageTemplateIdentity{ + // Type: to.Ptr(armvirtualmachineimagebuilder.ResourceIdentityTypeUserAssigned), + // UserAssignedIdentities: map[string]*armvirtualmachineimagebuilder.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity_1": &armvirtualmachineimagebuilder.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Properties: &armvirtualmachineimagebuilder.ImageTemplateProperties{ + // Customize: []armvirtualmachineimagebuilder.ImageTemplateCustomizerClassification{ + // &armvirtualmachineimagebuilder.ImageTemplateShellCustomizer{ + // Name: to.Ptr("Shell customization example"), + // Type: to.Ptr("Shell"), + // ScriptURI: to.Ptr("https://example.com/path/to/script.sh"), + // }}, + // Distribute: []armvirtualmachineimagebuilder.ImageTemplateDistributorClassification{ + // &armvirtualmachineimagebuilder.ImageTemplateManagedImageDistributor{ + // Type: to.Ptr("ManagedImage"), + // ArtifactTags: map[string]*string{ + // "tagName": to.Ptr("value"), + // }, + // RunOutputName: to.Ptr("image_it_pir_1"), + // ImageID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/images/image_it_1"), + // Location: to.Ptr("1_location"), + // }}, + // Source: &armvirtualmachineimagebuilder.ImageTemplateManagedImageSource{ + // Type: to.Ptr("ManagedImage"), + // ImageID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/source_rg/providers/Microsoft.Compute/images/source_image"), + // }, + // VMProfile: &armvirtualmachineimagebuilder.ImageTemplateVMProfile{ + // OSDiskSizeGB: to.Ptr[int32](64), + // VMSize: to.Ptr("Standard_D2s_v3"), + // }, + // }, + // }, + // { + // Name: to.Ptr("myOtherImageTemplate"), + // Type: to.Ptr("Microsoft.VirtualMachineImages/imageTemplate"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.VirtualMachineImages/imageTemplates/myOtherImageTemplate"), + // Location: to.Ptr("eastus"), + // Identity: &armvirtualmachineimagebuilder.ImageTemplateIdentity{ + // Type: to.Ptr(armvirtualmachineimagebuilder.ResourceIdentityTypeUserAssigned), + // UserAssignedIdentities: map[string]*armvirtualmachineimagebuilder.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity_1": &armvirtualmachineimagebuilder.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Properties: &armvirtualmachineimagebuilder.ImageTemplateProperties{ + // Customize: []armvirtualmachineimagebuilder.ImageTemplateCustomizerClassification{ + // &armvirtualmachineimagebuilder.ImageTemplateShellCustomizer{ + // Name: to.Ptr("Shell customization example"), + // Type: to.Ptr("Shell"), + // ScriptURI: to.Ptr("https://example.com/path/to/script.sh"), + // }}, + // Distribute: []armvirtualmachineimagebuilder.ImageTemplateDistributorClassification{ + // &armvirtualmachineimagebuilder.ImageTemplateManagedImageDistributor{ + // Type: to.Ptr("ManagedImage"), + // RunOutputName: to.Ptr("singleImage"), + // ImageID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/images/baseimage-cus"), + // Location: to.Ptr("centralus"), + // }, + // &armvirtualmachineimagebuilder.ImageTemplateSharedImageDistributor{ + // Type: to.Ptr("SharedImage"), + // RunOutputName: to.Ptr("gallery"), + // ExcludeFromLatest: to.Ptr(true), + // GalleryImageID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/gallery/baseimages/images/baseimage"), + // ReplicationRegions: []*string{ + // to.Ptr("eastus"), + // to.Ptr("westus")}, + // StorageAccountType: to.Ptr(armvirtualmachineimagebuilder.SharedImageStorageAccountTypeStandardLRS), + // }}, + // Source: &armvirtualmachineimagebuilder.ImageTemplatePlatformImageSource{ + // Type: to.Ptr("PlatformImage"), + // Offer: to.Ptr("UbuntuServer"), + // PlanInfo: &armvirtualmachineimagebuilder.PlatformImagePurchasePlan{ + // PlanName: to.Ptr("example_plan_name"), + // PlanProduct: to.Ptr("example_plan_product"), + // PlanPublisher: to.Ptr("example_plan_publisher"), + // }, + // Publisher: to.Ptr("Canonical"), + // SKU: to.Ptr("18.04-LTS"), + // Version: to.Ptr("18.04.201902121"), + // }, + // VMProfile: &armvirtualmachineimagebuilder.ImageTemplateVMProfile{ + // OSDiskSizeGB: to.Ptr[int32](64), + // VMSize: to.Ptr("Standard_D8s_v3"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/078b90617e5e08137d0395963bd4119f4561a910/specification/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/CreateImageTemplateLinux.json +func ExampleVirtualMachineImageTemplatesClient_BeginCreateOrUpdate_createAnImageTemplateForLinux() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualmachineimagebuilder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachineImageTemplatesClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myImageTemplate", armvirtualmachineimagebuilder.ImageTemplate{ + Location: to.Ptr("westus"), + Tags: map[string]*string{ + "imagetemplate_tag1": to.Ptr("IT_T1"), + "imagetemplate_tag2": to.Ptr("IT_T2"), + }, + Identity: &armvirtualmachineimagebuilder.ImageTemplateIdentity{ + Type: to.Ptr(armvirtualmachineimagebuilder.ResourceIdentityTypeUserAssigned), + UserAssignedIdentities: map[string]*armvirtualmachineimagebuilder.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties{ + "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity_1": {}, + }, + }, + Properties: &armvirtualmachineimagebuilder.ImageTemplateProperties{ + Customize: []armvirtualmachineimagebuilder.ImageTemplateCustomizerClassification{ + &armvirtualmachineimagebuilder.ImageTemplateShellCustomizer{ + Name: to.Ptr("Shell Customizer Example"), + Type: to.Ptr("Shell"), + ScriptURI: to.Ptr("https://example.com/path/to/script.sh"), + }}, + Distribute: []armvirtualmachineimagebuilder.ImageTemplateDistributorClassification{ + &armvirtualmachineimagebuilder.ImageTemplateManagedImageDistributor{ + Type: to.Ptr("ManagedImage"), + ArtifactTags: map[string]*string{ + "tagName": to.Ptr("value"), + }, + RunOutputName: to.Ptr("image_it_pir_1"), + ImageID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/images/image_it_1"), + Location: to.Ptr("1_location"), + }}, + Source: &armvirtualmachineimagebuilder.ImageTemplateManagedImageSource{ + Type: to.Ptr("ManagedImage"), + ImageID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Compute/images/source_image"), + }, + VMProfile: &armvirtualmachineimagebuilder.ImageTemplateVMProfile{ + OSDiskSizeGB: to.Ptr[int32](64), + VMSize: to.Ptr("Standard_D2s_v3"), + VnetConfig: &armvirtualmachineimagebuilder.VirtualNetworkConfig{ + SubnetID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet_name/subnets/subnet_name"), + }, + }, + }, + }, 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.ImageTemplate = armvirtualmachineimagebuilder.ImageTemplate{ + // Name: to.Ptr("myImageTemplate"), + // Type: to.Ptr("Microsoft.VirtualMachineImages/imageTemplate"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.VirtualMachineImages/imageTemplates/myImageTemplate"), + // Location: to.Ptr("westus"), + // Identity: &armvirtualmachineimagebuilder.ImageTemplateIdentity{ + // Type: to.Ptr(armvirtualmachineimagebuilder.ResourceIdentityTypeUserAssigned), + // UserAssignedIdentities: map[string]*armvirtualmachineimagebuilder.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity_1": &armvirtualmachineimagebuilder.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Properties: &armvirtualmachineimagebuilder.ImageTemplateProperties{ + // Customize: []armvirtualmachineimagebuilder.ImageTemplateCustomizerClassification{ + // &armvirtualmachineimagebuilder.ImageTemplateShellCustomizer{ + // Name: to.Ptr("Shell Customizer Example"), + // Type: to.Ptr("Shell"), + // ScriptURI: to.Ptr("https://example.com/path/to/script.sh"), + // }}, + // Distribute: []armvirtualmachineimagebuilder.ImageTemplateDistributorClassification{ + // &armvirtualmachineimagebuilder.ImageTemplateManagedImageDistributor{ + // Type: to.Ptr("ManagedImage"), + // ArtifactTags: map[string]*string{ + // "tagName": to.Ptr("value"), + // }, + // RunOutputName: to.Ptr("image_it_pir_1"), + // ImageID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/images/image_it_1"), + // Location: to.Ptr("1_location"), + // }}, + // Source: &armvirtualmachineimagebuilder.ImageTemplateManagedImageSource{ + // Type: to.Ptr("ManagedImage"), + // ImageID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Compute/images/source_image"), + // }, + // VMProfile: &armvirtualmachineimagebuilder.ImageTemplateVMProfile{ + // OSDiskSizeGB: to.Ptr[int32](64), + // VMSize: to.Ptr("Standard_D2s_v3"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/078b90617e5e08137d0395963bd4119f4561a910/specification/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/CreateImageTemplateWindows.json +func ExampleVirtualMachineImageTemplatesClient_BeginCreateOrUpdate_createAnImageTemplateForWindows() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualmachineimagebuilder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachineImageTemplatesClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myImageTemplate", armvirtualmachineimagebuilder.ImageTemplate{ + Location: to.Ptr("westus"), + Tags: map[string]*string{ + "imagetemplate_tag1": to.Ptr("IT_T1"), + "imagetemplate_tag2": to.Ptr("IT_T2"), + }, + Identity: &armvirtualmachineimagebuilder.ImageTemplateIdentity{ + Type: to.Ptr(armvirtualmachineimagebuilder.ResourceIdentityTypeUserAssigned), + UserAssignedIdentities: map[string]*armvirtualmachineimagebuilder.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties{ + "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity_1": {}, + }, + }, + Properties: &armvirtualmachineimagebuilder.ImageTemplateProperties{ + Customize: []armvirtualmachineimagebuilder.ImageTemplateCustomizerClassification{ + &armvirtualmachineimagebuilder.ImageTemplatePowerShellCustomizer{ + Name: to.Ptr("PowerShell (inline) Customizer Example"), + Type: to.Ptr("PowerShell"), + Inline: []*string{ + to.Ptr("Powershell command-1"), + to.Ptr("Powershell command-2"), + to.Ptr("Powershell command-3")}, + }, + &armvirtualmachineimagebuilder.ImageTemplatePowerShellCustomizer{ + Name: to.Ptr("PowerShell (inline) Customizer Elevated user Example"), + Type: to.Ptr("PowerShell"), + Inline: []*string{ + to.Ptr("Powershell command-1"), + to.Ptr("Powershell command-2"), + to.Ptr("Powershell command-3")}, + RunElevated: to.Ptr(true), + }, + &armvirtualmachineimagebuilder.ImageTemplatePowerShellCustomizer{ + Name: to.Ptr("PowerShell (inline) Customizer Elevated Local System user Example"), + Type: to.Ptr("PowerShell"), + Inline: []*string{ + to.Ptr("Powershell command-1"), + to.Ptr("Powershell command-2"), + to.Ptr("Powershell command-3")}, + RunAsSystem: to.Ptr(true), + RunElevated: to.Ptr(true), + }, + &armvirtualmachineimagebuilder.ImageTemplatePowerShellCustomizer{ + Name: to.Ptr("PowerShell (script) Customizer Example"), + Type: to.Ptr("PowerShell"), + ScriptURI: to.Ptr("https://example.com/path/to/script.ps1"), + ValidExitCodes: []*int32{ + to.Ptr[int32](0), + to.Ptr[int32](1)}, + }, + &armvirtualmachineimagebuilder.ImageTemplatePowerShellCustomizer{ + Name: to.Ptr("PowerShell (script) Customizer Elevated Local System user Example"), + Type: to.Ptr("PowerShell"), + RunElevated: to.Ptr(true), + ScriptURI: to.Ptr("https://example.com/path/to/script.ps1"), + ValidExitCodes: []*int32{ + to.Ptr[int32](0), + to.Ptr[int32](1)}, + }, + &armvirtualmachineimagebuilder.ImageTemplatePowerShellCustomizer{ + Name: to.Ptr("PowerShell (script) Customizer Elevated Local System user Example"), + Type: to.Ptr("PowerShell"), + RunAsSystem: to.Ptr(true), + RunElevated: to.Ptr(true), + ScriptURI: to.Ptr("https://example.com/path/to/script.ps1"), + ValidExitCodes: []*int32{ + to.Ptr[int32](0), + to.Ptr[int32](1)}, + }, + &armvirtualmachineimagebuilder.ImageTemplateRestartCustomizer{ + Name: to.Ptr("Restart Customizer Example"), + Type: to.Ptr("WindowsRestart"), + RestartCheckCommand: to.Ptr("powershell -command \"& {Write-Output 'restarted.'}\""), + RestartCommand: to.Ptr("shutdown /f /r /t 0 /c \"packer restart\""), + RestartTimeout: to.Ptr("10m"), + }, + &armvirtualmachineimagebuilder.ImageTemplateWindowsUpdateCustomizer{ + Name: to.Ptr("Windows Update Customizer Example"), + Type: to.Ptr("WindowsUpdate"), + Filters: []*string{ + to.Ptr("$_.BrowseOnly")}, + SearchCriteria: to.Ptr("BrowseOnly=0 and IsInstalled=0"), + UpdateLimit: to.Ptr[int32](100), + }}, + Distribute: []armvirtualmachineimagebuilder.ImageTemplateDistributorClassification{ + &armvirtualmachineimagebuilder.ImageTemplateManagedImageDistributor{ + Type: to.Ptr("ManagedImage"), + ArtifactTags: map[string]*string{ + "tagName": to.Ptr("value"), + }, + RunOutputName: to.Ptr("image_it_pir_1"), + ImageID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/images/image_it_1"), + Location: to.Ptr("1_location"), + }}, + Source: &armvirtualmachineimagebuilder.ImageTemplateManagedImageSource{ + Type: to.Ptr("ManagedImage"), + ImageID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Compute/images/source_image"), + }, + VMProfile: &armvirtualmachineimagebuilder.ImageTemplateVMProfile{ + OSDiskSizeGB: to.Ptr[int32](64), + VMSize: to.Ptr("Standard_D2s_v3"), + VnetConfig: &armvirtualmachineimagebuilder.VirtualNetworkConfig{ + SubnetID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet_name/subnets/subnet_name"), + }, + }, + }, + }, 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.ImageTemplate = armvirtualmachineimagebuilder.ImageTemplate{ + // Name: to.Ptr("myImageTemplate"), + // Type: to.Ptr("Microsoft.VirtualMachineImages/imageTemplate"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.VirtualMachineImages/imageTemplates/myImageTemplate"), + // Location: to.Ptr("westus"), + // Identity: &armvirtualmachineimagebuilder.ImageTemplateIdentity{ + // Type: to.Ptr(armvirtualmachineimagebuilder.ResourceIdentityTypeUserAssigned), + // UserAssignedIdentities: map[string]*armvirtualmachineimagebuilder.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity_1": &armvirtualmachineimagebuilder.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Properties: &armvirtualmachineimagebuilder.ImageTemplateProperties{ + // Customize: []armvirtualmachineimagebuilder.ImageTemplateCustomizerClassification{ + // &armvirtualmachineimagebuilder.ImageTemplatePowerShellCustomizer{ + // Name: to.Ptr("PowerShell (inline) Customizer Example"), + // Type: to.Ptr("PowerShell"), + // Inline: []*string{ + // to.Ptr("Powershell command-1"), + // to.Ptr("Powershell command-2"), + // to.Ptr("Powershell command-3")}, + // RunAsSystem: to.Ptr(false), + // RunElevated: to.Ptr(false), + // }, + // &armvirtualmachineimagebuilder.ImageTemplatePowerShellCustomizer{ + // Name: to.Ptr("PowerShell (inline) Customizer Elevated user Example"), + // Type: to.Ptr("PowerShell"), + // Inline: []*string{ + // to.Ptr("Powershell command-1"), + // to.Ptr("Powershell command-2"), + // to.Ptr("Powershell command-3")}, + // RunAsSystem: to.Ptr(false), + // RunElevated: to.Ptr(true), + // }, + // &armvirtualmachineimagebuilder.ImageTemplatePowerShellCustomizer{ + // Name: to.Ptr("PowerShell (inline) Customizer Elevated Local System user Example"), + // Type: to.Ptr("PowerShell"), + // Inline: []*string{ + // to.Ptr("Powershell command-1"), + // to.Ptr("Powershell command-2"), + // to.Ptr("Powershell command-3")}, + // RunAsSystem: to.Ptr(true), + // RunElevated: to.Ptr(true), + // }, + // &armvirtualmachineimagebuilder.ImageTemplatePowerShellCustomizer{ + // Name: to.Ptr("PowerShell (script) Customizer Example"), + // Type: to.Ptr("PowerShell"), + // RunAsSystem: to.Ptr(false), + // RunElevated: to.Ptr(false), + // ScriptURI: to.Ptr("https://example.com/path/to/script.ps1"), + // ValidExitCodes: []*int32{ + // to.Ptr[int32](0), + // to.Ptr[int32](1)}, + // }, + // &armvirtualmachineimagebuilder.ImageTemplatePowerShellCustomizer{ + // Name: to.Ptr("PowerShell (script) Customizer Elevated Local System user Example"), + // Type: to.Ptr("PowerShell"), + // RunAsSystem: to.Ptr(false), + // RunElevated: to.Ptr(true), + // ScriptURI: to.Ptr("https://example.com/path/to/script.ps1"), + // ValidExitCodes: []*int32{ + // to.Ptr[int32](0), + // to.Ptr[int32](1)}, + // }, + // &armvirtualmachineimagebuilder.ImageTemplatePowerShellCustomizer{ + // Name: to.Ptr("PowerShell (script) Customizer Elevated Local System user Example"), + // Type: to.Ptr("PowerShell"), + // RunAsSystem: to.Ptr(true), + // RunElevated: to.Ptr(true), + // ScriptURI: to.Ptr("https://example.com/path/to/script.ps1"), + // ValidExitCodes: []*int32{ + // to.Ptr[int32](0), + // to.Ptr[int32](1)}, + // }, + // &armvirtualmachineimagebuilder.ImageTemplateRestartCustomizer{ + // Name: to.Ptr("Restart Customizer Example"), + // Type: to.Ptr("WindowsRestart"), + // RestartCheckCommand: to.Ptr("powershell -command \"& {Write-Output 'restarted.'}\""), + // RestartCommand: to.Ptr("shutdown /f /r /t 0 /c \"packer restart\""), + // RestartTimeout: to.Ptr("10m"), + // }, + // &armvirtualmachineimagebuilder.ImageTemplateWindowsUpdateCustomizer{ + // Name: to.Ptr("Windows Update Customizer Example"), + // Type: to.Ptr("WindowsUpdate"), + // Filters: []*string{ + // to.Ptr("$_.BrowseOnly")}, + // SearchCriteria: to.Ptr("BrowseOnly=0 and IsInstalled=0"), + // UpdateLimit: to.Ptr[int32](100), + // }}, + // Distribute: []armvirtualmachineimagebuilder.ImageTemplateDistributorClassification{ + // &armvirtualmachineimagebuilder.ImageTemplateManagedImageDistributor{ + // Type: to.Ptr("ManagedImage"), + // ArtifactTags: map[string]*string{ + // "tagName": to.Ptr("value"), + // }, + // RunOutputName: to.Ptr("image_it_pir_1"), + // ImageID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/images/image_it_1"), + // Location: to.Ptr("1_location"), + // }}, + // Source: &armvirtualmachineimagebuilder.ImageTemplateManagedImageSource{ + // Type: to.Ptr("ManagedImage"), + // ImageID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Compute/images/source_image"), + // }, + // VMProfile: &armvirtualmachineimagebuilder.ImageTemplateVMProfile{ + // OSDiskSizeGB: to.Ptr[int32](64), + // VMSize: to.Ptr("Standard_D2s_v3"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/078b90617e5e08137d0395963bd4119f4561a910/specification/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/UpdateImageTemplateToRemoveIdentities.json +func ExampleVirtualMachineImageTemplatesClient_BeginUpdate_removeIdentitiesForAnImageTemplate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualmachineimagebuilder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachineImageTemplatesClient().BeginUpdate(ctx, "myResourceGroup", "myImageTemplate", armvirtualmachineimagebuilder.ImageTemplateUpdateParameters{ + Identity: &armvirtualmachineimagebuilder.ImageTemplateIdentity{ + Type: to.Ptr(armvirtualmachineimagebuilder.ResourceIdentityTypeNone), + }, + }, 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.ImageTemplate = armvirtualmachineimagebuilder.ImageTemplate{ + // Name: to.Ptr("myImageTemplate"), + // Type: to.Ptr("Microsoft.VirtualMachineImages/imageTemplate"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.VirtualMachineImages/imageTemplates/myImageTemplate"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "new-tag": to.Ptr("new-value"), + // }, + // Identity: &armvirtualmachineimagebuilder.ImageTemplateIdentity{ + // Type: to.Ptr(armvirtualmachineimagebuilder.ResourceIdentityTypeNone), + // }, + // Properties: &armvirtualmachineimagebuilder.ImageTemplateProperties{ + // Customize: []armvirtualmachineimagebuilder.ImageTemplateCustomizerClassification{ + // &armvirtualmachineimagebuilder.ImageTemplateShellCustomizer{ + // Name: to.Ptr("Shell customization example"), + // Type: to.Ptr("Shell"), + // ScriptURI: to.Ptr("https://example.com/path/to/script.sh"), + // }}, + // Distribute: []armvirtualmachineimagebuilder.ImageTemplateDistributorClassification{ + // &armvirtualmachineimagebuilder.ImageTemplateManagedImageDistributor{ + // Type: to.Ptr("ManagedImage"), + // ArtifactTags: map[string]*string{ + // "tagName": to.Ptr("value"), + // }, + // RunOutputName: to.Ptr("image_it_pir_1"), + // ImageID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/images/image_it_1"), + // Location: to.Ptr("1_location"), + // }}, + // Source: &armvirtualmachineimagebuilder.ImageTemplateManagedImageSource{ + // Type: to.Ptr("ManagedImage"), + // ImageID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/source_rg/providers/Microsoft.Compute/images/source_image"), + // }, + // VMProfile: &armvirtualmachineimagebuilder.ImageTemplateVMProfile{ + // OSDiskSizeGB: to.Ptr[int32](64), + // VMSize: to.Ptr("Standard_D2s_v3"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/078b90617e5e08137d0395963bd4119f4561a910/specification/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/UpdateImageTemplateTags.json +func ExampleVirtualMachineImageTemplatesClient_BeginUpdate_updateTheTagsForAnImageTemplate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualmachineimagebuilder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachineImageTemplatesClient().BeginUpdate(ctx, "myResourceGroup", "myImageTemplate", armvirtualmachineimagebuilder.ImageTemplateUpdateParameters{ + Tags: map[string]*string{ + "new-tag": to.Ptr("new-value"), + }, + }, 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.ImageTemplate = armvirtualmachineimagebuilder.ImageTemplate{ + // Name: to.Ptr("myImageTemplate"), + // Type: to.Ptr("Microsoft.VirtualMachineImages/imageTemplate"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.VirtualMachineImages/imageTemplates/myImageTemplate"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "new-tag": to.Ptr("new-value"), + // }, + // Identity: &armvirtualmachineimagebuilder.ImageTemplateIdentity{ + // Type: to.Ptr(armvirtualmachineimagebuilder.ResourceIdentityTypeUserAssigned), + // UserAssignedIdentities: map[string]*armvirtualmachineimagebuilder.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity_1": &armvirtualmachineimagebuilder.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Properties: &armvirtualmachineimagebuilder.ImageTemplateProperties{ + // Customize: []armvirtualmachineimagebuilder.ImageTemplateCustomizerClassification{ + // &armvirtualmachineimagebuilder.ImageTemplateShellCustomizer{ + // Name: to.Ptr("Shell customization example"), + // Type: to.Ptr("Shell"), + // ScriptURI: to.Ptr("https://example.com/path/to/script.sh"), + // }}, + // Distribute: []armvirtualmachineimagebuilder.ImageTemplateDistributorClassification{ + // &armvirtualmachineimagebuilder.ImageTemplateManagedImageDistributor{ + // Type: to.Ptr("ManagedImage"), + // ArtifactTags: map[string]*string{ + // "tagName": to.Ptr("value"), + // }, + // RunOutputName: to.Ptr("image_it_pir_1"), + // ImageID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/images/image_it_1"), + // Location: to.Ptr("1_location"), + // }}, + // Source: &armvirtualmachineimagebuilder.ImageTemplateManagedImageSource{ + // Type: to.Ptr("ManagedImage"), + // ImageID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/source_rg/providers/Microsoft.Compute/images/source_image"), + // }, + // VMProfile: &armvirtualmachineimagebuilder.ImageTemplateVMProfile{ + // OSDiskSizeGB: to.Ptr[int32](64), + // VMSize: to.Ptr("Standard_D2s_v3"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/078b90617e5e08137d0395963bd4119f4561a910/specification/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/GetImageTemplate.json +func ExampleVirtualMachineImageTemplatesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualmachineimagebuilder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewVirtualMachineImageTemplatesClient().Get(ctx, "myResourceGroup", "myImageTemplate", 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.ImageTemplate = armvirtualmachineimagebuilder.ImageTemplate{ + // Name: to.Ptr("myImageTemplate"), + // Type: to.Ptr("Microsoft.VirtualMachineImages/imageTemplate"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.VirtualMachineImages/imageTemplates/myImageTemplate"), + // Location: to.Ptr("westus"), + // Identity: &armvirtualmachineimagebuilder.ImageTemplateIdentity{ + // Type: to.Ptr(armvirtualmachineimagebuilder.ResourceIdentityTypeUserAssigned), + // UserAssignedIdentities: map[string]*armvirtualmachineimagebuilder.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity_1": &armvirtualmachineimagebuilder.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Properties: &armvirtualmachineimagebuilder.ImageTemplateProperties{ + // Customize: []armvirtualmachineimagebuilder.ImageTemplateCustomizerClassification{ + // &armvirtualmachineimagebuilder.ImageTemplateShellCustomizer{ + // Name: to.Ptr("Shell Customizer Example"), + // Type: to.Ptr("Shell"), + // ScriptURI: to.Ptr("https://example.com/path/to/script.sh"), + // }}, + // Distribute: []armvirtualmachineimagebuilder.ImageTemplateDistributorClassification{ + // &armvirtualmachineimagebuilder.ImageTemplateManagedImageDistributor{ + // Type: to.Ptr("ManagedImage"), + // ArtifactTags: map[string]*string{ + // "tagName": to.Ptr("value"), + // }, + // RunOutputName: to.Ptr("image_it_pir_1"), + // ImageID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/images/image_it_1"), + // Location: to.Ptr("1_location"), + // }}, + // Source: &armvirtualmachineimagebuilder.ImageTemplateManagedImageSource{ + // Type: to.Ptr("ManagedImage"), + // ImageID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/source_rg/providers/Microsoft.Compute/images/source_image"), + // }, + // VMProfile: &armvirtualmachineimagebuilder.ImageTemplateVMProfile{ + // OSDiskSizeGB: to.Ptr[int32](64), + // VMSize: to.Ptr("Standard_D2s_v3"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/078b90617e5e08137d0395963bd4119f4561a910/specification/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/DeleteImageTemplate.json +func ExampleVirtualMachineImageTemplatesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualmachineimagebuilder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachineImageTemplatesClient().BeginDelete(ctx, "myResourceGroup", "myImageTemplate", 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/078b90617e5e08137d0395963bd4119f4561a910/specification/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/RunImageTemplate.json +func ExampleVirtualMachineImageTemplatesClient_BeginRun() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualmachineimagebuilder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachineImageTemplatesClient().BeginRun(ctx, "myResourceGroup", "myImageTemplate", 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/078b90617e5e08137d0395963bd4119f4561a910/specification/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/CancelImageBuild.json +func ExampleVirtualMachineImageTemplatesClient_BeginCancel() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualmachineimagebuilder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachineImageTemplatesClient().BeginCancel(ctx, "myResourceGroup", "myImageTemplate", 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/078b90617e5e08137d0395963bd4119f4561a910/specification/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/ListRunOutputs.json +func ExampleVirtualMachineImageTemplatesClient_NewListRunOutputsPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualmachineimagebuilder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewVirtualMachineImageTemplatesClient().NewListRunOutputsPager("myResourceGroup", "myImageTemplate", 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.RunOutputCollection = armvirtualmachineimagebuilder.RunOutputCollection{ + // Value: []*armvirtualmachineimagebuilder.RunOutput{ + // { + // Name: to.Ptr("myManagedImageOutput"), + // Type: to.Ptr("Microsoft.VirtualMachineImages/imageTemplates/runOutputs"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourcegroups/myResourceGroup/providers/Microsoft.VirtualMachineImages/imageTemplates/myImageTemplate/runOutputs/myManagedImageOutput"), + // Properties: &armvirtualmachineimagebuilder.RunOutputProperties{ + // ArtifactID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/images/output_managed_image"), + // ProvisioningState: to.Ptr(armvirtualmachineimagebuilder.ProvisioningStateSucceeded), + // }, + // }, + // { + // Name: to.Ptr("mySharedImageOutput"), + // Type: to.Ptr("Microsoft.VirtualMachineImages/imageTemplates/runOutputs"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourcegroups/myResourceGroup/providers/Microsoft.VirtualMachineImages/imageTemplates/myImageTemplate/runOutputs/mySharedImageOutput"), + // Properties: &armvirtualmachineimagebuilder.RunOutputProperties{ + // ArtifactID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/galleries/Gallery1/images/SharedImageOutput/imageversions/1.2.3"), + // ProvisioningState: to.Ptr(armvirtualmachineimagebuilder.ProvisioningStateSucceeded), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/078b90617e5e08137d0395963bd4119f4561a910/specification/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/GetRunOutput.json +func ExampleVirtualMachineImageTemplatesClient_GetRunOutput() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvirtualmachineimagebuilder.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewVirtualMachineImageTemplatesClient().GetRunOutput(ctx, "myResourceGroup", "myImageTemplate", "myManagedImageOutput", 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.RunOutput = armvirtualmachineimagebuilder.RunOutput{ + // Name: to.Ptr("myManagedImageOutput"), + // Type: to.Ptr("Microsoft.VirtualMachineImages/imageTemplates/runOutputs"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourcegroups/myResourceGroup/providers/Microsoft.VirtualMachineImages/imageTemplates/myImageTemplate/runOutputs/myManagedImageOutput"), + // Properties: &armvirtualmachineimagebuilder.RunOutputProperties{ + // ArtifactID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/images/output_managed_image"), + // ProvisioningState: to.Ptr(armvirtualmachineimagebuilder.ProvisioningStateSucceeded), + // }, + // } +} diff --git a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/ze_generated_example_operations_client_test.go deleted file mode 100644 index 211587f7d621..000000000000 --- a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/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 armvirtualmachineimagebuilder_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/OperationsList.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvirtualmachineimagebuilder.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/virtualmachineimagebuilder/armvirtualmachineimagebuilder/ze_generated_example_virtualmachineimagetemplates_client_test.go b/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/ze_generated_example_virtualmachineimagetemplates_client_test.go deleted file mode 100644 index 6d1faa89d596..000000000000 --- a/sdk/resourcemanager/virtualmachineimagebuilder/armvirtualmachineimagebuilder/ze_generated_example_virtualmachineimagetemplates_client_test.go +++ /dev/null @@ -1,309 +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 armvirtualmachineimagebuilder_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/virtualmachineimagebuilder/armvirtualmachineimagebuilder" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/ListImageTemplates.json -func ExampleVirtualMachineImageTemplatesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvirtualmachineimagebuilder.NewVirtualMachineImageTemplatesClient("{subscription-id}", 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/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/ListImageTemplatesByRg.json -func ExampleVirtualMachineImageTemplatesClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvirtualmachineimagebuilder.NewVirtualMachineImageTemplatesClient("{subscription-id}", 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/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/CreateImageTemplateLinux.json -func ExampleVirtualMachineImageTemplatesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvirtualmachineimagebuilder.NewVirtualMachineImageTemplatesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "myResourceGroup", - "myImageTemplate", - armvirtualmachineimagebuilder.ImageTemplate{ - Location: to.Ptr("westus"), - Tags: map[string]*string{ - "imagetemplate_tag1": to.Ptr("IT_T1"), - "imagetemplate_tag2": to.Ptr("IT_T2"), - }, - Identity: &armvirtualmachineimagebuilder.ImageTemplateIdentity{ - Type: to.Ptr(armvirtualmachineimagebuilder.ResourceIdentityTypeUserAssigned), - UserAssignedIdentities: map[string]*armvirtualmachineimagebuilder.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties{ - "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity_1": {}, - }, - }, - Properties: &armvirtualmachineimagebuilder.ImageTemplateProperties{ - Customize: []armvirtualmachineimagebuilder.ImageTemplateCustomizerClassification{ - &armvirtualmachineimagebuilder.ImageTemplateShellCustomizer{ - Name: to.Ptr("Shell Customizer Example"), - Type: to.Ptr("Shell"), - ScriptURI: to.Ptr("https://example.com/path/to/script.sh"), - }}, - Distribute: []armvirtualmachineimagebuilder.ImageTemplateDistributorClassification{ - &armvirtualmachineimagebuilder.ImageTemplateManagedImageDistributor{ - Type: to.Ptr("ManagedImage"), - ArtifactTags: map[string]*string{ - "tagName": to.Ptr("value"), - }, - RunOutputName: to.Ptr("image_it_pir_1"), - ImageID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/images/image_it_1"), - Location: to.Ptr("1_location"), - }}, - Source: &armvirtualmachineimagebuilder.ImageTemplateManagedImageSource{ - Type: to.Ptr("ManagedImage"), - ImageID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Compute/images/source_image"), - }, - VMProfile: &armvirtualmachineimagebuilder.ImageTemplateVMProfile{ - OSDiskSizeGB: to.Ptr[int32](64), - VMSize: to.Ptr("Standard_D2s_v3"), - VnetConfig: &armvirtualmachineimagebuilder.VirtualNetworkConfig{ - SubnetID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet_name/subnets/subnet_name"), - }, - }, - }, - }, - 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/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/UpdateImageTemplateToRemoveIdentities.json -func ExampleVirtualMachineImageTemplatesClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvirtualmachineimagebuilder.NewVirtualMachineImageTemplatesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, - "myResourceGroup", - "myImageTemplate", - armvirtualmachineimagebuilder.ImageTemplateUpdateParameters{ - Identity: &armvirtualmachineimagebuilder.ImageTemplateIdentity{ - Type: to.Ptr(armvirtualmachineimagebuilder.ResourceIdentityTypeNone), - }, - }, - 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/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/GetImageTemplate.json -func ExampleVirtualMachineImageTemplatesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvirtualmachineimagebuilder.NewVirtualMachineImageTemplatesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "myResourceGroup", - "myImageTemplate", - 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/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/DeleteImageTemplate.json -func ExampleVirtualMachineImageTemplatesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvirtualmachineimagebuilder.NewVirtualMachineImageTemplatesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "myResourceGroup", - "myImageTemplate", - 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/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/RunImageTemplate.json -func ExampleVirtualMachineImageTemplatesClient_BeginRun() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvirtualmachineimagebuilder.NewVirtualMachineImageTemplatesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginRun(ctx, - "myResourceGroup", - "myImageTemplate", - 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/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/CancelImageBuild.json -func ExampleVirtualMachineImageTemplatesClient_BeginCancel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvirtualmachineimagebuilder.NewVirtualMachineImageTemplatesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCancel(ctx, - "myResourceGroup", - "myImageTemplate", - 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/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/ListRunOutputs.json -func ExampleVirtualMachineImageTemplatesClient_NewListRunOutputsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvirtualmachineimagebuilder.NewVirtualMachineImageTemplatesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListRunOutputsPager("myResourceGroup", - "myImageTemplate", - 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/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/examples/GetRunOutput.json -func ExampleVirtualMachineImageTemplatesClient_GetRunOutput() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvirtualmachineimagebuilder.NewVirtualMachineImageTemplatesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetRunOutput(ctx, - "myResourceGroup", - "myImageTemplate", - "myManagedImageOutput", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/visualstudio/armvisualstudio/CHANGELOG.md b/sdk/resourcemanager/visualstudio/armvisualstudio/CHANGELOG.md index 1f433f65359f..3697da153dcf 100644 --- a/sdk/resourcemanager/visualstudio/armvisualstudio/CHANGELOG.md +++ b/sdk/resourcemanager/visualstudio/armvisualstudio/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 0.5.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 0.4.0 (2022-05-18) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/visualstudio/armvisualstudio` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 0.4.0, which contains breaking changes. diff --git a/sdk/resourcemanager/visualstudio/armvisualstudio/README.md b/sdk/resourcemanager/visualstudio/armvisualstudio/README.md index 9b986f438334..06f2cba30909 100644 --- a/sdk/resourcemanager/visualstudio/armvisualstudio/README.md +++ b/sdk/resourcemanager/visualstudio/armvisualstudio/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 Visual Studio 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 Visual Studio 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 := armvisualstudio.NewAccountsClient(, cred, nil) +clientFactory, err := armvisualstudio.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 := armvisualstudio.NewAccountsClient(, cred, &options) +clientFactory, err := armvisualstudio.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.NewProjectsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_accounts_client.go b/sdk/resourcemanager/visualstudio/armvisualstudio/accounts_client.go similarity index 85% rename from sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_accounts_client.go rename to sdk/resourcemanager/visualstudio/armvisualstudio/accounts_client.go index 7479eeb553d5..f386938453e3 100644 --- a/sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_accounts_client.go +++ b/sdk/resourcemanager/visualstudio/armvisualstudio/accounts_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 armvisualstudio @@ -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 ( // 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 identifier. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription identifier. +// - 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 } @@ -57,16 +47,17 @@ func NewAccountsClient(subscriptionID string, credential azcore.TokenCredential, // CheckNameAvailability - Checks if the specified Visual Studio Team Services account name is available. Resource name can // be either an account name or an account name and PUID. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2014-04-01-preview -// body - Parameters describing the name to check availability for. -// options - AccountsClientCheckNameAvailabilityOptions contains the optional parameters for the AccountsClient.CheckNameAvailability -// method. +// - body - Parameters describing the name to check availability for. +// - options - AccountsClientCheckNameAvailabilityOptions contains the optional parameters for the AccountsClient.CheckNameAvailability +// method. func (client *AccountsClient) CheckNameAvailability(ctx context.Context, body CheckNameAvailabilityParameter, options *AccountsClientCheckNameAvailabilityOptions) (AccountsClientCheckNameAvailabilityResponse, error) { req, err := client.checkNameAvailabilityCreateRequest(ctx, body, options) if err != nil { return AccountsClientCheckNameAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientCheckNameAvailabilityResponse{}, err } @@ -83,7 +74,7 @@ func (client *AccountsClient) checkNameAvailabilityCreateRequest(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 } @@ -105,17 +96,18 @@ func (client *AccountsClient) checkNameAvailabilityHandleResponse(resp *http.Res // CreateOrUpdate - Creates or updates a Visual Studio Team Services account resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2014-04-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// resourceName - Name of the resource. -// body - The request data. -// options - AccountsClientCreateOrUpdateOptions contains the optional parameters for the AccountsClient.CreateOrUpdate method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - resourceName - Name of the resource. +// - body - The request data. +// - options - AccountsClientCreateOrUpdateOptions contains the optional parameters for the AccountsClient.CreateOrUpdate method. func (client *AccountsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, body AccountResourceRequest, options *AccountsClientCreateOrUpdateOptions) (AccountsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, resourceName, body, options) if err != nil { return AccountsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientCreateOrUpdateResponse{}, err } @@ -140,7 +132,7 @@ func (client *AccountsClient) createOrUpdateCreateRequest(ctx context.Context, r return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -162,16 +154,17 @@ func (client *AccountsClient) createOrUpdateHandleResponse(resp *http.Response) // Delete - Deletes a Visual Studio Team Services account resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2014-04-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// resourceName - Name of the resource. -// options - AccountsClientDeleteOptions contains the optional parameters for the AccountsClient.Delete method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - resourceName - Name of the resource. +// - options - AccountsClientDeleteOptions contains the optional parameters for the AccountsClient.Delete method. func (client *AccountsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, options *AccountsClientDeleteOptions) (AccountsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceName, options) if err != nil { return AccountsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientDeleteResponse{}, err } @@ -196,7 +189,7 @@ func (client *AccountsClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -208,16 +201,17 @@ func (client *AccountsClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Gets the Visual Studio Team Services account resource details. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2014-04-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// resourceName - Name of the resource. -// options - AccountsClientGetOptions contains the optional parameters for the AccountsClient.Get method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - resourceName - Name of the resource. +// - options - AccountsClientGetOptions contains the optional parameters for the AccountsClient.Get method. func (client *AccountsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, options *AccountsClientGetOptions) (AccountsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, resourceName, 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 } @@ -242,7 +236,7 @@ func (client *AccountsClient) getCreateRequest(ctx context.Context, resourceGrou 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 } @@ -265,16 +259,17 @@ func (client *AccountsClient) getHandleResponse(resp *http.Response) (AccountsCl // ListByResourceGroup - Gets all Visual Studio Team Services account resources under the resource group linked to the specified // Azure subscription. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2014-04-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// options - AccountsClientListByResourceGroupOptions contains the optional parameters for the AccountsClient.ListByResourceGroup -// method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - options - AccountsClientListByResourceGroupOptions contains the optional parameters for the AccountsClient.ListByResourceGroup +// method. func (client *AccountsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, options *AccountsClientListByResourceGroupOptions) (AccountsClientListByResourceGroupResponse, error) { req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) 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 } @@ -295,7 +290,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 } @@ -317,17 +312,18 @@ func (client *AccountsClient) listByResourceGroupHandleResponse(resp *http.Respo // Update - Updates tags for Visual Studio Team Services account resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2014-04-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// resourceName - Name of the resource. -// body - The request data. -// options - AccountsClientUpdateOptions contains the optional parameters for the AccountsClient.Update method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - resourceName - Name of the resource. +// - body - The request data. +// - options - AccountsClientUpdateOptions contains the optional parameters for the AccountsClient.Update method. func (client *AccountsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, body AccountTagRequest, options *AccountsClientUpdateOptions) (AccountsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, resourceName, body, options) if err != nil { return AccountsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientUpdateResponse{}, err } @@ -352,7 +348,7 @@ func (client *AccountsClient) updateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/visualstudio/armvisualstudio/accounts_client_example_test.go b/sdk/resourcemanager/visualstudio/armvisualstudio/accounts_client_example_test.go new file mode 100644 index 000000000000..9ad5c4617975 --- /dev/null +++ b/sdk/resourcemanager/visualstudio/armvisualstudio/accounts_client_example_test.go @@ -0,0 +1,199 @@ +//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 armvisualstudio_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/visualstudio/armvisualstudio" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/CheckNameAvailability.json +func ExampleAccountsClient_CheckNameAvailability() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvisualstudio.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().CheckNameAvailability(ctx, armvisualstudio.CheckNameAvailabilityParameter{ + ResourceName: to.Ptr("ExampleName"), + ResourceType: to.Ptr("Account"), + }, 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.CheckNameAvailabilityResult = armvisualstudio.CheckNameAvailabilityResult{ + // NameAvailable: to.Ptr(true), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/GetResources_List.json +func ExampleAccountsClient_ListByResourceGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvisualstudio.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().ListByResourceGroup(ctx, "VS-Example-Group", 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.AccountResourceListResult = armvisualstudio.AccountResourceListResult{ + // Value: []*armvisualstudio.AccountResource{ + // { + // Name: to.Ptr("VS-Example-Group"), + // Type: to.Ptr("Microsoft.VisualStudio/account"), + // ID: to.Ptr("/subscriptions/0de7f055-dbea-498d-8e9e-da287eedca90/resourceGroups/VS-Example-Group/providers/Microsoft.VisualStudio/account/Example"), + // Location: to.Ptr("Central US"), + // Tags: map[string]*string{ + // }, + // Properties: map[string]*string{ + // "AccountURL": to.Ptr(""), + // }, + // }}, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/CreateResource.json +func ExampleAccountsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvisualstudio.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().CreateOrUpdate(ctx, "VS-Example-Group", "Example", armvisualstudio.AccountResourceRequest{ + AccountName: to.Ptr("Example"), + Location: to.Ptr("Central US"), + OperationType: to.Ptr(armvisualstudio.AccountResourceRequestOperationTypeCreate), + Properties: map[string]*string{}, + Tags: map[string]*string{}, + }, 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.AccountResource = armvisualstudio.AccountResource{ + // Name: to.Ptr("VS-Example-Group"), + // Type: to.Ptr("Microsoft.VisualStudio/account"), + // ID: to.Ptr("/subscriptions/0de7f055-dbea-498d-8e9e-da287eedca90/resourceGroups/VS-Example-Group/providers/Microsoft.VisualStudio/account/Example"), + // Location: to.Ptr("Central US"), + // Tags: map[string]*string{ + // }, + // Properties: map[string]*string{ + // "AccountURL": to.Ptr(""), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/DeleteResource.json +func ExampleAccountsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvisualstudio.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewAccountsClient().Delete(ctx, "VS-Example-Group", "Example", 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/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/GetResource.json +func ExampleAccountsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvisualstudio.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().Get(ctx, "VS-Example-Group", "Example", 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.AccountResource = armvisualstudio.AccountResource{ + // Name: to.Ptr("VS-Example-Group"), + // Type: to.Ptr("Microsoft.VisualStudio/account"), + // ID: to.Ptr("/subscriptions/0de7f055-dbea-498d-8e9e-da287eedca90/resourceGroups/VS-Example-Group/providers/Microsoft.VisualStudio/account/Example"), + // Location: to.Ptr("Central US"), + // Tags: map[string]*string{ + // }, + // Properties: map[string]*string{ + // "AccountURL": to.Ptr(""), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/UpdateTags.json +func ExampleAccountsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvisualstudio.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().Update(ctx, "VS-Example-Group", "Example", armvisualstudio.AccountTagRequest{ + Tags: map[string]*string{ + "tag1": to.Ptr("value1"), + }, + }, 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.AccountResource = armvisualstudio.AccountResource{ + // Name: to.Ptr("VS-Example-Group"), + // Type: to.Ptr("Microsoft.VisualStudio/account"), + // ID: to.Ptr("/subscriptions/0de7f055-dbea-498d-8e9e-da287eedca90/resourceGroups/VS-Example-Group/providers/Microsoft.VisualStudio/account/Example"), + // Location: to.Ptr("Central US"), + // Tags: map[string]*string{ + // }, + // Properties: map[string]*string{ + // "AccountURL": to.Ptr(""), + // }, + // } +} diff --git a/sdk/resourcemanager/visualstudio/armvisualstudio/autorest.md b/sdk/resourcemanager/visualstudio/armvisualstudio/autorest.md index 132f28211d7f..d16b2f998caf 100644 --- a/sdk/resourcemanager/visualstudio/armvisualstudio/autorest.md +++ b/sdk/resourcemanager/visualstudio/armvisualstudio/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/visualstudio/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/visualstudio/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.4.0 +module-version: 0.5.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/visualstudio/armvisualstudio/client_factory.go b/sdk/resourcemanager/visualstudio/armvisualstudio/client_factory.go new file mode 100644 index 000000000000..1cad6510cc20 --- /dev/null +++ b/sdk/resourcemanager/visualstudio/armvisualstudio/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 armvisualstudio + +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 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) NewAccountsClient() *AccountsClient { + subClient, _ := NewAccountsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewExtensionsClient() *ExtensionsClient { + subClient, _ := NewExtensionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewProjectsClient() *ProjectsClient { + subClient, _ := NewProjectsClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_constants.go b/sdk/resourcemanager/visualstudio/armvisualstudio/constants.go similarity index 97% rename from sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_constants.go rename to sdk/resourcemanager/visualstudio/armvisualstudio/constants.go index 899e0fdf95cc..875995c0d310 100644 --- a/sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_constants.go +++ b/sdk/resourcemanager/visualstudio/armvisualstudio/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 armvisualstudio const ( moduleName = "armvisualstudio" - moduleVersion = "v0.4.0" + moduleVersion = "v0.5.0" ) // AccountResourceRequestOperationType - The type of the operation. diff --git a/sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_extensions_client.go b/sdk/resourcemanager/visualstudio/armvisualstudio/extensions_client.go similarity index 83% rename from sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_extensions_client.go rename to sdk/resourcemanager/visualstudio/armvisualstudio/extensions_client.go index 6724e664dde2..5043280125b8 100644 --- a/sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_extensions_client.go +++ b/sdk/resourcemanager/visualstudio/armvisualstudio/extensions_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 armvisualstudio @@ -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 ( // ExtensionsClient contains the methods for the Extensions group. // Don't use this type directly, use NewExtensionsClient() instead. type ExtensionsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewExtensionsClient creates a new instance of ExtensionsClient with the specified values. -// subscriptionID - The Azure subscription identifier. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription identifier. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewExtensionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExtensionsClient, 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+".ExtensionsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ExtensionsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Create - Registers the extension with a Visual Studio Team Services account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2014-04-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// accountResourceName - The name of the Visual Studio Team Services account resource. -// extensionResourceName - The name of the extension. -// body - An object containing additional information related to the extension request. -// options - ExtensionsClientCreateOptions contains the optional parameters for the ExtensionsClient.Create method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - accountResourceName - The name of the Visual Studio Team Services account resource. +// - extensionResourceName - The name of the extension. +// - body - An object containing additional information related to the extension request. +// - options - ExtensionsClientCreateOptions contains the optional parameters for the ExtensionsClient.Create method. func (client *ExtensionsClient) Create(ctx context.Context, resourceGroupName string, accountResourceName string, extensionResourceName string, body ExtensionResourceRequest, options *ExtensionsClientCreateOptions) (ExtensionsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, accountResourceName, extensionResourceName, body, options) if err != nil { return ExtensionsClientCreateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExtensionsClientCreateResponse{}, err } @@ -96,7 +87,7 @@ func (client *ExtensionsClient) createCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter extensionResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{extensionResourceName}", url.PathEscape(extensionResourceName)) - 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 *ExtensionsClient) createHandleResponse(resp *http.Response) (Exten // Delete - Removes an extension resource registration for a Visual Studio Team Services account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2014-04-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// accountResourceName - The name of the Visual Studio Team Services account resource. -// extensionResourceName - The name of the extension. -// options - ExtensionsClientDeleteOptions contains the optional parameters for the ExtensionsClient.Delete method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - accountResourceName - The name of the Visual Studio Team Services account resource. +// - extensionResourceName - The name of the extension. +// - options - ExtensionsClientDeleteOptions contains the optional parameters for the ExtensionsClient.Delete method. func (client *ExtensionsClient) Delete(ctx context.Context, resourceGroupName string, accountResourceName string, extensionResourceName string, options *ExtensionsClientDeleteOptions) (ExtensionsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountResourceName, extensionResourceName, options) if err != nil { return ExtensionsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExtensionsClientDeleteResponse{}, err } @@ -157,7 +149,7 @@ func (client *ExtensionsClient) deleteCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter extensionResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{extensionResourceName}", url.PathEscape(extensionResourceName)) - 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,17 +161,18 @@ func (client *ExtensionsClient) deleteCreateRequest(ctx context.Context, resourc // Get - Gets the details of an extension associated with a Visual Studio Team Services account resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2014-04-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// accountResourceName - The name of the Visual Studio Team Services account resource. -// extensionResourceName - The name of the extension. -// options - ExtensionsClientGetOptions contains the optional parameters for the ExtensionsClient.Get method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - accountResourceName - The name of the Visual Studio Team Services account resource. +// - extensionResourceName - The name of the extension. +// - options - ExtensionsClientGetOptions contains the optional parameters for the ExtensionsClient.Get method. func (client *ExtensionsClient) Get(ctx context.Context, resourceGroupName string, accountResourceName string, extensionResourceName string, options *ExtensionsClientGetOptions) (ExtensionsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountResourceName, extensionResourceName, options) if err != nil { return ExtensionsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExtensionsClientGetResponse{}, err } @@ -208,7 +201,7 @@ func (client *ExtensionsClient) getCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter extensionResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{extensionResourceName}", url.PathEscape(extensionResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -230,17 +223,18 @@ func (client *ExtensionsClient) getHandleResponse(resp *http.Response) (Extensio // ListByAccount - Gets the details of the extension resources created within the resource group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2014-04-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// accountResourceName - The name of the Visual Studio Team Services account resource. -// options - ExtensionsClientListByAccountOptions contains the optional parameters for the ExtensionsClient.ListByAccount -// method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - accountResourceName - The name of the Visual Studio Team Services account resource. +// - options - ExtensionsClientListByAccountOptions contains the optional parameters for the ExtensionsClient.ListByAccount +// method. func (client *ExtensionsClient) ListByAccount(ctx context.Context, resourceGroupName string, accountResourceName string, options *ExtensionsClientListByAccountOptions) (ExtensionsClientListByAccountResponse, error) { req, err := client.listByAccountCreateRequest(ctx, resourceGroupName, accountResourceName, options) if err != nil { return ExtensionsClientListByAccountResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExtensionsClientListByAccountResponse{}, err } @@ -265,7 +259,7 @@ func (client *ExtensionsClient) listByAccountCreateRequest(ctx context.Context, return nil, errors.New("parameter accountResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountResourceName}", url.PathEscape(accountResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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,18 +281,19 @@ func (client *ExtensionsClient) listByAccountHandleResponse(resp *http.Response) // Update - Updates an existing extension registration for the Visual Studio Team Services account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2014-04-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// accountResourceName - The name of the Visual Studio Team Services account resource. -// extensionResourceName - The name of the extension. -// body - An object containing additional information related to the extension request. -// options - ExtensionsClientUpdateOptions contains the optional parameters for the ExtensionsClient.Update method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - accountResourceName - The name of the Visual Studio Team Services account resource. +// - extensionResourceName - The name of the extension. +// - body - An object containing additional information related to the extension request. +// - options - ExtensionsClientUpdateOptions contains the optional parameters for the ExtensionsClient.Update method. func (client *ExtensionsClient) Update(ctx context.Context, resourceGroupName string, accountResourceName string, extensionResourceName string, body ExtensionResourceRequest, options *ExtensionsClientUpdateOptions) (ExtensionsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountResourceName, extensionResourceName, body, options) if err != nil { return ExtensionsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExtensionsClientUpdateResponse{}, err } @@ -327,7 +322,7 @@ func (client *ExtensionsClient) updateCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter extensionResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{extensionResourceName}", url.PathEscape(extensionResourceName)) - 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/visualstudio/armvisualstudio/extensions_client_example_test.go b/sdk/resourcemanager/visualstudio/armvisualstudio/extensions_client_example_test.go new file mode 100644 index 000000000000..57aa1b44c30f --- /dev/null +++ b/sdk/resourcemanager/visualstudio/armvisualstudio/extensions_client_example_test.go @@ -0,0 +1,209 @@ +//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 armvisualstudio_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/visualstudio/armvisualstudio" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/GetExtensionResources_List.json +func ExampleExtensionsClient_ListByAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvisualstudio.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewExtensionsClient().ListByAccount(ctx, "VS-Example-Group", "ExampleAccount", 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.ExtensionResourceListResult = armvisualstudio.ExtensionResourceListResult{ + // Value: []*armvisualstudio.ExtensionResource{ + // { + // Name: to.Ptr("ms.example"), + // Type: to.Ptr("Microsoft.VisualStudio/account/extension"), + // ID: to.Ptr("/subscriptions/0de7f055-dbea-498d-8e9e-da287eedca90/resourceGroups/VS-Example-Group/providers/Microsoft.VisualStudio/account/ExampleAccount/extension/ms.example"), + // Location: to.Ptr("Central US"), + // Tags: map[string]*string{ + // }, + // Plan: &armvisualstudio.ExtensionResourcePlan{ + // Name: to.Ptr("ExamplePlan"), + // Product: to.Ptr("ExampleExtensionName"), + // PromotionCode: to.Ptr(""), + // Publisher: to.Ptr("ExampleExtensionPublisher"), + // Version: to.Ptr("1.0"), + // }, + // Properties: map[string]*string{ + // }, + // }}, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/CreateExtensionResource.json +func ExampleExtensionsClient_Create() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvisualstudio.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewExtensionsClient().Create(ctx, "VS-Example-Group", "ExampleAccount", "ms.example", armvisualstudio.ExtensionResourceRequest{ + Location: to.Ptr("Central US"), + Plan: &armvisualstudio.ExtensionResourcePlan{ + Name: to.Ptr("ExamplePlan"), + Product: to.Ptr("ExampleExtensionName"), + PromotionCode: to.Ptr(""), + Publisher: to.Ptr("ExampleExtensionPublisher"), + Version: to.Ptr("1.0"), + }, + Properties: map[string]*string{}, + Tags: map[string]*string{}, + }, 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.ExtensionResource = armvisualstudio.ExtensionResource{ + // Name: to.Ptr("ms.example"), + // Type: to.Ptr("Microsoft.VisualStudio/account/extension"), + // ID: to.Ptr("/subscriptions/0de7f055-dbea-498d-8e9e-da287eedca90/resourceGroups/VS-Example-Group/providers/Microsoft.VisualStudio/account/ExampleAccount/extension/ms.example"), + // Location: to.Ptr("Central US"), + // Tags: map[string]*string{ + // }, + // Plan: &armvisualstudio.ExtensionResourcePlan{ + // Name: to.Ptr("ExamplePlan"), + // Product: to.Ptr("ExampleExtensionName"), + // PromotionCode: to.Ptr(""), + // Publisher: to.Ptr("ExampleExtensionPublisher"), + // Version: to.Ptr("1.0"), + // }, + // Properties: map[string]*string{ + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/DeleteExtensionResource.json +func ExampleExtensionsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvisualstudio.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewExtensionsClient().Delete(ctx, "VS-Example-Group", "Example", "ms.example", 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/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/GetExtensionResource.json +func ExampleExtensionsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvisualstudio.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewExtensionsClient().Get(ctx, "VS-Example-Group", "ExampleAccount", "ms.example", 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.ExtensionResource = armvisualstudio.ExtensionResource{ + // Name: to.Ptr("ms.example"), + // Type: to.Ptr("Microsoft.VisualStudio/account/extension"), + // ID: to.Ptr("/subscriptions/0de7f055-dbea-498d-8e9e-da287eedca90/resourceGroups/VS-Example-Group/providers/Microsoft.VisualStudio/account/ExampleAccount/extension/ms.example"), + // Location: to.Ptr("Central US"), + // Tags: map[string]*string{ + // }, + // Plan: &armvisualstudio.ExtensionResourcePlan{ + // Name: to.Ptr("ExamplePlan"), + // Product: to.Ptr("ExampleExtensionName"), + // PromotionCode: to.Ptr(""), + // Publisher: to.Ptr("ExampleExtensionPublisher"), + // Version: to.Ptr("1.0"), + // }, + // Properties: map[string]*string{ + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/UpdateExtensionResource.json +func ExampleExtensionsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvisualstudio.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewExtensionsClient().Update(ctx, "VS-Example-Group", "ExampleAccount", "Example", armvisualstudio.ExtensionResourceRequest{ + Location: to.Ptr("Central US"), + Plan: &armvisualstudio.ExtensionResourcePlan{ + Name: to.Ptr("ExamplePlan"), + Product: to.Ptr("ExampleExtensionName"), + PromotionCode: to.Ptr(""), + Publisher: to.Ptr("ExampleExtensionPublisher"), + Version: to.Ptr("1.0"), + }, + Properties: map[string]*string{}, + Tags: map[string]*string{}, + }, 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.ExtensionResource = armvisualstudio.ExtensionResource{ + // Name: to.Ptr("ms.example"), + // Type: to.Ptr("Microsoft.VisualStudio/account/extension"), + // ID: to.Ptr("/subscriptions/0de7f055-dbea-498d-8e9e-da287eedca90/resourceGroups/VS-Example-Group/providers/Microsoft.VisualStudio/account/ExampleAccount/extension/ms.example"), + // Location: to.Ptr("Central US"), + // Tags: map[string]*string{ + // }, + // Plan: &armvisualstudio.ExtensionResourcePlan{ + // Name: to.Ptr("ExamplePlan"), + // Product: to.Ptr("ExampleExtensionName"), + // PromotionCode: to.Ptr(""), + // Publisher: to.Ptr("ExampleExtensionPublisher"), + // Version: to.Ptr("1.0"), + // }, + // Properties: map[string]*string{ + // }, + // } +} diff --git a/sdk/resourcemanager/visualstudio/armvisualstudio/go.mod b/sdk/resourcemanager/visualstudio/armvisualstudio/go.mod index 812b4492b152..221982d4f68a 100644 --- a/sdk/resourcemanager/visualstudio/armvisualstudio/go.mod +++ b/sdk/resourcemanager/visualstudio/armvisualstudio/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/visualstudio/armvis 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/visualstudio/armvisualstudio/go.sum b/sdk/resourcemanager/visualstudio/armvisualstudio/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/visualstudio/armvisualstudio/go.sum +++ b/sdk/resourcemanager/visualstudio/armvisualstudio/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/visualstudio/armvisualstudio/zz_generated_models.go b/sdk/resourcemanager/visualstudio/armvisualstudio/models.go similarity index 99% rename from sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_models.go rename to sdk/resourcemanager/visualstudio/armvisualstudio/models.go index 0915b802c8c9..2ab8d92e91d1 100644 --- a/sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_models.go +++ b/sdk/resourcemanager/visualstudio/armvisualstudio/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 armvisualstudio diff --git a/sdk/resourcemanager/visualstudio/armvisualstudio/models_serde.go b/sdk/resourcemanager/visualstudio/armvisualstudio/models_serde.go new file mode 100644 index 000000000000..8f8b636080df --- /dev/null +++ b/sdk/resourcemanager/visualstudio/armvisualstudio/models_serde.go @@ -0,0 +1,617 @@ +//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 armvisualstudio + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AccountResource. +func (a AccountResource) 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 AccountResource. +func (a *AccountResource) UnmarshalJSON(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 AccountResourceListResult. +func (a AccountResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountResourceListResult. +func (a *AccountResourceListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccountResourceRequest. +func (a AccountResourceRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accountName", a.AccountName) + populate(objectMap, "location", a.Location) + populate(objectMap, "operationType", a.OperationType) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountResourceRequest. +func (a *AccountResourceRequest) UnmarshalJSON(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 "accountName": + err = unpopulate(val, "AccountName", &a.AccountName) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &a.Location) + delete(rawMsg, key) + case "operationType": + err = unpopulate(val, "OperationType", &a.OperationType) + 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) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccountTagRequest. +func (a AccountTagRequest) 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 AccountTagRequest. +func (a *AccountTagRequest) UnmarshalJSON(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 CheckNameAvailabilityParameter. +func (c CheckNameAvailabilityParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceName", c.ResourceName) + populate(objectMap, "resourceType", c.ResourceType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityParameter. +func (c *CheckNameAvailabilityParameter) UnmarshalJSON(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 "resourceName": + err = unpopulate(val, "ResourceName", &c.ResourceName) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &c.ResourceType) + 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 CheckNameAvailabilityResult. +func (c CheckNameAvailabilityResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", c.Message) + populate(objectMap, "nameAvailable", c.NameAvailable) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityResult. +func (c *CheckNameAvailabilityResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &c.Message) + delete(rawMsg, key) + case "nameAvailable": + err = unpopulate(val, "NameAvailable", &c.NameAvailable) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExtensionResource. +func (e ExtensionResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + populate(objectMap, "location", e.Location) + populate(objectMap, "name", e.Name) + populate(objectMap, "plan", e.Plan) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "tags", e.Tags) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionResource. +func (e *ExtensionResource) UnmarshalJSON(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 "location": + err = unpopulate(val, "Location", &e.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "plan": + err = unpopulate(val, "Plan", &e.Plan) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + 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 ExtensionResourceListResult. +func (e ExtensionResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionResourceListResult. +func (e *ExtensionResourceListResult) UnmarshalJSON(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 "value": + err = unpopulate(val, "Value", &e.Value) + 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 ExtensionResourcePlan. +func (e ExtensionResourcePlan) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", e.Name) + populate(objectMap, "product", e.Product) + populate(objectMap, "promotionCode", e.PromotionCode) + populate(objectMap, "publisher", e.Publisher) + populate(objectMap, "version", e.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionResourcePlan. +func (e *ExtensionResourcePlan) UnmarshalJSON(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 "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "product": + err = unpopulate(val, "Product", &e.Product) + delete(rawMsg, key) + case "promotionCode": + err = unpopulate(val, "PromotionCode", &e.PromotionCode) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &e.Publisher) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &e.Version) + 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 ExtensionResourceRequest. +func (e ExtensionResourceRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "location", e.Location) + populate(objectMap, "plan", e.Plan) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "tags", e.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionResourceRequest. +func (e *ExtensionResourceRequest) UnmarshalJSON(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 "location": + err = unpopulate(val, "Location", &e.Location) + delete(rawMsg, key) + case "plan": + err = unpopulate(val, "Plan", &e.Plan) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", o.Display) + populate(objectMap, "name", o.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationProperties. +func (o OperationProperties) 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 OperationProperties. +func (o *OperationProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "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 ProjectResource. +func (p ProjectResource) 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 ProjectResource. +func (p *ProjectResource) UnmarshalJSON(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 ProjectResourceListResult. +func (p ProjectResourceListResult) 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 ProjectResourceListResult. +func (p *ProjectResourceListResult) UnmarshalJSON(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 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/visualstudio/armvisualstudio/zz_generated_operations_client.go b/sdk/resourcemanager/visualstudio/armvisualstudio/operations_client.go similarity index 75% rename from sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_operations_client.go rename to sdk/resourcemanager/visualstudio/armvisualstudio/operations_client.go index f02f10c013da..f0b16a8ffaf0 100644 --- a/sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_operations_client.go +++ b/sdk/resourcemanager/visualstudio/armvisualstudio/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 armvisualstudio @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,42 +21,34 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // List - Gets the details of all operations possible on the Microsoft.VisualStudio resource provider. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2014-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 } @@ -70,7 +61,7 @@ func (client *OperationsClient) List(ctx context.Context, options *OperationsCli // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/microsoft.visualstudio/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/visualstudio/armvisualstudio/operations_client_example_test.go b/sdk/resourcemanager/visualstudio/armvisualstudio/operations_client_example_test.go new file mode 100644 index 000000000000..d24c7f5df931 --- /dev/null +++ b/sdk/resourcemanager/visualstudio/armvisualstudio/operations_client_example_test.go @@ -0,0 +1,122 @@ +//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 armvisualstudio_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/visualstudio/armvisualstudio" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/GetOperations.json +func ExampleOperationsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvisualstudio.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewOperationsClient().List(ctx, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.OperationListResult = armvisualstudio.OperationListResult{ + // Value: []*armvisualstudio.Operation{ + // { + // Name: to.Ptr("Microsoft.VisualStudio/Account/Write"), + // Display: &armvisualstudio.OperationProperties{ + // Description: to.Ptr("Set Account"), + // Operation: to.Ptr("Creates or updates the Account"), + // Provider: to.Ptr("Visual Studio"), + // Resource: to.Ptr("Account"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.VisualStudio/Account/Delete"), + // Display: &armvisualstudio.OperationProperties{ + // Description: to.Ptr("Delete Account"), + // Operation: to.Ptr("Deletes the Account"), + // Provider: to.Ptr("Visual Studio"), + // Resource: to.Ptr("Account"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.VisualStudio/Account/Read"), + // Display: &armvisualstudio.OperationProperties{ + // Description: to.Ptr("Read Account"), + // Operation: to.Ptr("Reads the Account"), + // Provider: to.Ptr("Visual Studio"), + // Resource: to.Ptr("Account"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.VisualStudio/Project/Write"), + // Display: &armvisualstudio.OperationProperties{ + // Description: to.Ptr("Set Project"), + // Operation: to.Ptr("Creates or updates the Project"), + // Provider: to.Ptr("Visual Studio"), + // Resource: to.Ptr("Project"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.VisualStudio/Project/Delete"), + // Display: &armvisualstudio.OperationProperties{ + // Description: to.Ptr("Delete Project"), + // Operation: to.Ptr("Deletes the Project"), + // Provider: to.Ptr("Visual Studio"), + // Resource: to.Ptr("Project"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.VisualStudio/Project/Read"), + // Display: &armvisualstudio.OperationProperties{ + // Description: to.Ptr("Read Project"), + // Operation: to.Ptr("Reads the Project"), + // Provider: to.Ptr("Visual Studio"), + // Resource: to.Ptr("Project"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.VisualStudio/Extension/Write"), + // Display: &armvisualstudio.OperationProperties{ + // Description: to.Ptr("Set Extension"), + // Operation: to.Ptr("Creates or updates the Extension"), + // Provider: to.Ptr("Visual Studio"), + // Resource: to.Ptr("Extension"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.VisualStudio/Extension/Delete"), + // Display: &armvisualstudio.OperationProperties{ + // Description: to.Ptr("Delete Extension"), + // Operation: to.Ptr("Deletes the Extension"), + // Provider: to.Ptr("Visual Studio"), + // Resource: to.Ptr("Extension"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.VisualStudio/Extension/Read"), + // Display: &armvisualstudio.OperationProperties{ + // Description: to.Ptr("Read Extension"), + // Operation: to.Ptr("Reads the Extension"), + // Provider: to.Ptr("Visual Studio"), + // Resource: to.Ptr("Extension"), + // }, + // }}, + // } +} diff --git a/sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_projects_client.go b/sdk/resourcemanager/visualstudio/armvisualstudio/projects_client.go similarity index 85% rename from sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_projects_client.go rename to sdk/resourcemanager/visualstudio/armvisualstudio/projects_client.go index 830199713f78..bb4ef7e513d2 100644 --- a/sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_projects_client.go +++ b/sdk/resourcemanager/visualstudio/armvisualstudio/projects_client.go @@ -5,6 +5,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armvisualstudio @@ -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 ( // ProjectsClient contains the methods for the Projects group. // Don't use this type directly, use NewProjectsClient() instead. type ProjectsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewProjectsClient creates a new instance of ProjectsClient with the specified values. -// subscriptionID - The Azure subscription identifier. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription identifier. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewProjectsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProjectsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ProjectsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ProjectsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -60,21 +50,22 @@ func NewProjectsClient(subscriptionID string, credential azcore.TokenCredential, // 27450541-8E31-4150-9947-DC59F998FC01 (these IDs // correspond to Scrum, Agile, and CMMI process templates). // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2014-04-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// rootResourceName - Name of the Team Services account. -// resourceName - Name of the Team Services project. -// body - The request data. -// options - ProjectsClientBeginCreateOptions contains the optional parameters for the ProjectsClient.BeginCreate method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - rootResourceName - Name of the Team Services account. +// - resourceName - Name of the Team Services project. +// - body - The request data. +// - options - ProjectsClientBeginCreateOptions contains the optional parameters for the ProjectsClient.BeginCreate method. func (client *ProjectsClient) BeginCreate(ctx context.Context, resourceGroupName string, rootResourceName string, resourceName string, body ProjectResource, options *ProjectsClientBeginCreateOptions) (*runtime.Poller[ProjectsClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, rootResourceName, resourceName, body, options) if err != nil { return nil, err } - return runtime.NewPoller[ProjectsClientCreateResponse](resp, client.pl, nil) + return runtime.NewPoller[ProjectsClientCreateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ProjectsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ProjectsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } @@ -84,13 +75,14 @@ func (client *ProjectsClient) BeginCreate(ctx context.Context, resourceGroupName // 27450541-8E31-4150-9947-DC59F998FC01 (these IDs // correspond to Scrum, Agile, and CMMI process templates). // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2014-04-01-preview func (client *ProjectsClient) create(ctx context.Context, resourceGroupName string, rootResourceName string, resourceName string, body ProjectResource, options *ProjectsClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, rootResourceName, resourceName, body, 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 } @@ -119,7 +111,7 @@ func (client *ProjectsClient) createCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -135,17 +127,18 @@ func (client *ProjectsClient) createCreateRequest(ctx context.Context, resourceG // Get - Gets the details of a Team Services project resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2014-04-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// rootResourceName - Name of the Team Services account. -// resourceName - Name of the Team Services project. -// options - ProjectsClientGetOptions contains the optional parameters for the ProjectsClient.Get method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - rootResourceName - Name of the Team Services account. +// - resourceName - Name of the Team Services project. +// - options - ProjectsClientGetOptions contains the optional parameters for the ProjectsClient.Get method. func (client *ProjectsClient) Get(ctx context.Context, resourceGroupName string, rootResourceName string, resourceName string, options *ProjectsClientGetOptions) (ProjectsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, rootResourceName, resourceName, options) if err != nil { return ProjectsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProjectsClientGetResponse{}, err } @@ -174,7 +167,7 @@ func (client *ProjectsClient) getCreateRequest(ctx context.Context, resourceGrou 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 } @@ -196,19 +189,20 @@ func (client *ProjectsClient) getHandleResponse(resp *http.Response) (ProjectsCl // GetJobStatus - Gets the status of the project resource creation job. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2014-04-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// rootResourceName - Name of the Team Services account. -// resourceName - Name of the Team Services project. -// subContainerName - This parameter should be set to the resourceName. -// operation - The operation type. The only supported value is 'put'. -// options - ProjectsClientGetJobStatusOptions contains the optional parameters for the ProjectsClient.GetJobStatus method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - rootResourceName - Name of the Team Services account. +// - resourceName - Name of the Team Services project. +// - subContainerName - This parameter should be set to the resourceName. +// - operation - The operation type. The only supported value is 'put'. +// - options - ProjectsClientGetJobStatusOptions contains the optional parameters for the ProjectsClient.GetJobStatus method. func (client *ProjectsClient) GetJobStatus(ctx context.Context, resourceGroupName string, rootResourceName string, resourceName string, subContainerName string, operation string, options *ProjectsClientGetJobStatusOptions) (ProjectsClientGetJobStatusResponse, error) { req, err := client.getJobStatusCreateRequest(ctx, resourceGroupName, rootResourceName, resourceName, subContainerName, operation, options) if err != nil { return ProjectsClientGetJobStatusResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProjectsClientGetJobStatusResponse{}, err } @@ -241,7 +235,7 @@ func (client *ProjectsClient) getJobStatusCreateRequest(ctx context.Context, res return nil, errors.New("parameter subContainerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subContainerName}", url.PathEscape(subContainerName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -267,17 +261,18 @@ func (client *ProjectsClient) getJobStatusHandleResponse(resp *http.Response) (P // ListByResourceGroup - Gets all Visual Studio Team Services project resources created in the specified Team Services account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2014-04-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// rootResourceName - Name of the Team Services account. -// options - ProjectsClientListByResourceGroupOptions contains the optional parameters for the ProjectsClient.ListByResourceGroup -// method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - rootResourceName - Name of the Team Services account. +// - options - ProjectsClientListByResourceGroupOptions contains the optional parameters for the ProjectsClient.ListByResourceGroup +// method. func (client *ProjectsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, rootResourceName string, options *ProjectsClientListByResourceGroupOptions) (ProjectsClientListByResourceGroupResponse, error) { req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, rootResourceName, options) if err != nil { return ProjectsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProjectsClientListByResourceGroupResponse{}, err } @@ -302,7 +297,7 @@ func (client *ProjectsClient) listByResourceGroupCreateRequest(ctx context.Conte return nil, errors.New("parameter rootResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{rootResourceName}", url.PathEscape(rootResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -324,18 +319,19 @@ func (client *ProjectsClient) listByResourceGroupHandleResponse(resp *http.Respo // Update - Updates the tags of the specified Team Services project. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2014-04-01-preview -// resourceGroupName - Name of the resource group within the Azure subscription. -// rootResourceName - Name of the Team Services account. -// resourceName - Name of the Team Services project. -// body - The request data. -// options - ProjectsClientUpdateOptions contains the optional parameters for the ProjectsClient.Update method. +// - resourceGroupName - Name of the resource group within the Azure subscription. +// - rootResourceName - Name of the Team Services account. +// - resourceName - Name of the Team Services project. +// - body - The request data. +// - options - ProjectsClientUpdateOptions contains the optional parameters for the ProjectsClient.Update method. func (client *ProjectsClient) Update(ctx context.Context, resourceGroupName string, rootResourceName string, resourceName string, body ProjectResource, options *ProjectsClientUpdateOptions) (ProjectsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, rootResourceName, resourceName, body, options) if err != nil { return ProjectsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProjectsClientUpdateResponse{}, err } @@ -364,7 +360,7 @@ func (client *ProjectsClient) updateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/visualstudio/armvisualstudio/projects_client_example_test.go b/sdk/resourcemanager/visualstudio/armvisualstudio/projects_client_example_test.go new file mode 100644 index 000000000000..e9a30d4e11ef --- /dev/null +++ b/sdk/resourcemanager/visualstudio/armvisualstudio/projects_client_example_test.go @@ -0,0 +1,203 @@ +//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 armvisualstudio_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/visualstudio/armvisualstudio" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/GetProjectResources_List.json +func ExampleProjectsClient_ListByResourceGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvisualstudio.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewProjectsClient().ListByResourceGroup(ctx, "VS-Example-Group", "ExampleAccount", 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.ProjectResourceListResult = armvisualstudio.ProjectResourceListResult{ + // Value: []*armvisualstudio.ProjectResource{ + // { + // Name: to.Ptr("ExampleProject"), + // Type: to.Ptr("Microsoft.VisualStudio/account/project"), + // ID: to.Ptr("/subscriptions/0de7f055-dbea-498d-8e9e-da287eedca90/resourceGroups/VS-Example-Group/providers/Microsoft.VisualStudio/account/ExampleAccount/project/ExampleProject"), + // Location: to.Ptr("Central US"), + // Tags: map[string]*string{ + // }, + // Properties: map[string]*string{ + // "AzureResourceName": to.Ptr("ExampleProject"), + // "TfsUniqueIdentifier": to.Ptr("vstfs:///Classification/TeamProject/d921d601-0600-4e45-8600-3914ffc8811a"), + // }, + // }}, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/CreateProjectResource.json +func ExampleProjectsClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvisualstudio.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewProjectsClient().BeginCreate(ctx, "VS-Example-Group", "ExampleAccount", "ExampleProject", armvisualstudio.ProjectResource{ + Name: to.Ptr("ExampleProject"), + Type: to.Ptr("Microsoft.VisualStudio/account/project"), + ID: to.Ptr("/subscriptions/0de7f055-dbea-498d-8e9e-da287eedca90/resourceGroups/VS-Example-Group/providers/Microsoft.VisualStudio/account/ExampleAccount/project/ExampleProject"), + Location: to.Ptr("Central US"), + Tags: map[string]*string{}, + Properties: map[string]*string{ + "ProcessTemplateId": to.Ptr("6B724908-EF14-45CF-84F8-768B5384DA45"), + "VersionControlOption": to.Ptr("Git"), + }, + }, &armvisualstudio.ProjectsClientBeginCreateOptions{Validating: 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.ProjectResource = armvisualstudio.ProjectResource{ + // Name: to.Ptr("ExampleProject"), + // Type: to.Ptr("microsoft.visualstudio/account/project"), + // ID: to.Ptr("/subscriptions/0de7f055-dbea-498d-8e9e-da287eedca90/resourceGroups/VS-Example-Group/providers/microsoft.visualstudio/account/ExampleAccount/project/ExampleProject"), + // Location: to.Ptr("North Central US"), + // Tags: map[string]*string{ + // }, + // Properties: map[string]*string{ + // "AzureResourceName": to.Ptr("ExampleProject"), + // "TfsUniqueIdentifier": to.Ptr("vstfs:///Classification/TeamProject/7a4e6ba5-35bf-4667-86a4-9b598a88fa25"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/GetProjectResource.json +func ExampleProjectsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvisualstudio.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewProjectsClient().Get(ctx, "VS-Example-Group", "ExampleAccount", "ExampleProject", 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.ProjectResource = armvisualstudio.ProjectResource{ + // Name: to.Ptr("ExampleProject"), + // Type: to.Ptr("microsoft.visualstudio/account/project"), + // ID: to.Ptr("/subscriptions/0de7f055-dbea-498d-8e9e-da287eedca90/resourceGroups/VS-Example-Group/providers/microsoft.visualstudio/account/ExampleAccount/project/ExampleProject"), + // Location: to.Ptr("North Central US"), + // Tags: map[string]*string{ + // }, + // Properties: map[string]*string{ + // "AzureResourceName": to.Ptr("ExampleProject"), + // "TfsUniqueIdentifier": to.Ptr("vstfs:///Classification/TeamProject/7a4e6ba5-35bf-4667-86a4-9b598a88fa25"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/UpdateProjectResource.json +func ExampleProjectsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvisualstudio.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewProjectsClient().Update(ctx, "VS-Example-Group", "ExampleAccount", "ExampleProject", armvisualstudio.ProjectResource{ + Name: to.Ptr("ms.example"), + Type: to.Ptr("Microsoft.VisualStudio/account/extension"), + ID: to.Ptr("/subscriptions/0de7f055-dbea-498d-8e9e-da287eedca90/resourceGroups/VS-Example-Group/providers/microsoft.visualstudio/account/ExampleAccount/project/ExampleProject"), + Location: to.Ptr("Central US"), + Tags: map[string]*string{}, + Properties: map[string]*string{}, + }, 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.ProjectResource = armvisualstudio.ProjectResource{ + // Name: to.Ptr("ExampleProject"), + // Type: to.Ptr("microsoft.visualstudio/account/project"), + // ID: to.Ptr("/subscriptions/0de7f055-dbea-498d-8e9e-da287eedca90/resourceGroups/VS-Example-Group/providers/microsoft.visualstudio/account/ExampleAccount/project/ExampleProject"), + // Location: to.Ptr("North Central US"), + // Tags: map[string]*string{ + // }, + // Properties: map[string]*string{ + // "AzureResourceName": to.Ptr("ExampleProject"), + // "TfsUniqueIdentifier": to.Ptr("vstfs:///Classification/TeamProject/7a4e6ba5-35bf-4667-86a4-9b598a88fa25"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/GetProjectJobStatus.json +func ExampleProjectsClient_GetJobStatus() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvisualstudio.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewProjectsClient().GetJobStatus(ctx, "VS-Example-Group", "ExampleAccount", "ExampleProject", "ExampleProject", "put", &armvisualstudio.ProjectsClientGetJobStatusOptions{JobID: to.Ptr("126167d2-d710-4b5d-80a8-a1d58717142d")}) + 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.ProjectResource = armvisualstudio.ProjectResource{ + // Name: to.Ptr("ExampleProject"), + // Type: to.Ptr("microsoft.visualstudio/account/project"), + // ID: to.Ptr("/subscriptions/0de7f055-dbea-498d-8e9e-da287eedca90/resourceGroups/VS-Example-Group/providers/microsoft.visualstudio/account/ExampleAccount/project/ExampleProject"), + // Location: to.Ptr("North Central US"), + // Tags: map[string]*string{ + // }, + // Properties: map[string]*string{ + // "AzureResourceName": to.Ptr("ExampleProject"), + // "TfsUniqueIdentifier": to.Ptr("vstfs:///Classification/TeamProject/7a4e6ba5-35bf-4667-86a4-9b598a88fa25"), + // }, + // } +} diff --git a/sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_response_types.go b/sdk/resourcemanager/visualstudio/armvisualstudio/response_types.go similarity index 98% rename from sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_response_types.go rename to sdk/resourcemanager/visualstudio/armvisualstudio/response_types.go index 3e57bfd63188..bf39b9d95ddc 100644 --- a/sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_response_types.go +++ b/sdk/resourcemanager/visualstudio/armvisualstudio/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 armvisualstudio @@ -68,7 +69,7 @@ type OperationsClientListResponse struct { OperationListResult } -// ProjectsClientCreateResponse contains the response from method ProjectsClient.Create. +// ProjectsClientCreateResponse contains the response from method ProjectsClient.BeginCreate. type ProjectsClientCreateResponse struct { ProjectResource } diff --git a/sdk/resourcemanager/visualstudio/armvisualstudio/ze_generated_example_accounts_client_test.go b/sdk/resourcemanager/visualstudio/armvisualstudio/ze_generated_example_accounts_client_test.go deleted file mode 100644 index 3bca3db09852..000000000000 --- a/sdk/resourcemanager/visualstudio/armvisualstudio/ze_generated_example_accounts_client_test.go +++ /dev/null @@ -1,161 +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 armvisualstudio_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/visualstudio/armvisualstudio" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/CheckNameAvailability.json -func ExampleAccountsClient_CheckNameAvailability() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvisualstudio.NewAccountsClient("0de7f055-dbea-498d-8e9e-da287eedca90", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CheckNameAvailability(ctx, - armvisualstudio.CheckNameAvailabilityParameter{ - ResourceName: to.Ptr("ExampleName"), - ResourceType: to.Ptr("Account"), - }, - 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/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/GetResources_List.json -func ExampleAccountsClient_ListByResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvisualstudio.NewAccountsClient("0de7f055-dbea-498d-8e9e-da287eedca90", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListByResourceGroup(ctx, - "VS-Example-Group", - 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/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/CreateResource.json -func ExampleAccountsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvisualstudio.NewAccountsClient("0de7f055-dbea-498d-8e9e-da287eedca90", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "VS-Example-Group", - "Example", - armvisualstudio.AccountResourceRequest{ - AccountName: to.Ptr("Example"), - Location: to.Ptr("Central US"), - OperationType: to.Ptr(armvisualstudio.AccountResourceRequestOperationTypeCreate), - Properties: map[string]*string{}, - Tags: map[string]*string{}, - }, - 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/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/DeleteResource.json -func ExampleAccountsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvisualstudio.NewAccountsClient("0de7f055-dbea-498d-8e9e-da287eedca90", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "VS-Example-Group", - "Example", - 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/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/GetResource.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 := armvisualstudio.NewAccountsClient("0de7f055-dbea-498d-8e9e-da287eedca90", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "VS-Example-Group", - "Example", - 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/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/UpdateTags.json -func ExampleAccountsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvisualstudio.NewAccountsClient("0de7f055-dbea-498d-8e9e-da287eedca90", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "VS-Example-Group", - "Example", - armvisualstudio.AccountTagRequest{ - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/visualstudio/armvisualstudio/ze_generated_example_extensions_client_test.go b/sdk/resourcemanager/visualstudio/armvisualstudio/ze_generated_example_extensions_client_test.go deleted file mode 100644 index 8ea0ae75713c..000000000000 --- a/sdk/resourcemanager/visualstudio/armvisualstudio/ze_generated_example_extensions_client_test.go +++ /dev/null @@ -1,154 +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 armvisualstudio_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/visualstudio/armvisualstudio" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/GetExtensionResources_List.json -func ExampleExtensionsClient_ListByAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvisualstudio.NewExtensionsClient("0de7f055-dbea-498d-8e9e-da287eedca90", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListByAccount(ctx, - "VS-Example-Group", - "ExampleAccount", - 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/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/CreateExtensionResource.json -func ExampleExtensionsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvisualstudio.NewExtensionsClient("0de7f055-dbea-498d-8e9e-da287eedca90", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Create(ctx, - "VS-Example-Group", - "ExampleAccount", - "ms.example", - armvisualstudio.ExtensionResourceRequest{ - Location: to.Ptr("Central US"), - Plan: &armvisualstudio.ExtensionResourcePlan{ - Name: to.Ptr("ExamplePlan"), - Product: to.Ptr("ExampleExtensionName"), - PromotionCode: to.Ptr(""), - Publisher: to.Ptr("ExampleExtensionPublisher"), - Version: to.Ptr("1.0"), - }, - Properties: map[string]*string{}, - Tags: map[string]*string{}, - }, - 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/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/DeleteExtensionResource.json -func ExampleExtensionsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvisualstudio.NewExtensionsClient("0de7f055-dbea-498d-8e9e-da287eedca90", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "VS-Example-Group", - "Example", - "ms.example", - 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/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/GetExtensionResource.json -func ExampleExtensionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvisualstudio.NewExtensionsClient("0de7f055-dbea-498d-8e9e-da287eedca90", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "VS-Example-Group", - "ExampleAccount", - "ms.example", - 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/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/UpdateExtensionResource.json -func ExampleExtensionsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvisualstudio.NewExtensionsClient("0de7f055-dbea-498d-8e9e-da287eedca90", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "VS-Example-Group", - "ExampleAccount", - "Example", - armvisualstudio.ExtensionResourceRequest{ - Location: to.Ptr("Central US"), - Plan: &armvisualstudio.ExtensionResourcePlan{ - Name: to.Ptr("ExamplePlan"), - Product: to.Ptr("ExampleExtensionName"), - PromotionCode: to.Ptr(""), - Publisher: to.Ptr("ExampleExtensionPublisher"), - Version: to.Ptr("1.0"), - }, - Properties: map[string]*string{}, - Tags: map[string]*string{}, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/visualstudio/armvisualstudio/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/visualstudio/armvisualstudio/ze_generated_example_operations_client_test.go deleted file mode 100644 index 0ed38918abcf..000000000000 --- a/sdk/resourcemanager/visualstudio/armvisualstudio/ze_generated_example_operations_client_test.go +++ /dev/null @@ -1,37 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armvisualstudio_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/visualstudio/armvisualstudio" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/GetOperations.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 := armvisualstudio.NewOperationsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.List(ctx, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/visualstudio/armvisualstudio/ze_generated_example_projects_client_test.go b/sdk/resourcemanager/visualstudio/armvisualstudio/ze_generated_example_projects_client_test.go deleted file mode 100644 index daca13ed37e5..000000000000 --- a/sdk/resourcemanager/visualstudio/armvisualstudio/ze_generated_example_projects_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 armvisualstudio_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/visualstudio/armvisualstudio" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/GetProjectResources_List.json -func ExampleProjectsClient_ListByResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvisualstudio.NewProjectsClient("0de7f055-dbea-498d-8e9e-da287eedca90", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListByResourceGroup(ctx, - "VS-Example-Group", - "ExampleAccount", - 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/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/CreateProjectResource.json -func ExampleProjectsClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvisualstudio.NewProjectsClient("0de7f055-dbea-498d-8e9e-da287eedca90", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, - "VS-Example-Group", - "ExampleAccount", - "ExampleProject", - armvisualstudio.ProjectResource{ - Name: to.Ptr("ExampleProject"), - Type: to.Ptr("Microsoft.VisualStudio/account/project"), - ID: to.Ptr("/subscriptions/0de7f055-dbea-498d-8e9e-da287eedca90/resourceGroups/VS-Example-Group/providers/Microsoft.VisualStudio/account/ExampleAccount/project/ExampleProject"), - Location: to.Ptr("Central US"), - Tags: map[string]*string{}, - Properties: map[string]*string{ - "ProcessTemplateId": to.Ptr("6B724908-EF14-45CF-84F8-768B5384DA45"), - "VersionControlOption": to.Ptr("Git"), - }, - }, - &armvisualstudio.ProjectsClientBeginCreateOptions{Validating: 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/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/GetProjectResource.json -func ExampleProjectsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvisualstudio.NewProjectsClient("0de7f055-dbea-498d-8e9e-da287eedca90", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "VS-Example-Group", - "ExampleAccount", - "ExampleProject", - 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/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/UpdateProjectResource.json -func ExampleProjectsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvisualstudio.NewProjectsClient("0de7f055-dbea-498d-8e9e-da287eedca90", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "VS-Example-Group", - "ExampleAccount", - "ExampleProject", - armvisualstudio.ProjectResource{ - Name: to.Ptr("ms.example"), - Type: to.Ptr("Microsoft.VisualStudio/account/extension"), - ID: to.Ptr("/subscriptions/0de7f055-dbea-498d-8e9e-da287eedca90/resourceGroups/VS-Example-Group/providers/microsoft.visualstudio/account/ExampleAccount/project/ExampleProject"), - Location: to.Ptr("Central US"), - Tags: map[string]*string{}, - Properties: map[string]*string{}, - }, - 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/visualstudio/resource-manager/Microsoft.VisualStudio/preview/2014-04-01-preview/examples/GetProjectJobStatus.json -func ExampleProjectsClient_GetJobStatus() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvisualstudio.NewProjectsClient("0de7f055-dbea-498d-8e9e-da287eedca90", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetJobStatus(ctx, - "VS-Example-Group", - "ExampleAccount", - "ExampleProject", - "ExampleProject", - "put", - &armvisualstudio.ProjectsClientGetJobStatusOptions{JobID: to.Ptr("126167d2-d710-4b5d-80a8-a1d58717142d")}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_models_serde.go b/sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_models_serde.go deleted file mode 100644 index 66f87db5f1c3..000000000000 --- a/sdk/resourcemanager/visualstudio/armvisualstudio/zz_generated_models_serde.go +++ /dev/null @@ -1,101 +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 armvisualstudio - -import ( - "encoding/json" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type AccountResource. -func (a AccountResource) 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 AccountResourceRequest. -func (a AccountResourceRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "accountName", a.AccountName) - populate(objectMap, "location", a.Location) - populate(objectMap, "operationType", a.OperationType) - populate(objectMap, "properties", a.Properties) - populate(objectMap, "tags", a.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type AccountTagRequest. -func (a AccountTagRequest) 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 ExtensionResource. -func (e ExtensionResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", e.ID) - populate(objectMap, "location", e.Location) - populate(objectMap, "name", e.Name) - populate(objectMap, "plan", e.Plan) - populate(objectMap, "properties", e.Properties) - populate(objectMap, "tags", e.Tags) - populate(objectMap, "type", e.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ExtensionResourceRequest. -func (e ExtensionResourceRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "location", e.Location) - populate(objectMap, "plan", e.Plan) - populate(objectMap, "properties", e.Properties) - populate(objectMap, "tags", e.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ProjectResource. -func (p ProjectResource) 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 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/vmwarecloudsimple/armvmwarecloudsimple/CHANGELOG.md b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/CHANGELOG.md index c50998a040fd..94274e213a50 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/CHANGELOG.md +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2022-05-18) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple` 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/vmwarecloudsimple/armvmwarecloudsimple/README.md b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/README.md index 722c6f90d948..6f17b96ff385 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/README.md +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/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 VMware Cloud Simple 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 VMware Cloud Simple 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 := armvmwarecloudsimple.NewCustomizationPoliciesClient(, cred, nil) +clientFactory, err := armvmwarecloudsimple.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 := armvmwarecloudsimple.NewCustomizationPoliciesClient(, cred, &options) +clientFactory, err := armvmwarecloudsimple.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.NewVirtualMachinesClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/autorest.md b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/autorest.md index 0b8129c513c9..e74e84131592 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/autorest.md +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/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/vmwarecloudsimple/armvmwarecloudsimple/client_factory.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/client_factory.go new file mode 100644 index 000000000000..17b906df242a --- /dev/null +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/client_factory.go @@ -0,0 +1,94 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armvmwarecloudsimple + +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) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDedicatedCloudNodesClient() *DedicatedCloudNodesClient { + subClient, _ := NewDedicatedCloudNodesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDedicatedCloudServicesClient() *DedicatedCloudServicesClient { + subClient, _ := NewDedicatedCloudServicesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSKUsAvailabilityClient() *SKUsAvailabilityClient { + subClient, _ := NewSKUsAvailabilityClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPrivateCloudsClient() *PrivateCloudsClient { + subClient, _ := NewPrivateCloudsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCustomizationPoliciesClient() *CustomizationPoliciesClient { + subClient, _ := NewCustomizationPoliciesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewResourcePoolsClient() *ResourcePoolsClient { + subClient, _ := NewResourcePoolsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVirtualMachineTemplatesClient() *VirtualMachineTemplatesClient { + subClient, _ := NewVirtualMachineTemplatesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVirtualNetworksClient() *VirtualNetworksClient { + subClient, _ := NewVirtualNetworksClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewUsagesClient() *UsagesClient { + subClient, _ := NewUsagesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVirtualMachinesClient() *VirtualMachinesClient { + subClient, _ := NewVirtualMachinesClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_constants.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/constants.go similarity index 99% rename from sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_constants.go rename to sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/constants.go index 2016f15bc29c..896dcd4c959e 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_constants.go +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/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 armvmwarecloudsimple const ( moduleName = "armvmwarecloudsimple" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // AggregationType - Metric's aggregation type for e.g. (Average, Total) diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_customizationpolicies_client.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/customizationpolicies_client.go similarity index 83% rename from sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_customizationpolicies_client.go rename to sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/customizationpolicies_client.go index be9a54bca59d..d0488c351d50 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_customizationpolicies_client.go +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/customizationpolicies_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 armvmwarecloudsimple @@ -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 ( // CustomizationPoliciesClient contains the methods for the CustomizationPolicies group. // Don't use this type directly, use NewCustomizationPoliciesClient() instead. type CustomizationPoliciesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCustomizationPoliciesClient creates a new instance of CustomizationPoliciesClient 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 NewCustomizationPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CustomizationPoliciesClient, 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+".CustomizationPoliciesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CustomizationPoliciesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Returns customization policy by its name // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// regionID - The region Id (westus, eastus) -// pcName - The private cloud name -// customizationPolicyName - customization policy name -// options - CustomizationPoliciesClientGetOptions contains the optional parameters for the CustomizationPoliciesClient.Get -// method. +// - regionID - The region Id (westus, eastus) +// - pcName - The private cloud name +// - customizationPolicyName - customization policy name +// - options - CustomizationPoliciesClientGetOptions contains the optional parameters for the CustomizationPoliciesClient.Get +// method. func (client *CustomizationPoliciesClient) Get(ctx context.Context, regionID string, pcName string, customizationPolicyName string, options *CustomizationPoliciesClientGetOptions) (CustomizationPoliciesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, regionID, pcName, customizationPolicyName, options) if err != nil { return CustomizationPoliciesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomizationPoliciesClientGetResponse{}, err } @@ -96,7 +87,7 @@ func (client *CustomizationPoliciesClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter customizationPolicyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{customizationPolicyName}", url.PathEscape(customizationPolicyName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -117,12 +108,12 @@ func (client *CustomizationPoliciesClient) getHandleResponse(resp *http.Response } // NewListPager - Returns list of customization policies in region for private cloud -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// regionID - The region Id (westus, eastus) -// pcName - The private cloud name -// options - CustomizationPoliciesClientListOptions contains the optional parameters for the CustomizationPoliciesClient.List -// method. +// - regionID - The region Id (westus, eastus) +// - pcName - The private cloud name +// - options - CustomizationPoliciesClientListOptions contains the optional parameters for the CustomizationPoliciesClient.NewListPager +// method. func (client *CustomizationPoliciesClient) NewListPager(regionID string, pcName string, options *CustomizationPoliciesClientListOptions) *runtime.Pager[CustomizationPoliciesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[CustomizationPoliciesClientListResponse]{ More: func(page CustomizationPoliciesClientListResponse) bool { @@ -139,7 +130,7 @@ func (client *CustomizationPoliciesClient) NewListPager(regionID string, pcName if err != nil { return CustomizationPoliciesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomizationPoliciesClientListResponse{}, err } @@ -166,7 +157,7 @@ func (client *CustomizationPoliciesClient) listCreateRequest(ctx context.Context return nil, errors.New("parameter pcName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{pcName}", url.PathEscape(pcName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/vmwarecloudsimple/armvmwarecloudsimple/customizationpolicies_client_example_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/customizationpolicies_client_example_test.go new file mode 100644 index 000000000000..681bf472c64d --- /dev/null +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/customizationpolicies_client_example_test.go @@ -0,0 +1,156 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armvmwarecloudsimple_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListCustomizationPolicies.json +func ExampleCustomizationPoliciesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewCustomizationPoliciesClient().NewListPager("myResourceGroup", "myPrivateCloud", &armvmwarecloudsimple.CustomizationPoliciesClientListOptions{Filter: 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.CustomizationPoliciesListResponse = armvmwarecloudsimple.CustomizationPoliciesListResponse{ + // Value: []*armvmwarecloudsimple.CustomizationPolicy{ + // { + // Name: to.Ptr("Linux1"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/customizationPolicies"), + // ID: to.Ptr("/subscriptions/b85c4986-56ae-4ebd-b5c5-a1595ca3dab1/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/foobar/customizationpolicies/Linux1"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.CustomizationPolicyProperties{ + // Type: to.Ptr(armvmwarecloudsimple.CustomizationPolicyPropertiesTypeLINUX), + // PrivateCloudID: to.Ptr("/subscriptions/b85c4986-56ae-4ebd-b5c5-a1595ca3dab1/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/foobar"), + // Specification: &armvmwarecloudsimple.CustomizationSpecification{ + // Identity: &armvmwarecloudsimple.CustomizationIdentity{ + // Type: to.Ptr(armvmwarecloudsimple.CustomizationIdentityTypeLINUX), + // HostName: &armvmwarecloudsimple.CustomizationHostName{ + // Type: to.Ptr(armvmwarecloudsimple.CustomizationHostNameTypeUSERDEFINED), + // }, + // UserData: &armvmwarecloudsimple.CustomizationIdentityUserData{ + // IsPasswordPredefined: to.Ptr(false), + // }, + // }, + // NicSettings: []*armvmwarecloudsimple.CustomizationNicSetting{ + // { + // Adapter: &armvmwarecloudsimple.CustomizationIPSettings{ + // IP: &armvmwarecloudsimple.CustomizationIPAddress{ + // Type: to.Ptr(armvmwarecloudsimple.CustomizationIPAddressTypeUSERDEFINED), + // }, + // }, + // }}, + // }, + // Version: to.Ptr("1568102823"), + // }, + // }, + // { + // Name: to.Ptr("Linux2"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/customizationPolicies"), + // ID: to.Ptr("/subscriptions/b85c4986-56ae-4ebd-b5c5-a1595ca3dab1/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/foobar/customizationpolicies/Linux2"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.CustomizationPolicyProperties{ + // Type: to.Ptr(armvmwarecloudsimple.CustomizationPolicyPropertiesTypeLINUX), + // PrivateCloudID: to.Ptr("/subscriptions/b85c4986-56ae-4ebd-b5c5-a1595ca3dab1/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/foobar"), + // Specification: &armvmwarecloudsimple.CustomizationSpecification{ + // Identity: &armvmwarecloudsimple.CustomizationIdentity{ + // Type: to.Ptr(armvmwarecloudsimple.CustomizationIdentityTypeLINUX), + // HostName: &armvmwarecloudsimple.CustomizationHostName{ + // Type: to.Ptr(armvmwarecloudsimple.CustomizationHostNameTypeVIRTUALMACHINENAME), + // }, + // UserData: &armvmwarecloudsimple.CustomizationIdentityUserData{ + // IsPasswordPredefined: to.Ptr(false), + // }, + // }, + // NicSettings: []*armvmwarecloudsimple.CustomizationNicSetting{ + // { + // Adapter: &armvmwarecloudsimple.CustomizationIPSettings{ + // IP: &armvmwarecloudsimple.CustomizationIPAddress{ + // Type: to.Ptr(armvmwarecloudsimple.CustomizationIPAddressTypeDHCPIP), + // }, + // }, + // }}, + // }, + // Version: to.Ptr("1568102846"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/GetCustomizationPolicy.json +func ExampleCustomizationPoliciesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewCustomizationPoliciesClient().Get(ctx, "myResourceGroup", "myPrivateCloud", "Linux1", 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.CustomizationPolicy = armvmwarecloudsimple.CustomizationPolicy{ + // Name: to.Ptr("Linux1"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/customizationPolicies"), + // ID: to.Ptr("/subscriptions/b85c4986-56ae-4ebd-b5c5-a1595ca3dab1/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/foobar/customizationpolicies/Linux1"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.CustomizationPolicyProperties{ + // Type: to.Ptr(armvmwarecloudsimple.CustomizationPolicyPropertiesTypeLINUX), + // PrivateCloudID: to.Ptr("/subscriptions/b85c4986-56ae-4ebd-b5c5-a1595ca3dab1/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/foobar"), + // Specification: &armvmwarecloudsimple.CustomizationSpecification{ + // Identity: &armvmwarecloudsimple.CustomizationIdentity{ + // Type: to.Ptr(armvmwarecloudsimple.CustomizationIdentityTypeLINUX), + // HostName: &armvmwarecloudsimple.CustomizationHostName{ + // Type: to.Ptr(armvmwarecloudsimple.CustomizationHostNameTypeUSERDEFINED), + // }, + // UserData: &armvmwarecloudsimple.CustomizationIdentityUserData{ + // IsPasswordPredefined: to.Ptr(false), + // }, + // }, + // NicSettings: []*armvmwarecloudsimple.CustomizationNicSetting{ + // { + // Adapter: &armvmwarecloudsimple.CustomizationIPSettings{ + // IP: &armvmwarecloudsimple.CustomizationIPAddress{ + // Type: to.Ptr(armvmwarecloudsimple.CustomizationIPAddressTypeUSERDEFINED), + // }, + // }, + // }}, + // }, + // Version: to.Ptr("1568102823"), + // }, + // } +} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_dedicatedcloudnodes_client.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/dedicatedcloudnodes_client.go similarity index 86% rename from sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_dedicatedcloudnodes_client.go rename to sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/dedicatedcloudnodes_client.go index 0247bc9097ec..5c8be036404e 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_dedicatedcloudnodes_client.go +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/dedicatedcloudnodes_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 armvmwarecloudsimple @@ -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 ( // DedicatedCloudNodesClient contains the methods for the DedicatedCloudNodes group. // Don't use this type directly, use NewDedicatedCloudNodesClient() instead. type DedicatedCloudNodesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDedicatedCloudNodesClient creates a new instance of DedicatedCloudNodesClient 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 NewDedicatedCloudNodesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DedicatedCloudNodesClient, 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+".DedicatedCloudNodesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DedicatedCloudNodesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Returns dedicated cloud node by its name // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// resourceGroupName - The name of the resource group -// referer - referer url -// dedicatedCloudNodeName - dedicated cloud node name -// dedicatedCloudNodeRequest - Create Dedicated Cloud Node request -// options - DedicatedCloudNodesClientBeginCreateOrUpdateOptions contains the optional parameters for the DedicatedCloudNodesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group +// - referer - referer url +// - dedicatedCloudNodeName - dedicated cloud node name +// - dedicatedCloudNodeRequest - Create Dedicated Cloud Node request +// - options - DedicatedCloudNodesClientBeginCreateOrUpdateOptions contains the optional parameters for the DedicatedCloudNodesClient.BeginCreateOrUpdate +// method. func (client *DedicatedCloudNodesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, referer string, dedicatedCloudNodeName string, dedicatedCloudNodeRequest DedicatedCloudNode, options *DedicatedCloudNodesClientBeginCreateOrUpdateOptions) (*runtime.Poller[DedicatedCloudNodesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, referer, dedicatedCloudNodeName, dedicatedCloudNodeRequest, options) if err != nil { return nil, err } - return runtime.NewPoller[DedicatedCloudNodesClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[DedicatedCloudNodesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DedicatedCloudNodesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DedicatedCloudNodesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Returns dedicated cloud node by its name // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 func (client *DedicatedCloudNodesClient) createOrUpdate(ctx context.Context, resourceGroupName string, referer string, dedicatedCloudNodeName string, dedicatedCloudNodeRequest DedicatedCloudNode, options *DedicatedCloudNodesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, referer, dedicatedCloudNodeName, dedicatedCloudNodeRequest, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -109,7 +101,7 @@ func (client *DedicatedCloudNodesClient) createOrUpdateCreateRequest(ctx context return nil, errors.New("parameter dedicatedCloudNodeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dedicatedCloudNodeName}", url.PathEscape(dedicatedCloudNodeName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -123,17 +115,18 @@ func (client *DedicatedCloudNodesClient) createOrUpdateCreateRequest(ctx context // Delete - Delete dedicated cloud node // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// resourceGroupName - The name of the resource group -// dedicatedCloudNodeName - dedicated cloud node name -// options - DedicatedCloudNodesClientDeleteOptions contains the optional parameters for the DedicatedCloudNodesClient.Delete -// method. +// - resourceGroupName - The name of the resource group +// - dedicatedCloudNodeName - dedicated cloud node name +// - options - DedicatedCloudNodesClientDeleteOptions contains the optional parameters for the DedicatedCloudNodesClient.Delete +// method. func (client *DedicatedCloudNodesClient) Delete(ctx context.Context, resourceGroupName string, dedicatedCloudNodeName string, options *DedicatedCloudNodesClientDeleteOptions) (DedicatedCloudNodesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, dedicatedCloudNodeName, options) if err != nil { return DedicatedCloudNodesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DedicatedCloudNodesClientDeleteResponse{}, err } @@ -158,7 +151,7 @@ func (client *DedicatedCloudNodesClient) deleteCreateRequest(ctx context.Context return nil, errors.New("parameter dedicatedCloudNodeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dedicatedCloudNodeName}", url.PathEscape(dedicatedCloudNodeName)) - 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,16 +164,17 @@ func (client *DedicatedCloudNodesClient) deleteCreateRequest(ctx context.Context // Get - Returns dedicated cloud node // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// resourceGroupName - The name of the resource group -// dedicatedCloudNodeName - dedicated cloud node name -// options - DedicatedCloudNodesClientGetOptions contains the optional parameters for the DedicatedCloudNodesClient.Get method. +// - resourceGroupName - The name of the resource group +// - dedicatedCloudNodeName - dedicated cloud node name +// - options - DedicatedCloudNodesClientGetOptions contains the optional parameters for the DedicatedCloudNodesClient.Get method. func (client *DedicatedCloudNodesClient) Get(ctx context.Context, resourceGroupName string, dedicatedCloudNodeName string, options *DedicatedCloudNodesClientGetOptions) (DedicatedCloudNodesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, dedicatedCloudNodeName, options) if err != nil { return DedicatedCloudNodesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DedicatedCloudNodesClientGetResponse{}, err } @@ -205,7 +199,7 @@ func (client *DedicatedCloudNodesClient) getCreateRequest(ctx context.Context, r return nil, errors.New("parameter dedicatedCloudNodeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dedicatedCloudNodeName}", url.PathEscape(dedicatedCloudNodeName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -226,11 +220,11 @@ func (client *DedicatedCloudNodesClient) getHandleResponse(resp *http.Response) } // NewListByResourceGroupPager - Returns list of dedicate cloud nodes within resource group -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// resourceGroupName - The name of the resource group -// options - DedicatedCloudNodesClientListByResourceGroupOptions contains the optional parameters for the DedicatedCloudNodesClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group +// - options - DedicatedCloudNodesClientListByResourceGroupOptions contains the optional parameters for the DedicatedCloudNodesClient.NewListByResourceGroupPager +// method. func (client *DedicatedCloudNodesClient) NewListByResourceGroupPager(resourceGroupName string, options *DedicatedCloudNodesClientListByResourceGroupOptions) *runtime.Pager[DedicatedCloudNodesClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[DedicatedCloudNodesClientListByResourceGroupResponse]{ More: func(page DedicatedCloudNodesClientListByResourceGroupResponse) bool { @@ -247,7 +241,7 @@ func (client *DedicatedCloudNodesClient) NewListByResourceGroupPager(resourceGro if err != nil { return DedicatedCloudNodesClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DedicatedCloudNodesClientListByResourceGroupResponse{}, err } @@ -270,7 +264,7 @@ func (client *DedicatedCloudNodesClient) listByResourceGroupCreateRequest(ctx co return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -300,10 +294,10 @@ func (client *DedicatedCloudNodesClient) listByResourceGroupHandleResponse(resp } // NewListBySubscriptionPager - Returns list of dedicate cloud nodes within subscription -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// options - DedicatedCloudNodesClientListBySubscriptionOptions contains the optional parameters for the DedicatedCloudNodesClient.ListBySubscription -// method. +// - options - DedicatedCloudNodesClientListBySubscriptionOptions contains the optional parameters for the DedicatedCloudNodesClient.NewListBySubscriptionPager +// method. func (client *DedicatedCloudNodesClient) NewListBySubscriptionPager(options *DedicatedCloudNodesClientListBySubscriptionOptions) *runtime.Pager[DedicatedCloudNodesClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[DedicatedCloudNodesClientListBySubscriptionResponse]{ More: func(page DedicatedCloudNodesClientListBySubscriptionResponse) bool { @@ -320,7 +314,7 @@ func (client *DedicatedCloudNodesClient) NewListBySubscriptionPager(options *Ded if err != nil { return DedicatedCloudNodesClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DedicatedCloudNodesClientListBySubscriptionResponse{}, err } @@ -339,7 +333,7 @@ func (client *DedicatedCloudNodesClient) listBySubscriptionCreateRequest(ctx con return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -370,18 +364,19 @@ func (client *DedicatedCloudNodesClient) listBySubscriptionHandleResponse(resp * // Update - Patches dedicated node properties // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// resourceGroupName - The name of the resource group -// dedicatedCloudNodeName - dedicated cloud node name -// dedicatedCloudNodeRequest - Patch Dedicated Cloud Node request -// options - DedicatedCloudNodesClientUpdateOptions contains the optional parameters for the DedicatedCloudNodesClient.Update -// method. +// - resourceGroupName - The name of the resource group +// - dedicatedCloudNodeName - dedicated cloud node name +// - dedicatedCloudNodeRequest - Patch Dedicated Cloud Node request +// - options - DedicatedCloudNodesClientUpdateOptions contains the optional parameters for the DedicatedCloudNodesClient.Update +// method. func (client *DedicatedCloudNodesClient) Update(ctx context.Context, resourceGroupName string, dedicatedCloudNodeName string, dedicatedCloudNodeRequest PatchPayload, options *DedicatedCloudNodesClientUpdateOptions) (DedicatedCloudNodesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, dedicatedCloudNodeName, dedicatedCloudNodeRequest, options) if err != nil { return DedicatedCloudNodesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DedicatedCloudNodesClientUpdateResponse{}, err } @@ -406,7 +401,7 @@ func (client *DedicatedCloudNodesClient) updateCreateRequest(ctx context.Context return nil, errors.New("parameter dedicatedCloudNodeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dedicatedCloudNodeName}", url.PathEscape(dedicatedCloudNodeName)) - 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/vmwarecloudsimple/armvmwarecloudsimple/dedicatedcloudnodes_client_example_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/dedicatedcloudnodes_client_example_test.go new file mode 100644 index 000000000000..98e2546aa368 --- /dev/null +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/dedicatedcloudnodes_client_example_test.go @@ -0,0 +1,382 @@ +//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 armvmwarecloudsimple_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/vmwarecloudsimple/armvmwarecloudsimple" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListDedicatedCloudNodes.json +func ExampleDedicatedCloudNodesClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDedicatedCloudNodesClient().NewListBySubscriptionPager(&armvmwarecloudsimple.DedicatedCloudNodesClientListBySubscriptionOptions{Filter: nil, + Top: 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.DedicatedCloudNodeListResponse = armvmwarecloudsimple.DedicatedCloudNodeListResponse{ + // Value: []*armvmwarecloudsimple.DedicatedCloudNode{ + // { + // Name: to.Ptr("node-2"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/dedicatedCloudNodes"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup-1/providers/Microsoft.VMwareCloudSimple/dedicatedCloudNodes/node-2"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.DedicatedCloudNodeProperties{ + // AvailabilityZoneID: to.Ptr("az1"), + // AvailabilityZoneName: to.Ptr("Availability Zone 1"), + // CloudRackName: to.Ptr("cloud_rack_1"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-21T07:32:12.134Z"); return t}()), + // NodesCount: to.Ptr[int32](0), + // PlacementGroupID: to.Ptr("n2"), + // PlacementGroupName: to.Ptr("Placement Group 2"), + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // PrivateCloudName: to.Ptr("private_cloud_name"), + // PurchaseID: to.Ptr("225fadec-3bbe-4e61-a119-ff102da67d0d"), + // SKUDescription: &armvmwarecloudsimple.SKUDescription{ + // Name: to.Ptr("CS28-Node"), + // ID: to.Ptr("general"), + // }, + // Status: to.Ptr(armvmwarecloudsimple.NodeStatusUsed), + // VmwareClusterName: to.Ptr("Cluster"), + // }, + // SKU: &armvmwarecloudsimple.SKU{ + // Name: to.Ptr("VMware_CloudSimple_CS28"), + // }, + // }, + // { + // Name: to.Ptr("node1"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/dedicatedCloudNodes"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup-2/providers/Microsoft.VMwareCloudSimple/dedicatedCloudNodes/node-1"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.DedicatedCloudNodeProperties{ + // AvailabilityZoneID: to.Ptr("az1"), + // AvailabilityZoneName: to.Ptr("Availability Zone 1"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-22T11:57:43.891Z"); return t}()), + // NodesCount: to.Ptr[int32](0), + // PlacementGroupID: to.Ptr("n1"), + // PlacementGroupName: to.Ptr("Placement Group 1"), + // PurchaseID: to.Ptr("eb9d2e22-c787-4723-aa4f-3760b53a0a4d"), + // SKUDescription: &armvmwarecloudsimple.SKUDescription{ + // Name: to.Ptr("CS28-Node"), + // ID: to.Ptr("general"), + // }, + // Status: to.Ptr(armvmwarecloudsimple.NodeStatusUnused), + // }, + // SKU: &armvmwarecloudsimple.SKU{ + // Name: to.Ptr("VMware_CloudSimple_CS28"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListRGDedicatedCloudNodes.json +func ExampleDedicatedCloudNodesClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDedicatedCloudNodesClient().NewListByResourceGroupPager("myResourceGroup", &armvmwarecloudsimple.DedicatedCloudNodesClientListByResourceGroupOptions{Filter: nil, + Top: 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.DedicatedCloudNodeListResponse = armvmwarecloudsimple.DedicatedCloudNodeListResponse{ + // Value: []*armvmwarecloudsimple.DedicatedCloudNode{ + // { + // Name: to.Ptr("node-east-1"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/dedicatedCloudNodes"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourcegroups/myResourceGroup/providers/Microsoft.VMwareCloudSimple/dedicatedCloudNodes/node-east-1"), + // Location: to.Ptr("eastus"), + // Properties: &armvmwarecloudsimple.DedicatedCloudNodeProperties{ + // AvailabilityZoneID: to.Ptr("az1"), + // AvailabilityZoneName: to.Ptr("Availability Zone 1"), + // CloudRackName: to.Ptr("cloud_rack_1"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-21T07:32:12.134Z"); return t}()), + // NodesCount: to.Ptr[int32](0), + // PlacementGroupID: to.Ptr("n2"), + // PlacementGroupName: to.Ptr("Placement Group 2"), + // PrivateCloudID: to.Ptr("private_cloud_id"), + // PrivateCloudName: to.Ptr("private_cloud_name"), + // PurchaseID: to.Ptr("225fadec-3bbe-4e61-a119-ff102da67d0d"), + // SKUDescription: &armvmwarecloudsimple.SKUDescription{ + // Name: to.Ptr("CS28-Node"), + // ID: to.Ptr("general"), + // }, + // Status: to.Ptr(armvmwarecloudsimple.NodeStatusUsed), + // VmwareClusterName: to.Ptr("Cluster"), + // }, + // SKU: &armvmwarecloudsimple.SKU{ + // Name: to.Ptr("VMware_CloudSimple_CS28"), + // }, + // }, + // { + // Name: to.Ptr("node-east-2"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/dedicatedCloudNodes"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourcegroups/myResourceGroup/providers/Microsoft.VMwareCloudSimple/dedicatedCloudNodes/node-east-2"), + // Location: to.Ptr("eastus"), + // Properties: &armvmwarecloudsimple.DedicatedCloudNodeProperties{ + // AvailabilityZoneID: to.Ptr("az1"), + // AvailabilityZoneName: to.Ptr("Availability Zone 1"), + // CloudRackName: to.Ptr("cloud_rack_1"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-21T07:32:12.114Z"); return t}()), + // NodesCount: to.Ptr[int32](0), + // PlacementGroupID: to.Ptr("n2"), + // PlacementGroupName: to.Ptr("Placement Group 2"), + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // PrivateCloudName: to.Ptr("private_cloud_name"), + // PurchaseID: to.Ptr("225fadec-3bbe-4e61-a119-ff102da67d0d"), + // SKUDescription: &armvmwarecloudsimple.SKUDescription{ + // Name: to.Ptr("CS28-Node"), + // ID: to.Ptr("general"), + // }, + // Status: to.Ptr(armvmwarecloudsimple.NodeStatusUsed), + // VmwareClusterName: to.Ptr("Cluster"), + // }, + // SKU: &armvmwarecloudsimple.SKU{ + // Name: to.Ptr("VMware_CloudSimple_CS28"), + // }, + // }, + // { + // Name: to.Ptr("myNode"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/dedicatedCloudNodes"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourcegroups/myResourceGroup/providers/Microsoft.VMwareCloudSimple/dedicatedCloudNodes/myNode"), + // Location: to.Ptr("eastus"), + // Properties: &armvmwarecloudsimple.DedicatedCloudNodeProperties{ + // AvailabilityZoneID: to.Ptr("az1"), + // AvailabilityZoneName: to.Ptr("Availability Zone 1"), + // CloudRackName: to.Ptr("cloud_rack_1"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-08T09:35:47.961Z"); return t}()), + // NodesCount: to.Ptr[int32](0), + // PlacementGroupID: to.Ptr("n2"), + // PlacementGroupName: to.Ptr("Placement Group 2"), + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // PrivateCloudName: to.Ptr("myPrivateCloud"), + // PurchaseID: to.Ptr("b3fcd958-f19c-4421-ab46-e4fa9cc8514e"), + // SKUDescription: &armvmwarecloudsimple.SKUDescription{ + // Name: to.Ptr("CS28-Node"), + // ID: to.Ptr("general"), + // }, + // Status: to.Ptr(armvmwarecloudsimple.NodeStatusUsed), + // VmwareClusterName: to.Ptr("Cluster"), + // }, + // SKU: &armvmwarecloudsimple.SKU{ + // Name: to.Ptr("VMware_CloudSimple_CS28"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/GetDedicatedCloudNode.json +func ExampleDedicatedCloudNodesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDedicatedCloudNodesClient().Get(ctx, "myResourceGroup", "myNode", 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.DedicatedCloudNode = armvmwarecloudsimple.DedicatedCloudNode{ + // Name: to.Ptr("myNode"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/dedicatedCloudNodes"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourcegroups/myResourceGroup/providers/Microsoft.VMwareCloudSimple/dedicatedCloudNodes/myNode"), + // Location: to.Ptr("eastus"), + // Properties: &armvmwarecloudsimple.DedicatedCloudNodeProperties{ + // AvailabilityZoneID: to.Ptr("az1"), + // AvailabilityZoneName: to.Ptr("Availability Zone 1"), + // CloudRackName: to.Ptr("cloud_rack_1"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-21T07:32:12.114Z"); return t}()), + // NodesCount: to.Ptr[int32](0), + // PlacementGroupID: to.Ptr("n2"), + // PlacementGroupName: to.Ptr("Placement Group 2"), + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // PrivateCloudName: to.Ptr("private_cloud_name"), + // PurchaseID: to.Ptr("225fadec-3bbe-4e61-a119-ff102da67d0d"), + // SKUDescription: &armvmwarecloudsimple.SKUDescription{ + // Name: to.Ptr("CS28-Node"), + // ID: to.Ptr("general"), + // }, + // Status: to.Ptr(armvmwarecloudsimple.NodeStatusUsed), + // VmwareClusterName: to.Ptr("Cluster"), + // }, + // SKU: &armvmwarecloudsimple.SKU{ + // Name: to.Ptr("VMware_CloudSimple_CS28"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/CreateDedicatedCloudNode.json +func ExampleDedicatedCloudNodesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDedicatedCloudNodesClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "https://management.azure.com/", "myNode", armvmwarecloudsimple.DedicatedCloudNode{ + Location: to.Ptr("westus"), + Properties: &armvmwarecloudsimple.DedicatedCloudNodeProperties{ + AvailabilityZoneID: to.Ptr("az1"), + NodesCount: to.Ptr[int32](1), + PlacementGroupID: to.Ptr("n1"), + PurchaseID: to.Ptr("56acbd46-3d36-4bbf-9b08-57c30fdf6932"), + SKUDescription: &armvmwarecloudsimple.SKUDescription{ + Name: to.Ptr("CS28-Node"), + ID: to.Ptr("general"), + }, + }, + SKU: &armvmwarecloudsimple.SKU{ + Name: to.Ptr("VMware_CloudSimple_CS28"), + }, + }, 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.DedicatedCloudNode = armvmwarecloudsimple.DedicatedCloudNode{ + // Name: to.Ptr("myNode"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/dedicatedCloudNodes"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.VMwareCloudSimple/dedicatedCloudNodes/myNode"), + // Location: to.Ptr("westus"), + // Properties: &armvmwarecloudsimple.DedicatedCloudNodeProperties{ + // AvailabilityZoneID: to.Ptr("az1"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-21T13:43:26.441Z"); return t}()), + // NodesCount: to.Ptr[int32](0), + // PlacementGroupID: to.Ptr("n1"), + // ProvisioningState: to.Ptr("Succeeded"), + // PurchaseID: to.Ptr("56acbd46-3d36-4bbf-9b08-57c30fdf6932"), + // SKUDescription: &armvmwarecloudsimple.SKUDescription{ + // Name: to.Ptr("CS28-Node"), + // ID: to.Ptr("general"), + // }, + // Status: to.Ptr(armvmwarecloudsimple.NodeStatusUnused), + // }, + // SKU: &armvmwarecloudsimple.SKU{ + // Name: to.Ptr("VMware_CloudSimple_CS28"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/DeleteDedicatedCloudNode.json +func ExampleDedicatedCloudNodesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewDedicatedCloudNodesClient().Delete(ctx, "myResourceGroup", "myNode", 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/PatchDedicatedCloudNode.json +func ExampleDedicatedCloudNodesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDedicatedCloudNodesClient().Update(ctx, "myResourceGroup", "myNode", armvmwarecloudsimple.PatchPayload{ + Tags: map[string]*string{ + "myTag": 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.DedicatedCloudNode = armvmwarecloudsimple.DedicatedCloudNode{ + // Name: to.Ptr("myNode"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/dedicatedCloudNodes"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.VMwareCloudSimple/dedicatedCloudNodes/myNode"), + // Location: to.Ptr("westus"), + // Properties: &armvmwarecloudsimple.DedicatedCloudNodeProperties{ + // AvailabilityZoneID: to.Ptr("az1"), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-21T13:43:26.441Z"); return t}()), + // NodesCount: to.Ptr[int32](0), + // PlacementGroupID: to.Ptr("n1"), + // PurchaseID: to.Ptr("56acbd46-3d36-4bbf-9b08-57c30fdf6932"), + // SKUDescription: &armvmwarecloudsimple.SKUDescription{ + // Name: to.Ptr("CS28-Node"), + // ID: to.Ptr("general"), + // }, + // Status: to.Ptr(armvmwarecloudsimple.NodeStatusUnused), + // }, + // Tags: map[string]*string{ + // "myTag": to.Ptr("tagValue"), + // }, + // } +} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_dedicatedcloudservices_client.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/dedicatedcloudservices_client.go similarity index 87% rename from sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_dedicatedcloudservices_client.go rename to sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/dedicatedcloudservices_client.go index c5be79ab1b5d..c578b791d0f9 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_dedicatedcloudservices_client.go +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/dedicatedcloudservices_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 armvmwarecloudsimple @@ -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 ( // DedicatedCloudServicesClient contains the methods for the DedicatedCloudServices group. // Don't use this type directly, use NewDedicatedCloudServicesClient() instead. type DedicatedCloudServicesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDedicatedCloudServicesClient creates a new instance of DedicatedCloudServicesClient 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 NewDedicatedCloudServicesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DedicatedCloudServicesClient, 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+".DedicatedCloudServicesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DedicatedCloudServicesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create dedicate cloud service // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// resourceGroupName - The name of the resource group -// dedicatedCloudServiceName - dedicated cloud Service name -// dedicatedCloudServiceRequest - Create Dedicated Cloud Service request -// options - DedicatedCloudServicesClientCreateOrUpdateOptions contains the optional parameters for the DedicatedCloudServicesClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group +// - dedicatedCloudServiceName - dedicated cloud Service name +// - dedicatedCloudServiceRequest - Create Dedicated Cloud Service request +// - options - DedicatedCloudServicesClientCreateOrUpdateOptions contains the optional parameters for the DedicatedCloudServicesClient.CreateOrUpdate +// method. func (client *DedicatedCloudServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, dedicatedCloudServiceName string, dedicatedCloudServiceRequest DedicatedCloudService, options *DedicatedCloudServicesClientCreateOrUpdateOptions) (DedicatedCloudServicesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, dedicatedCloudServiceName, dedicatedCloudServiceRequest, options) if err != nil { return DedicatedCloudServicesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DedicatedCloudServicesClientCreateOrUpdateResponse{}, err } @@ -93,7 +84,7 @@ func (client *DedicatedCloudServicesClient) createOrUpdateCreateRequest(ctx cont return nil, errors.New("parameter dedicatedCloudServiceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dedicatedCloudServiceName}", url.PathEscape(dedicatedCloudServiceName)) - 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,32 +106,34 @@ func (client *DedicatedCloudServicesClient) createOrUpdateHandleResponse(resp *h // BeginDelete - Delete dedicate cloud service // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// resourceGroupName - The name of the resource group -// dedicatedCloudServiceName - dedicated cloud service name -// options - DedicatedCloudServicesClientBeginDeleteOptions contains the optional parameters for the DedicatedCloudServicesClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group +// - dedicatedCloudServiceName - dedicated cloud service name +// - options - DedicatedCloudServicesClientBeginDeleteOptions contains the optional parameters for the DedicatedCloudServicesClient.BeginDelete +// method. func (client *DedicatedCloudServicesClient) BeginDelete(ctx context.Context, resourceGroupName string, dedicatedCloudServiceName string, options *DedicatedCloudServicesClientBeginDeleteOptions) (*runtime.Poller[DedicatedCloudServicesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, dedicatedCloudServiceName, options) if err != nil { return nil, err } - return runtime.NewPoller[DedicatedCloudServicesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[DedicatedCloudServicesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DedicatedCloudServicesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DedicatedCloudServicesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete dedicate cloud service // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 func (client *DedicatedCloudServicesClient) deleteOperation(ctx context.Context, resourceGroupName string, dedicatedCloudServiceName string, options *DedicatedCloudServicesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, dedicatedCloudServiceName, 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 } @@ -165,7 +158,7 @@ func (client *DedicatedCloudServicesClient) deleteCreateRequest(ctx context.Cont return nil, errors.New("parameter dedicatedCloudServiceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dedicatedCloudServiceName}", url.PathEscape(dedicatedCloudServiceName)) - 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 *DedicatedCloudServicesClient) deleteCreateRequest(ctx context.Cont // Get - Returns Dedicate Cloud Service // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// resourceGroupName - The name of the resource group -// dedicatedCloudServiceName - dedicated cloud Service name -// options - DedicatedCloudServicesClientGetOptions contains the optional parameters for the DedicatedCloudServicesClient.Get -// method. +// - resourceGroupName - The name of the resource group +// - dedicatedCloudServiceName - dedicated cloud Service name +// - options - DedicatedCloudServicesClientGetOptions contains the optional parameters for the DedicatedCloudServicesClient.Get +// method. func (client *DedicatedCloudServicesClient) Get(ctx context.Context, resourceGroupName string, dedicatedCloudServiceName string, options *DedicatedCloudServicesClientGetOptions) (DedicatedCloudServicesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, dedicatedCloudServiceName, options) if err != nil { return DedicatedCloudServicesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DedicatedCloudServicesClientGetResponse{}, err } @@ -213,7 +207,7 @@ func (client *DedicatedCloudServicesClient) getCreateRequest(ctx context.Context return nil, errors.New("parameter dedicatedCloudServiceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dedicatedCloudServiceName}", url.PathEscape(dedicatedCloudServiceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -234,11 +228,11 @@ func (client *DedicatedCloudServicesClient) getHandleResponse(resp *http.Respons } // NewListByResourceGroupPager - Returns list of dedicated cloud services within a resource group -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// resourceGroupName - The name of the resource group -// options - DedicatedCloudServicesClientListByResourceGroupOptions contains the optional parameters for the DedicatedCloudServicesClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group +// - options - DedicatedCloudServicesClientListByResourceGroupOptions contains the optional parameters for the DedicatedCloudServicesClient.NewListByResourceGroupPager +// method. func (client *DedicatedCloudServicesClient) NewListByResourceGroupPager(resourceGroupName string, options *DedicatedCloudServicesClientListByResourceGroupOptions) *runtime.Pager[DedicatedCloudServicesClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[DedicatedCloudServicesClientListByResourceGroupResponse]{ More: func(page DedicatedCloudServicesClientListByResourceGroupResponse) bool { @@ -255,7 +249,7 @@ func (client *DedicatedCloudServicesClient) NewListByResourceGroupPager(resource if err != nil { return DedicatedCloudServicesClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DedicatedCloudServicesClientListByResourceGroupResponse{}, err } @@ -278,7 +272,7 @@ func (client *DedicatedCloudServicesClient) 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 } @@ -308,10 +302,10 @@ func (client *DedicatedCloudServicesClient) listByResourceGroupHandleResponse(re } // NewListBySubscriptionPager - Returns list of dedicated cloud services within a subscription -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// options - DedicatedCloudServicesClientListBySubscriptionOptions contains the optional parameters for the DedicatedCloudServicesClient.ListBySubscription -// method. +// - options - DedicatedCloudServicesClientListBySubscriptionOptions contains the optional parameters for the DedicatedCloudServicesClient.NewListBySubscriptionPager +// method. func (client *DedicatedCloudServicesClient) NewListBySubscriptionPager(options *DedicatedCloudServicesClientListBySubscriptionOptions) *runtime.Pager[DedicatedCloudServicesClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[DedicatedCloudServicesClientListBySubscriptionResponse]{ More: func(page DedicatedCloudServicesClientListBySubscriptionResponse) bool { @@ -328,7 +322,7 @@ func (client *DedicatedCloudServicesClient) NewListBySubscriptionPager(options * if err != nil { return DedicatedCloudServicesClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DedicatedCloudServicesClientListBySubscriptionResponse{}, err } @@ -347,7 +341,7 @@ func (client *DedicatedCloudServicesClient) listBySubscriptionCreateRequest(ctx return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -378,18 +372,19 @@ func (client *DedicatedCloudServicesClient) listBySubscriptionHandleResponse(res // Update - Patch dedicated cloud service's properties // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// resourceGroupName - The name of the resource group -// dedicatedCloudServiceName - dedicated cloud service name -// dedicatedCloudServiceRequest - Patch Dedicated Cloud Service request -// options - DedicatedCloudServicesClientUpdateOptions contains the optional parameters for the DedicatedCloudServicesClient.Update -// method. +// - resourceGroupName - The name of the resource group +// - dedicatedCloudServiceName - dedicated cloud service name +// - dedicatedCloudServiceRequest - Patch Dedicated Cloud Service request +// - options - DedicatedCloudServicesClientUpdateOptions contains the optional parameters for the DedicatedCloudServicesClient.Update +// method. func (client *DedicatedCloudServicesClient) Update(ctx context.Context, resourceGroupName string, dedicatedCloudServiceName string, dedicatedCloudServiceRequest PatchPayload, options *DedicatedCloudServicesClientUpdateOptions) (DedicatedCloudServicesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, dedicatedCloudServiceName, dedicatedCloudServiceRequest, options) if err != nil { return DedicatedCloudServicesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DedicatedCloudServicesClientUpdateResponse{}, err } @@ -414,7 +409,7 @@ func (client *DedicatedCloudServicesClient) updateCreateRequest(ctx context.Cont return nil, errors.New("parameter dedicatedCloudServiceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{dedicatedCloudServiceName}", url.PathEscape(dedicatedCloudServiceName)) - 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/vmwarecloudsimple/armvmwarecloudsimple/dedicatedcloudservices_client_example_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/dedicatedcloudservices_client_example_test.go new file mode 100644 index 000000000000..9506b4ec2951 --- /dev/null +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/dedicatedcloudservices_client_example_test.go @@ -0,0 +1,251 @@ +//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 armvmwarecloudsimple_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/vmwarecloudsimple/armvmwarecloudsimple" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListDedicatedCloudServices.json +func ExampleDedicatedCloudServicesClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDedicatedCloudServicesClient().NewListBySubscriptionPager(&armvmwarecloudsimple.DedicatedCloudServicesClientListBySubscriptionOptions{Filter: nil, + Top: 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.DedicatedCloudServiceListResponse = armvmwarecloudsimple.DedicatedCloudServiceListResponse{ + // Value: []*armvmwarecloudsimple.DedicatedCloudService{ + // { + // Name: to.Ptr("service-east"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/dedicatedCloudServices"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup-1/providers/Microsoft.VMwareCloudSimple/dedicatedCloudServices/service-east"), + // Location: to.Ptr("eastus"), + // Properties: &armvmwarecloudsimple.DedicatedCloudServiceProperties{ + // GatewaySubnet: to.Ptr("10.101.201.0/28"), + // IsAccountOnboarded: to.Ptr(armvmwarecloudsimple.OnboardingStatusOnBoarded), + // ServiceURL: to.Ptr("https://eastus-he.azure.cloudsimple.com"), + // }, + // }, + // { + // Name: to.Ptr("service-west"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/dedicatedCloudServices"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup-2/providers/Microsoft.VMwareCloudSimple/dedicatedCloudServices/service-west"), + // Location: to.Ptr("westus"), + // Properties: &armvmwarecloudsimple.DedicatedCloudServiceProperties{ + // GatewaySubnet: to.Ptr("10.0.0.0/28"), + // IsAccountOnboarded: to.Ptr(armvmwarecloudsimple.OnboardingStatusOnBoarded), + // ServiceURL: to.Ptr("https://westus-he.azure.cloudsimple.com"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListRGDedicatedCloudServices.json +func ExampleDedicatedCloudServicesClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDedicatedCloudServicesClient().NewListByResourceGroupPager("myResourceGroup", &armvmwarecloudsimple.DedicatedCloudServicesClientListByResourceGroupOptions{Filter: nil, + Top: 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.DedicatedCloudServiceListResponse = armvmwarecloudsimple.DedicatedCloudServiceListResponse{ + // Value: []*armvmwarecloudsimple.DedicatedCloudService{ + // { + // Name: to.Ptr("service-east"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/dedicatedCloudServices"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.VMwareCloudSimple/dedicatedCloudServices/service-east"), + // Location: to.Ptr("eastus"), + // Properties: &armvmwarecloudsimple.DedicatedCloudServiceProperties{ + // GatewaySubnet: to.Ptr("10.101.201.0/28"), + // IsAccountOnboarded: to.Ptr(armvmwarecloudsimple.OnboardingStatusOnBoarded), + // ServiceURL: to.Ptr("https://eastus-he.azure.cloudsimple.com"), + // }, + // }, + // { + // Name: to.Ptr("service-west"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/dedicatedCloudServices"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.VMwareCloudSimple/dedicatedCloudServices/service-west"), + // Location: to.Ptr("westus"), + // Properties: &armvmwarecloudsimple.DedicatedCloudServiceProperties{ + // GatewaySubnet: to.Ptr("10.0.0.0/28"), + // IsAccountOnboarded: to.Ptr(armvmwarecloudsimple.OnboardingStatusOnBoarded), + // ServiceURL: to.Ptr("https://westus-he.azure.cloudsimple.com"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/GetDedicatedCloudService.json +func ExampleDedicatedCloudServicesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDedicatedCloudServicesClient().Get(ctx, "myResourceGroup", "myService", 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.DedicatedCloudService = armvmwarecloudsimple.DedicatedCloudService{ + // Name: to.Ptr("myService"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/dedicatedCloudServices"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.VMwareCloudSimple/dedicatedCloudServices/myService"), + // Location: to.Ptr("westus"), + // Properties: &armvmwarecloudsimple.DedicatedCloudServiceProperties{ + // GatewaySubnet: to.Ptr("10.0.10.0/28"), + // IsAccountOnboarded: to.Ptr(armvmwarecloudsimple.OnboardingStatusNotOnBoarded), + // Nodes: to.Ptr[int32](1), + // ServiceURL: to.Ptr("https://westus-he.azure.cloudsimple.com"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/CreateDedicatedCloudService.json +func ExampleDedicatedCloudServicesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDedicatedCloudServicesClient().CreateOrUpdate(ctx, "myResourceGroup", "myService", armvmwarecloudsimple.DedicatedCloudService{ + Location: to.Ptr("westus"), + Properties: &armvmwarecloudsimple.DedicatedCloudServiceProperties{ + GatewaySubnet: to.Ptr("10.0.0.0"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DedicatedCloudService = armvmwarecloudsimple.DedicatedCloudService{ + // Name: to.Ptr("myService"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/dedicatedCloudServices"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.VMwareCloudSimple/dedicatedCloudServices/myService"), + // Location: to.Ptr("westus"), + // Properties: &armvmwarecloudsimple.DedicatedCloudServiceProperties{ + // GatewaySubnet: to.Ptr("10.0.10.0/28"), + // IsAccountOnboarded: to.Ptr(armvmwarecloudsimple.OnboardingStatusNotOnBoarded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/DeleteDedicatedCloudService.json +func ExampleDedicatedCloudServicesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDedicatedCloudServicesClient().BeginDelete(ctx, "myResourceGroup", "myService", 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/PatchDedicatedService.json +func ExampleDedicatedCloudServicesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDedicatedCloudServicesClient().Update(ctx, "myResourceGroup", "myService", armvmwarecloudsimple.PatchPayload{ + Tags: map[string]*string{ + "myTag": 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.DedicatedCloudService = armvmwarecloudsimple.DedicatedCloudService{ + // Name: to.Ptr("myService"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/dedicatedCloudServices"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.VMwareCloudSimple/dedicatedCloudServices/myService"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.DedicatedCloudServiceProperties{ + // GatewaySubnet: to.Ptr("10.0.0.0/28"), + // IsAccountOnboarded: to.Ptr(armvmwarecloudsimple.OnboardingStatusOnBoarded), + // ServiceURL: to.Ptr("https://westus-he.azure.cloudsimple.com"), + // }, + // Tags: map[string]*string{ + // "myTag": to.Ptr("tagValue"), + // }, + // } +} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/go.mod b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/go.mod index a9b69682dd05..f03c13618d87 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/go.mod +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/vmwarecloudsimple/a 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/vmwarecloudsimple/armvmwarecloudsimple/go.sum b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/go.sum +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/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/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_models.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/models.go similarity index 97% rename from sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_models.go rename to sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/models.go index 3688dce7788c..178931fe8692 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_models.go +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/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 armvmwarecloudsimple @@ -169,7 +170,8 @@ type CustomizationPoliciesClientGetOptions struct { // placeholder for future optional parameters } -// CustomizationPoliciesClientListOptions contains the optional parameters for the CustomizationPoliciesClient.List method. +// CustomizationPoliciesClientListOptions contains the optional parameters for the CustomizationPoliciesClient.NewListPager +// method. type CustomizationPoliciesClientListOptions struct { // The filter to apply on the list operation. only type is allowed here as a filter e.g. $filter=type eq 'xxxx' Filter *string @@ -324,7 +326,7 @@ type DedicatedCloudNodesClientGetOptions struct { // placeholder for future optional parameters } -// DedicatedCloudNodesClientListByResourceGroupOptions contains the optional parameters for the DedicatedCloudNodesClient.ListByResourceGroup +// DedicatedCloudNodesClientListByResourceGroupOptions contains the optional parameters for the DedicatedCloudNodesClient.NewListByResourceGroupPager // method. type DedicatedCloudNodesClientListByResourceGroupOptions struct { // The filter to apply on the list operation @@ -335,7 +337,7 @@ type DedicatedCloudNodesClientListByResourceGroupOptions struct { Top *int32 } -// DedicatedCloudNodesClientListBySubscriptionOptions contains the optional parameters for the DedicatedCloudNodesClient.ListBySubscription +// DedicatedCloudNodesClientListBySubscriptionOptions contains the optional parameters for the DedicatedCloudNodesClient.NewListBySubscriptionPager // method. type DedicatedCloudNodesClientListBySubscriptionOptions struct { // The filter to apply on the list operation @@ -414,7 +416,7 @@ type DedicatedCloudServicesClientGetOptions struct { // placeholder for future optional parameters } -// DedicatedCloudServicesClientListByResourceGroupOptions contains the optional parameters for the DedicatedCloudServicesClient.ListByResourceGroup +// DedicatedCloudServicesClientListByResourceGroupOptions contains the optional parameters for the DedicatedCloudServicesClient.NewListByResourceGroupPager // method. type DedicatedCloudServicesClientListByResourceGroupOptions struct { // The filter to apply on the list operation @@ -425,7 +427,7 @@ type DedicatedCloudServicesClientListByResourceGroupOptions struct { Top *int32 } -// DedicatedCloudServicesClientListBySubscriptionOptions contains the optional parameters for the DedicatedCloudServicesClient.ListBySubscription +// DedicatedCloudServicesClientListBySubscriptionOptions contains the optional parameters for the DedicatedCloudServicesClient.NewListBySubscriptionPager // method. type DedicatedCloudServicesClientListBySubscriptionOptions struct { // The filter to apply on the list operation @@ -519,7 +521,7 @@ type OperationsClientGetOptions struct { // placeholder for future optional parameters } -// 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 } @@ -637,7 +639,7 @@ type PrivateCloudsClientGetOptions struct { // placeholder for future optional parameters } -// PrivateCloudsClientListOptions contains the optional parameters for the PrivateCloudsClient.List method. +// PrivateCloudsClientListOptions contains the optional parameters for the PrivateCloudsClient.NewListPager method. type PrivateCloudsClientListOptions struct { // placeholder for future optional parameters } @@ -674,7 +676,7 @@ type ResourcePoolsClientGetOptions struct { // placeholder for future optional parameters } -// ResourcePoolsClientListOptions contains the optional parameters for the ResourcePoolsClient.List method. +// ResourcePoolsClientListOptions contains the optional parameters for the ResourcePoolsClient.NewListPager method. type ResourcePoolsClientListOptions struct { // placeholder for future optional parameters } @@ -752,7 +754,7 @@ type SKUDescription struct { Name *string `json:"name,omitempty"` } -// SKUsAvailabilityClientListOptions contains the optional parameters for the SKUsAvailabilityClient.List method. +// SKUsAvailabilityClientListOptions contains the optional parameters for the SKUsAvailabilityClient.NewListPager method. type SKUsAvailabilityClientListOptions struct { // sku id, if no sku is passed availability for all skus will be returned SKUID *string @@ -792,7 +794,7 @@ type UsageName struct { Value *string `json:"value,omitempty"` } -// UsagesClientListOptions contains the optional parameters for the UsagesClient.List method. +// UsagesClientListOptions contains the optional parameters for the UsagesClient.NewListPager method. type UsagesClientListOptions struct { // The filter to apply on the list operation. only name.value is allowed here as a filter e.g. $filter=name.value eq 'xxxx' Filter *string @@ -1013,7 +1015,8 @@ type VirtualMachineTemplatesClientGetOptions struct { // placeholder for future optional parameters } -// VirtualMachineTemplatesClientListOptions contains the optional parameters for the VirtualMachineTemplatesClient.List method. +// VirtualMachineTemplatesClientListOptions contains the optional parameters for the VirtualMachineTemplatesClient.NewListPager +// method. type VirtualMachineTemplatesClientListOptions struct { // placeholder for future optional parameters } @@ -1058,7 +1061,7 @@ type VirtualMachinesClientGetOptions struct { // placeholder for future optional parameters } -// VirtualMachinesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachinesClient.ListByResourceGroup +// VirtualMachinesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachinesClient.NewListByResourceGroupPager // method. type VirtualMachinesClientListByResourceGroupOptions struct { // The filter to apply on the list operation @@ -1069,7 +1072,7 @@ type VirtualMachinesClientListByResourceGroupOptions struct { Top *int32 } -// VirtualMachinesClientListBySubscriptionOptions contains the optional parameters for the VirtualMachinesClient.ListBySubscription +// VirtualMachinesClientListBySubscriptionOptions contains the optional parameters for the VirtualMachinesClient.NewListBySubscriptionPager // method. type VirtualMachinesClientListBySubscriptionOptions struct { // The filter to apply on the list operation @@ -1121,7 +1124,7 @@ type VirtualNetworksClientGetOptions struct { // placeholder for future optional parameters } -// VirtualNetworksClientListOptions contains the optional parameters for the VirtualNetworksClient.List method. +// VirtualNetworksClientListOptions contains the optional parameters for the VirtualNetworksClient.NewListPager method. type VirtualNetworksClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/models_serde.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/models_serde.go new file mode 100644 index 000000000000..a5c6f5677c03 --- /dev/null +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/models_serde.go @@ -0,0 +1,2306 @@ +//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 armvmwarecloudsimple + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AvailableOperation. +func (a AvailableOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", a.Display) + populate(objectMap, "isDataAction", a.IsDataAction) + populate(objectMap, "name", a.Name) + populate(objectMap, "origin", a.Origin) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvailableOperation. +func (a *AvailableOperation) UnmarshalJSON(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 "display": + err = unpopulate(val, "Display", &a.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &a.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &a.Origin) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AvailableOperationDisplay. +func (a AvailableOperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", a.Description) + populate(objectMap, "operation", a.Operation) + populate(objectMap, "provider", a.Provider) + populate(objectMap, "resource", a.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvailableOperationDisplay. +func (a *AvailableOperationDisplay) UnmarshalJSON(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 "description": + err = unpopulate(val, "Description", &a.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &a.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &a.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &a.Resource) + 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 AvailableOperationDisplayPropertyServiceSpecification. +func (a AvailableOperationDisplayPropertyServiceSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "serviceSpecification", a.ServiceSpecification) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvailableOperationDisplayPropertyServiceSpecification. +func (a *AvailableOperationDisplayPropertyServiceSpecification) UnmarshalJSON(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 "serviceSpecification": + err = unpopulate(val, "ServiceSpecification", &a.ServiceSpecification) + 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 AvailableOperationDisplayPropertyServiceSpecificationMetricsItem. +func (a AvailableOperationDisplayPropertyServiceSpecificationMetricsItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "aggregationType", a.AggregationType) + populate(objectMap, "displayDescription", a.DisplayDescription) + populate(objectMap, "displayName", a.DisplayName) + populate(objectMap, "name", a.Name) + populate(objectMap, "unit", a.Unit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvailableOperationDisplayPropertyServiceSpecificationMetricsItem. +func (a *AvailableOperationDisplayPropertyServiceSpecificationMetricsItem) UnmarshalJSON(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 "aggregationType": + err = unpopulate(val, "AggregationType", &a.AggregationType) + delete(rawMsg, key) + case "displayDescription": + err = unpopulate(val, "DisplayDescription", &a.DisplayDescription) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &a.DisplayName) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "unit": + err = unpopulate(val, "Unit", &a.Unit) + 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 AvailableOperationDisplayPropertyServiceSpecificationMetricsList. +func (a AvailableOperationDisplayPropertyServiceSpecificationMetricsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "metricSpecifications", a.MetricSpecifications) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvailableOperationDisplayPropertyServiceSpecificationMetricsList. +func (a *AvailableOperationDisplayPropertyServiceSpecificationMetricsList) UnmarshalJSON(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 "metricSpecifications": + err = unpopulate(val, "MetricSpecifications", &a.MetricSpecifications) + 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 AvailableOperationsListResponse. +func (a AvailableOperationsListResponse) 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 AvailableOperationsListResponse. +func (a *AvailableOperationsListResponse) UnmarshalJSON(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 CSRPError. +func (c CSRPError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", c.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CSRPError. +func (c *CSRPError) UnmarshalJSON(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 "error": + err = unpopulate(val, "Error", &c.Error) + 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 CSRPErrorBody. +func (c CSRPErrorBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", c.Code) + populate(objectMap, "details", c.Details) + populate(objectMap, "message", c.Message) + populate(objectMap, "target", c.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CSRPErrorBody. +func (c *CSRPErrorBody) UnmarshalJSON(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 "details": + err = unpopulate(val, "Details", &c.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &c.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &c.Target) + 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 CustomizationHostName. +func (c CustomizationHostName) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomizationHostName. +func (c *CustomizationHostName) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CustomizationIPAddress. +func (c CustomizationIPAddress) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "argument", c.Argument) + populate(objectMap, "ipAddress", c.IPAddress) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomizationIPAddress. +func (c *CustomizationIPAddress) UnmarshalJSON(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 "argument": + err = unpopulate(val, "Argument", &c.Argument) + delete(rawMsg, key) + case "ipAddress": + err = unpopulate(val, "IPAddress", &c.IPAddress) + 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 CustomizationIPSettings. +func (c CustomizationIPSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "gateway", c.Gateway) + populate(objectMap, "ip", c.IP) + populate(objectMap, "subnetMask", c.SubnetMask) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomizationIPSettings. +func (c *CustomizationIPSettings) UnmarshalJSON(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 "gateway": + err = unpopulate(val, "Gateway", &c.Gateway) + delete(rawMsg, key) + case "ip": + err = unpopulate(val, "IP", &c.IP) + delete(rawMsg, key) + case "subnetMask": + err = unpopulate(val, "SubnetMask", &c.SubnetMask) + 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 CustomizationIdentity. +func (c CustomizationIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "data", c.Data) + populate(objectMap, "hostName", c.HostName) + populate(objectMap, "type", c.Type) + populate(objectMap, "userData", c.UserData) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomizationIdentity. +func (c *CustomizationIdentity) UnmarshalJSON(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 "data": + err = unpopulate(val, "Data", &c.Data) + delete(rawMsg, key) + case "hostName": + err = unpopulate(val, "HostName", &c.HostName) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + case "userData": + err = unpopulate(val, "UserData", &c.UserData) + 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 CustomizationIdentityUserData. +func (c CustomizationIdentityUserData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "isPasswordPredefined", c.IsPasswordPredefined) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomizationIdentityUserData. +func (c *CustomizationIdentityUserData) UnmarshalJSON(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 "isPasswordPredefined": + err = unpopulate(val, "IsPasswordPredefined", &c.IsPasswordPredefined) + 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 CustomizationNicSetting. +func (c CustomizationNicSetting) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "adapter", c.Adapter) + populate(objectMap, "macAddress", c.MacAddress) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomizationNicSetting. +func (c *CustomizationNicSetting) UnmarshalJSON(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 "adapter": + err = unpopulate(val, "Adapter", &c.Adapter) + delete(rawMsg, key) + case "macAddress": + err = unpopulate(val, "MacAddress", &c.MacAddress) + 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 CustomizationPoliciesListResponse. +func (c CustomizationPoliciesListResponse) 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 CustomizationPoliciesListResponse. +func (c *CustomizationPoliciesListResponse) UnmarshalJSON(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 CustomizationPolicy. +func (c CustomizationPolicy) 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, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomizationPolicy. +func (c *CustomizationPolicy) UnmarshalJSON(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 "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 CustomizationPolicyProperties. +func (c CustomizationPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", c.Description) + populate(objectMap, "privateCloudId", c.PrivateCloudID) + populate(objectMap, "specification", c.Specification) + populate(objectMap, "type", c.Type) + populate(objectMap, "version", c.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomizationPolicyProperties. +func (c *CustomizationPolicyProperties) UnmarshalJSON(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 "description": + err = unpopulate(val, "Description", &c.Description) + delete(rawMsg, key) + case "privateCloudId": + err = unpopulate(val, "PrivateCloudID", &c.PrivateCloudID) + delete(rawMsg, key) + case "specification": + err = unpopulate(val, "Specification", &c.Specification) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &c.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CustomizationSpecification. +func (c CustomizationSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", c.Identity) + populate(objectMap, "nicSettings", c.NicSettings) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomizationSpecification. +func (c *CustomizationSpecification) UnmarshalJSON(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 "identity": + err = unpopulate(val, "Identity", &c.Identity) + delete(rawMsg, key) + case "nicSettings": + err = unpopulate(val, "NicSettings", &c.NicSettings) + 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 DedicatedCloudNode. +func (d DedicatedCloudNode) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "location", d.Location) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "sku", d.SKU) + populate(objectMap, "tags", d.Tags) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DedicatedCloudNode. +func (d *DedicatedCloudNode) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &d.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &d.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DedicatedCloudNodeListResponse. +func (d DedicatedCloudNodeListResponse) 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 DedicatedCloudNodeListResponse. +func (d *DedicatedCloudNodeListResponse) UnmarshalJSON(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 DedicatedCloudNodeProperties. +func (d DedicatedCloudNodeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "availabilityZoneId", d.AvailabilityZoneID) + populate(objectMap, "availabilityZoneName", d.AvailabilityZoneName) + populate(objectMap, "cloudRackName", d.CloudRackName) + populateTimeRFC3339(objectMap, "created", d.Created) + populate(objectMap, "nodesCount", d.NodesCount) + populate(objectMap, "placementGroupId", d.PlacementGroupID) + populate(objectMap, "placementGroupName", d.PlacementGroupName) + populate(objectMap, "privateCloudId", d.PrivateCloudID) + populate(objectMap, "privateCloudName", d.PrivateCloudName) + populate(objectMap, "provisioningState", d.ProvisioningState) + populate(objectMap, "purchaseId", d.PurchaseID) + populate(objectMap, "skuDescription", d.SKUDescription) + populate(objectMap, "status", d.Status) + populate(objectMap, "vmwareClusterName", d.VmwareClusterName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DedicatedCloudNodeProperties. +func (d *DedicatedCloudNodeProperties) UnmarshalJSON(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 "availabilityZoneId": + err = unpopulate(val, "AvailabilityZoneID", &d.AvailabilityZoneID) + delete(rawMsg, key) + case "availabilityZoneName": + err = unpopulate(val, "AvailabilityZoneName", &d.AvailabilityZoneName) + delete(rawMsg, key) + case "cloudRackName": + err = unpopulate(val, "CloudRackName", &d.CloudRackName) + delete(rawMsg, key) + case "created": + err = unpopulateTimeRFC3339(val, "Created", &d.Created) + delete(rawMsg, key) + case "nodesCount": + err = unpopulate(val, "NodesCount", &d.NodesCount) + delete(rawMsg, key) + case "placementGroupId": + err = unpopulate(val, "PlacementGroupID", &d.PlacementGroupID) + delete(rawMsg, key) + case "placementGroupName": + err = unpopulate(val, "PlacementGroupName", &d.PlacementGroupName) + delete(rawMsg, key) + case "privateCloudId": + err = unpopulate(val, "PrivateCloudID", &d.PrivateCloudID) + delete(rawMsg, key) + case "privateCloudName": + err = unpopulate(val, "PrivateCloudName", &d.PrivateCloudName) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + delete(rawMsg, key) + case "purchaseId": + err = unpopulate(val, "PurchaseID", &d.PurchaseID) + delete(rawMsg, key) + case "skuDescription": + err = unpopulate(val, "SKUDescription", &d.SKUDescription) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &d.Status) + delete(rawMsg, key) + case "vmwareClusterName": + err = unpopulate(val, "VmwareClusterName", &d.VmwareClusterName) + 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 DedicatedCloudService. +func (d DedicatedCloudService) 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 DedicatedCloudService. +func (d *DedicatedCloudService) UnmarshalJSON(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 DedicatedCloudServiceListResponse. +func (d DedicatedCloudServiceListResponse) 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 DedicatedCloudServiceListResponse. +func (d *DedicatedCloudServiceListResponse) UnmarshalJSON(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 DedicatedCloudServiceProperties. +func (d DedicatedCloudServiceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "gatewaySubnet", d.GatewaySubnet) + populate(objectMap, "isAccountOnboarded", d.IsAccountOnboarded) + populate(objectMap, "nodes", d.Nodes) + populate(objectMap, "serviceURL", d.ServiceURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DedicatedCloudServiceProperties. +func (d *DedicatedCloudServiceProperties) UnmarshalJSON(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 "gatewaySubnet": + err = unpopulate(val, "GatewaySubnet", &d.GatewaySubnet) + delete(rawMsg, key) + case "isAccountOnboarded": + err = unpopulate(val, "IsAccountOnboarded", &d.IsAccountOnboarded) + delete(rawMsg, key) + case "nodes": + err = unpopulate(val, "Nodes", &d.Nodes) + delete(rawMsg, key) + case "serviceURL": + err = unpopulate(val, "ServiceURL", &d.ServiceURL) + 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 GuestOSCustomization. +func (g GuestOSCustomization) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dnsServers", g.DNSServers) + populate(objectMap, "hostName", g.HostName) + populate(objectMap, "password", g.Password) + populate(objectMap, "policyId", g.PolicyID) + populate(objectMap, "username", g.Username) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GuestOSCustomization. +func (g *GuestOSCustomization) UnmarshalJSON(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 "dnsServers": + err = unpopulate(val, "DNSServers", &g.DNSServers) + delete(rawMsg, key) + case "hostName": + err = unpopulate(val, "HostName", &g.HostName) + delete(rawMsg, key) + case "password": + err = unpopulate(val, "Password", &g.Password) + delete(rawMsg, key) + case "policyId": + err = unpopulate(val, "PolicyID", &g.PolicyID) + delete(rawMsg, key) + case "username": + err = unpopulate(val, "Username", &g.Username) + 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 GuestOSNICCustomization. +func (g GuestOSNICCustomization) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "allocation", g.Allocation) + populate(objectMap, "dnsServers", g.DNSServers) + populate(objectMap, "gateway", g.Gateway) + populate(objectMap, "ipAddress", g.IPAddress) + populate(objectMap, "mask", g.Mask) + populate(objectMap, "primaryWinsServer", g.PrimaryWinsServer) + populate(objectMap, "secondaryWinsServer", g.SecondaryWinsServer) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GuestOSNICCustomization. +func (g *GuestOSNICCustomization) UnmarshalJSON(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 "allocation": + err = unpopulate(val, "Allocation", &g.Allocation) + delete(rawMsg, key) + case "dnsServers": + err = unpopulate(val, "DNSServers", &g.DNSServers) + delete(rawMsg, key) + case "gateway": + err = unpopulate(val, "Gateway", &g.Gateway) + delete(rawMsg, key) + case "ipAddress": + err = unpopulate(val, "IPAddress", &g.IPAddress) + delete(rawMsg, key) + case "mask": + err = unpopulate(val, "Mask", &g.Mask) + delete(rawMsg, key) + case "primaryWinsServer": + err = unpopulate(val, "PrimaryWinsServer", &g.PrimaryWinsServer) + delete(rawMsg, key) + case "secondaryWinsServer": + err = unpopulate(val, "SecondaryWinsServer", &g.SecondaryWinsServer) + 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 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 OperationResource. +func (o OperationResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "endTime", o.EndTime) + populate(objectMap, "error", o.Error) + populate(objectMap, "id", o.ID) + populate(objectMap, "name", o.Name) + populateTimeRFC3339(objectMap, "startTime", o.StartTime) + populate(objectMap, "status", o.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationResource. +func (o *OperationResource) UnmarshalJSON(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 "endTime": + err = unpopulateTimeRFC3339(val, "EndTime", &o.EndTime) + delete(rawMsg, key) + case "error": + err = unpopulate(val, "Error", &o.Error) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &o.StartTime) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &o.Status) + 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 PatchPayload. +func (p PatchPayload) 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 PatchPayload. +func (p *PatchPayload) UnmarshalJSON(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 PrivateCloud. +func (p PrivateCloud) 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) + objectMap["type"] = "Microsoft.VMwareCloudSimple/privateClouds" + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateCloud. +func (p *PrivateCloud) UnmarshalJSON(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 "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 PrivateCloudList. +func (p PrivateCloudList) 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 PrivateCloudList. +func (p *PrivateCloudList) UnmarshalJSON(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 PrivateCloudProperties. +func (p PrivateCloudProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "availabilityZoneId", p.AvailabilityZoneID) + populate(objectMap, "availabilityZoneName", p.AvailabilityZoneName) + populate(objectMap, "clustersNumber", p.ClustersNumber) + populate(objectMap, "createdBy", p.CreatedBy) + populateTimeRFC3339(objectMap, "createdOn", p.CreatedOn) + populate(objectMap, "dnsServers", p.DNSServers) + populate(objectMap, "expires", p.Expires) + populate(objectMap, "nsxType", p.NsxType) + populate(objectMap, "placementGroupId", p.PlacementGroupID) + populate(objectMap, "placementGroupName", p.PlacementGroupName) + populate(objectMap, "privateCloudId", p.PrivateCloudID) + populate(objectMap, "resourcePools", p.ResourcePools) + populate(objectMap, "state", p.State) + populate(objectMap, "totalCpuCores", p.TotalCPUCores) + populate(objectMap, "totalNodes", p.TotalNodes) + populate(objectMap, "totalRam", p.TotalRAM) + populate(objectMap, "totalStorage", p.TotalStorage) + populate(objectMap, "type", p.Type) + populate(objectMap, "vSphereVersion", p.VSphereVersion) + populate(objectMap, "vcenterFqdn", p.VcenterFqdn) + populate(objectMap, "vcenterRefid", p.VcenterRefid) + populate(objectMap, "virtualMachineTemplates", p.VirtualMachineTemplates) + populate(objectMap, "virtualNetworks", p.VirtualNetworks) + populate(objectMap, "vrOpsEnabled", p.VrOpsEnabled) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateCloudProperties. +func (p *PrivateCloudProperties) UnmarshalJSON(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 "availabilityZoneId": + err = unpopulate(val, "AvailabilityZoneID", &p.AvailabilityZoneID) + delete(rawMsg, key) + case "availabilityZoneName": + err = unpopulate(val, "AvailabilityZoneName", &p.AvailabilityZoneName) + delete(rawMsg, key) + case "clustersNumber": + err = unpopulate(val, "ClustersNumber", &p.ClustersNumber) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &p.CreatedBy) + delete(rawMsg, key) + case "createdOn": + err = unpopulateTimeRFC3339(val, "CreatedOn", &p.CreatedOn) + delete(rawMsg, key) + case "dnsServers": + err = unpopulate(val, "DNSServers", &p.DNSServers) + delete(rawMsg, key) + case "expires": + err = unpopulate(val, "Expires", &p.Expires) + delete(rawMsg, key) + case "nsxType": + err = unpopulate(val, "NsxType", &p.NsxType) + delete(rawMsg, key) + case "placementGroupId": + err = unpopulate(val, "PlacementGroupID", &p.PlacementGroupID) + delete(rawMsg, key) + case "placementGroupName": + err = unpopulate(val, "PlacementGroupName", &p.PlacementGroupName) + delete(rawMsg, key) + case "privateCloudId": + err = unpopulate(val, "PrivateCloudID", &p.PrivateCloudID) + delete(rawMsg, key) + case "resourcePools": + err = unpopulate(val, "ResourcePools", &p.ResourcePools) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &p.State) + delete(rawMsg, key) + case "totalCpuCores": + err = unpopulate(val, "TotalCPUCores", &p.TotalCPUCores) + delete(rawMsg, key) + case "totalNodes": + err = unpopulate(val, "TotalNodes", &p.TotalNodes) + delete(rawMsg, key) + case "totalRam": + err = unpopulate(val, "TotalRAM", &p.TotalRAM) + delete(rawMsg, key) + case "totalStorage": + err = unpopulate(val, "TotalStorage", &p.TotalStorage) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + case "vSphereVersion": + err = unpopulate(val, "VSphereVersion", &p.VSphereVersion) + delete(rawMsg, key) + case "vcenterFqdn": + err = unpopulate(val, "VcenterFqdn", &p.VcenterFqdn) + delete(rawMsg, key) + case "vcenterRefid": + err = unpopulate(val, "VcenterRefid", &p.VcenterRefid) + delete(rawMsg, key) + case "virtualMachineTemplates": + err = unpopulate(val, "VirtualMachineTemplates", &p.VirtualMachineTemplates) + delete(rawMsg, key) + case "virtualNetworks": + err = unpopulate(val, "VirtualNetworks", &p.VirtualNetworks) + delete(rawMsg, key) + case "vrOpsEnabled": + err = unpopulate(val, "VrOpsEnabled", &p.VrOpsEnabled) + 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 ResourcePool. +func (r ResourcePool) 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, "privateCloudId", r.PrivateCloudID) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourcePool. +func (r *ResourcePool) UnmarshalJSON(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 "privateCloudId": + err = unpopulate(val, "PrivateCloudID", &r.PrivateCloudID) + 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 ResourcePoolProperties. +func (r ResourcePoolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "fullName", r.FullName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourcePoolProperties. +func (r *ResourcePoolProperties) UnmarshalJSON(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 "fullName": + err = unpopulate(val, "FullName", &r.FullName) + 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 ResourcePoolsListResponse. +func (r ResourcePoolsListResponse) 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 ResourcePoolsListResponse. +func (r *ResourcePoolsListResponse) UnmarshalJSON(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 SKU. +func (s SKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "capacity", s.Capacity) + populate(objectMap, "description", s.Description) + populate(objectMap, "family", s.Family) + populate(objectMap, "name", s.Name) + populate(objectMap, "tier", s.Tier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKU. +func (s *SKU) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "capacity": + err = unpopulate(val, "Capacity", &s.Capacity) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &s.Description) + delete(rawMsg, key) + case "family": + err = unpopulate(val, "Family", &s.Family) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "tier": + err = unpopulate(val, "Tier", &s.Tier) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SKUAvailability. +func (s SKUAvailability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dedicatedAvailabilityZoneId", s.DedicatedAvailabilityZoneID) + populate(objectMap, "dedicatedAvailabilityZoneName", s.DedicatedAvailabilityZoneName) + populate(objectMap, "dedicatedPlacementGroupId", s.DedicatedPlacementGroupID) + populate(objectMap, "dedicatedPlacementGroupName", s.DedicatedPlacementGroupName) + populate(objectMap, "limit", s.Limit) + populate(objectMap, "resourceType", s.ResourceType) + populate(objectMap, "skuId", s.SKUID) + populate(objectMap, "skuName", s.SKUName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKUAvailability. +func (s *SKUAvailability) UnmarshalJSON(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 "dedicatedAvailabilityZoneId": + err = unpopulate(val, "DedicatedAvailabilityZoneID", &s.DedicatedAvailabilityZoneID) + delete(rawMsg, key) + case "dedicatedAvailabilityZoneName": + err = unpopulate(val, "DedicatedAvailabilityZoneName", &s.DedicatedAvailabilityZoneName) + delete(rawMsg, key) + case "dedicatedPlacementGroupId": + err = unpopulate(val, "DedicatedPlacementGroupID", &s.DedicatedPlacementGroupID) + delete(rawMsg, key) + case "dedicatedPlacementGroupName": + err = unpopulate(val, "DedicatedPlacementGroupName", &s.DedicatedPlacementGroupName) + delete(rawMsg, key) + case "limit": + err = unpopulate(val, "Limit", &s.Limit) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &s.ResourceType) + delete(rawMsg, key) + case "skuId": + err = unpopulate(val, "SKUID", &s.SKUID) + delete(rawMsg, key) + case "skuName": + err = unpopulate(val, "SKUName", &s.SKUName) + 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 SKUAvailabilityListResponse. +func (s SKUAvailabilityListResponse) 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 SKUAvailabilityListResponse. +func (s *SKUAvailabilityListResponse) UnmarshalJSON(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 SKUDescription. +func (s SKUDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKUDescription. +func (s *SKUDescription) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Usage. +func (u Usage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "currentValue", u.CurrentValue) + populate(objectMap, "limit", u.Limit) + populate(objectMap, "name", u.Name) + populate(objectMap, "unit", u.Unit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Usage. +func (u *Usage) UnmarshalJSON(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 "currentValue": + err = unpopulate(val, "CurrentValue", &u.CurrentValue) + delete(rawMsg, key) + case "limit": + err = unpopulate(val, "Limit", &u.Limit) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &u.Name) + delete(rawMsg, key) + case "unit": + err = unpopulate(val, "Unit", &u.Unit) + 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 UsageListResponse. +func (u UsageListResponse) 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 UsageListResponse. +func (u *UsageListResponse) UnmarshalJSON(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 UsageName. +func (u UsageName) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "localizedValue", u.LocalizedValue) + populate(objectMap, "value", u.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UsageName. +func (u *UsageName) UnmarshalJSON(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 "localizedValue": + err = unpopulate(val, "LocalizedValue", &u.LocalizedValue) + 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 VirtualDisk. +func (v VirtualDisk) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "controllerId", v.ControllerID) + populate(objectMap, "independenceMode", v.IndependenceMode) + populate(objectMap, "totalSize", v.TotalSize) + populate(objectMap, "virtualDiskId", v.VirtualDiskID) + populate(objectMap, "virtualDiskName", v.VirtualDiskName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualDisk. +func (v *VirtualDisk) UnmarshalJSON(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 "controllerId": + err = unpopulate(val, "ControllerID", &v.ControllerID) + delete(rawMsg, key) + case "independenceMode": + err = unpopulate(val, "IndependenceMode", &v.IndependenceMode) + delete(rawMsg, key) + case "totalSize": + err = unpopulate(val, "TotalSize", &v.TotalSize) + delete(rawMsg, key) + case "virtualDiskId": + err = unpopulate(val, "VirtualDiskID", &v.VirtualDiskID) + delete(rawMsg, key) + case "virtualDiskName": + err = unpopulate(val, "VirtualDiskName", &v.VirtualDiskName) + 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 VirtualDiskController. +func (v VirtualDiskController) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", v.ID) + populate(objectMap, "name", v.Name) + populate(objectMap, "subType", v.SubType) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualDiskController. +func (v *VirtualDiskController) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &v.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &v.Name) + delete(rawMsg, key) + case "subType": + err = unpopulate(val, "SubType", &v.SubType) + 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 VirtualMachine. +func (v VirtualMachine) 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 VirtualMachine. +func (v *VirtualMachine) UnmarshalJSON(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 VirtualMachineListResponse. +func (v VirtualMachineListResponse) 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 VirtualMachineListResponse. +func (v *VirtualMachineListResponse) UnmarshalJSON(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 VirtualMachineProperties. +func (v VirtualMachineProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "amountOfRam", v.AmountOfRAM) + populate(objectMap, "controllers", v.Controllers) + populate(objectMap, "customization", v.Customization) + populate(objectMap, "disks", v.Disks) + populate(objectMap, "dnsname", v.Dnsname) + populate(objectMap, "exposeToGuestVM", v.ExposeToGuestVM) + populate(objectMap, "folder", v.Folder) + populate(objectMap, "guestOS", v.GuestOS) + populate(objectMap, "guestOSType", v.GuestOSType) + populate(objectMap, "nics", v.Nics) + populate(objectMap, "numberOfCores", v.NumberOfCores) + populate(objectMap, "password", v.Password) + populate(objectMap, "privateCloudId", v.PrivateCloudID) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "publicIP", v.PublicIP) + populate(objectMap, "resourcePool", v.ResourcePool) + populate(objectMap, "status", v.Status) + populate(objectMap, "templateId", v.TemplateID) + populate(objectMap, "username", v.Username) + populate(objectMap, "vmId", v.VMID) + populate(objectMap, "vSphereNetworks", v.VSphereNetworks) + populate(objectMap, "vmwaretools", v.Vmwaretools) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineProperties. +func (v *VirtualMachineProperties) UnmarshalJSON(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 "amountOfRam": + err = unpopulate(val, "AmountOfRAM", &v.AmountOfRAM) + delete(rawMsg, key) + case "controllers": + err = unpopulate(val, "Controllers", &v.Controllers) + delete(rawMsg, key) + case "customization": + err = unpopulate(val, "Customization", &v.Customization) + delete(rawMsg, key) + case "disks": + err = unpopulate(val, "Disks", &v.Disks) + delete(rawMsg, key) + case "dnsname": + err = unpopulate(val, "Dnsname", &v.Dnsname) + delete(rawMsg, key) + case "exposeToGuestVM": + err = unpopulate(val, "ExposeToGuestVM", &v.ExposeToGuestVM) + delete(rawMsg, key) + case "folder": + err = unpopulate(val, "Folder", &v.Folder) + delete(rawMsg, key) + case "guestOS": + err = unpopulate(val, "GuestOS", &v.GuestOS) + delete(rawMsg, key) + case "guestOSType": + err = unpopulate(val, "GuestOSType", &v.GuestOSType) + delete(rawMsg, key) + case "nics": + err = unpopulate(val, "Nics", &v.Nics) + delete(rawMsg, key) + case "numberOfCores": + err = unpopulate(val, "NumberOfCores", &v.NumberOfCores) + delete(rawMsg, key) + case "password": + err = unpopulate(val, "Password", &v.Password) + delete(rawMsg, key) + case "privateCloudId": + err = unpopulate(val, "PrivateCloudID", &v.PrivateCloudID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &v.ProvisioningState) + delete(rawMsg, key) + case "publicIP": + err = unpopulate(val, "PublicIP", &v.PublicIP) + delete(rawMsg, key) + case "resourcePool": + err = unpopulate(val, "ResourcePool", &v.ResourcePool) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &v.Status) + delete(rawMsg, key) + case "templateId": + err = unpopulate(val, "TemplateID", &v.TemplateID) + delete(rawMsg, key) + case "username": + err = unpopulate(val, "Username", &v.Username) + delete(rawMsg, key) + case "vmId": + err = unpopulate(val, "VMID", &v.VMID) + delete(rawMsg, key) + case "vSphereNetworks": + err = unpopulate(val, "VSphereNetworks", &v.VSphereNetworks) + delete(rawMsg, key) + case "vmwaretools": + err = unpopulate(val, "Vmwaretools", &v.Vmwaretools) + 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 VirtualMachineStopMode. +func (v VirtualMachineStopMode) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "mode", v.Mode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineStopMode. +func (v *VirtualMachineStopMode) UnmarshalJSON(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 "mode": + err = unpopulate(val, "Mode", &v.Mode) + 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 VirtualMachineTemplate. +func (v VirtualMachineTemplate) 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, "type", v.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineTemplate. +func (v *VirtualMachineTemplate) UnmarshalJSON(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 "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 VirtualMachineTemplateListResponse. +func (v VirtualMachineTemplateListResponse) 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 VirtualMachineTemplateListResponse. +func (v *VirtualMachineTemplateListResponse) UnmarshalJSON(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 VirtualMachineTemplateProperties. +func (v VirtualMachineTemplateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "amountOfRam", v.AmountOfRAM) + populate(objectMap, "controllers", v.Controllers) + populate(objectMap, "description", v.Description) + populate(objectMap, "disks", v.Disks) + populate(objectMap, "exposeToGuestVM", v.ExposeToGuestVM) + populate(objectMap, "guestOS", v.GuestOS) + populate(objectMap, "guestOSType", v.GuestOSType) + populate(objectMap, "nics", v.Nics) + populate(objectMap, "numberOfCores", v.NumberOfCores) + populate(objectMap, "path", v.Path) + populate(objectMap, "privateCloudId", v.PrivateCloudID) + populate(objectMap, "vSphereNetworks", v.VSphereNetworks) + populate(objectMap, "vSphereTags", v.VSphereTags) + populate(objectMap, "vmwaretools", v.Vmwaretools) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineTemplateProperties. +func (v *VirtualMachineTemplateProperties) UnmarshalJSON(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 "amountOfRam": + err = unpopulate(val, "AmountOfRAM", &v.AmountOfRAM) + delete(rawMsg, key) + case "controllers": + err = unpopulate(val, "Controllers", &v.Controllers) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &v.Description) + delete(rawMsg, key) + case "disks": + err = unpopulate(val, "Disks", &v.Disks) + delete(rawMsg, key) + case "exposeToGuestVM": + err = unpopulate(val, "ExposeToGuestVM", &v.ExposeToGuestVM) + delete(rawMsg, key) + case "guestOS": + err = unpopulate(val, "GuestOS", &v.GuestOS) + delete(rawMsg, key) + case "guestOSType": + err = unpopulate(val, "GuestOSType", &v.GuestOSType) + delete(rawMsg, key) + case "nics": + err = unpopulate(val, "Nics", &v.Nics) + delete(rawMsg, key) + case "numberOfCores": + err = unpopulate(val, "NumberOfCores", &v.NumberOfCores) + delete(rawMsg, key) + case "path": + err = unpopulate(val, "Path", &v.Path) + delete(rawMsg, key) + case "privateCloudId": + err = unpopulate(val, "PrivateCloudID", &v.PrivateCloudID) + delete(rawMsg, key) + case "vSphereNetworks": + err = unpopulate(val, "VSphereNetworks", &v.VSphereNetworks) + delete(rawMsg, key) + case "vSphereTags": + err = unpopulate(val, "VSphereTags", &v.VSphereTags) + delete(rawMsg, key) + case "vmwaretools": + err = unpopulate(val, "Vmwaretools", &v.Vmwaretools) + 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 VirtualNetwork. +func (v VirtualNetwork) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "assignable", v.Assignable) + populate(objectMap, "id", v.ID) + populate(objectMap, "location", v.Location) + 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 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 "assignable": + err = unpopulate(val, "Assignable", &v.Assignable) + delete(rawMsg, 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 "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 VirtualNetworkListResponse. +func (v VirtualNetworkListResponse) 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 VirtualNetworkListResponse. +func (v *VirtualNetworkListResponse) UnmarshalJSON(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, "privateCloudId", v.PrivateCloudID) + 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 "privateCloudId": + err = unpopulate(val, "PrivateCloudID", &v.PrivateCloudID) + 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 VirtualNic. +func (v VirtualNic) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "customization", v.Customization) + populate(objectMap, "ipAddresses", v.IPAddresses) + populate(objectMap, "macAddress", v.MacAddress) + populate(objectMap, "network", v.Network) + populate(objectMap, "nicType", v.NicType) + populate(objectMap, "powerOnBoot", v.PowerOnBoot) + populate(objectMap, "virtualNicId", v.VirtualNicID) + populate(objectMap, "virtualNicName", v.VirtualNicName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNic. +func (v *VirtualNic) UnmarshalJSON(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 "customization": + err = unpopulate(val, "Customization", &v.Customization) + delete(rawMsg, key) + case "ipAddresses": + err = unpopulate(val, "IPAddresses", &v.IPAddresses) + delete(rawMsg, key) + case "macAddress": + err = unpopulate(val, "MacAddress", &v.MacAddress) + delete(rawMsg, key) + case "network": + err = unpopulate(val, "Network", &v.Network) + delete(rawMsg, key) + case "nicType": + err = unpopulate(val, "NicType", &v.NicType) + delete(rawMsg, key) + case "powerOnBoot": + err = unpopulate(val, "PowerOnBoot", &v.PowerOnBoot) + delete(rawMsg, key) + case "virtualNicId": + err = unpopulate(val, "VirtualNicID", &v.VirtualNicID) + delete(rawMsg, key) + case "virtualNicName": + err = unpopulate(val, "VirtualNicName", &v.VirtualNicName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_operations_client.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/operations_client.go similarity index 82% rename from sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_operations_client.go rename to sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/operations_client.go index 4795b5015992..445e99b714c2 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_operations_client.go +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/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 armvmwarecloudsimple @@ -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 ( // 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 - Return an async operation // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// regionID - The region Id (westus, eastus) -// referer - referer url -// operationID - operation id -// options - OperationsClientGetOptions contains the optional parameters for the OperationsClient.Get method. +// - regionID - The region Id (westus, eastus) +// - referer - referer url +// - operationID - operation id +// - options - OperationsClientGetOptions contains the optional parameters for the OperationsClient.Get method. func (client *OperationsClient) Get(ctx context.Context, regionID string, referer string, operationID string, options *OperationsClientGetOptions) (OperationsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, regionID, referer, operationID, 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 } @@ -92,7 +83,7 @@ func (client *OperationsClient) getCreateRequest(ctx context.Context, regionID s return nil, errors.New("parameter operationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -125,9 +116,9 @@ func (client *OperationsClient) getHandleResponse(resp *http.Response) (Operatio } // NewListPager - Return list of operations -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -144,7 +135,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 } @@ -159,7 +150,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.VMwareCloudSimple/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/vmwarecloudsimple/armvmwarecloudsimple/operations_client_example_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/operations_client_example_test.go new file mode 100644 index 000000000000..ce506c596a7d --- /dev/null +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/operations_client_example_test.go @@ -0,0 +1,114 @@ +//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 armvmwarecloudsimple_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/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 := armvmwarecloudsimple.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.AvailableOperationsListResponse = armvmwarecloudsimple.AvailableOperationsListResponse{ + // Value: []*armvmwarecloudsimple.AvailableOperation{ + // { + // Name: to.Ptr("Microsoft.VMwareCloudSimple/dedicatedCloudNodes/write"), + // Display: &armvmwarecloudsimple.AvailableOperationDisplay{ + // Description: to.Ptr("Creates a new dedicated cloud node"), + // Operation: to.Ptr("Create Dedicated Cloud Node"), + // Provider: to.Ptr("VMware Solution by CloudSimple"), + // Resource: to.Ptr("Dedicated Cloud Nodes"), + // }, + // Origin: to.Ptr(armvmwarecloudsimple.OperationOriginUserSystem), + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/GetFailedOperationResult.json +func ExampleOperationsClient_Get_getFailedOperationResult() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewOperationsClient().Get(ctx, "westus2", "https://management.azure.com/", "d030bb3f-7d53-11e9-8e09-9a86872085ff", 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.OperationResource = armvmwarecloudsimple.OperationResource{ + // Name: to.Ptr("d030bb3f-7d53-11e9-8e09-9a86872085ff"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-23T12:11:00.655Z"); return t}()), + // Error: &armvmwarecloudsimple.OperationError{ + // Code: to.Ptr("InternalError"), + // Message: to.Ptr("Internal Service error"), + // }, + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/microsoft.vmwarecloudsimple/locations/westus2/operationresults/d030bb3f-7d53-11e9-8e09-9a86872085ff"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-23T12:10:54.012Z"); return t}()), + // Status: to.Ptr("Failed"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/GetOperationResult.json +func ExampleOperationsClient_Get_getOperationResult() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewOperationsClient().Get(ctx, "westus2", "https://management.azure.com/", "f8e1c8f1-7d52-11e9-8e07-9a86872085ff", 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.OperationResource = armvmwarecloudsimple.OperationResource{ + // Name: to.Ptr("f8e1c8f1-7d52-11e9-8e07-9a86872085ff"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-23T12:05:55.660Z"); return t}()), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/microsoft.vmwarecloudsimple/locations/westus2/operationresults/f8e1c8f1-7d52-11e9-8e07-9a86872085ff"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-23T12:04:52.784Z"); return t}()), + // Status: to.Ptr("Succeeded"), + // } +} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_privateclouds_client.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/privateclouds_client.go similarity index 82% rename from sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_privateclouds_client.go rename to sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/privateclouds_client.go index e1034ce84886..fff593502148 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_privateclouds_client.go +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/privateclouds_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 armvmwarecloudsimple @@ -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 ( // PrivateCloudsClient contains the methods for the PrivateClouds group. // Don't use this type directly, use NewPrivateCloudsClient() instead. type PrivateCloudsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPrivateCloudsClient creates a new instance of PrivateCloudsClient 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 NewPrivateCloudsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateCloudsClient, 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+".PrivateCloudsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PrivateCloudsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Returns private cloud by its name // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// pcName - The private cloud name -// regionID - The region Id (westus, eastus) -// options - PrivateCloudsClientGetOptions contains the optional parameters for the PrivateCloudsClient.Get method. +// - pcName - The private cloud name +// - regionID - The region Id (westus, eastus) +// - options - PrivateCloudsClientGetOptions contains the optional parameters for the PrivateCloudsClient.Get method. func (client *PrivateCloudsClient) Get(ctx context.Context, pcName string, regionID string, options *PrivateCloudsClientGetOptions) (PrivateCloudsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, pcName, regionID, options) if err != nil { return PrivateCloudsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateCloudsClientGetResponse{}, err } @@ -90,7 +81,7 @@ func (client *PrivateCloudsClient) getCreateRequest(ctx context.Context, pcName return nil, errors.New("parameter regionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{regionId}", url.PathEscape(regionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -111,10 +102,10 @@ func (client *PrivateCloudsClient) getHandleResponse(resp *http.Response) (Priva } // NewListPager - Returns list of private clouds in particular region -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// regionID - The region Id (westus, eastus) -// options - PrivateCloudsClientListOptions contains the optional parameters for the PrivateCloudsClient.List method. +// - regionID - The region Id (westus, eastus) +// - options - PrivateCloudsClientListOptions contains the optional parameters for the PrivateCloudsClient.NewListPager method. func (client *PrivateCloudsClient) NewListPager(regionID string, options *PrivateCloudsClientListOptions) *runtime.Pager[PrivateCloudsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[PrivateCloudsClientListResponse]{ More: func(page PrivateCloudsClientListResponse) bool { @@ -131,7 +122,7 @@ func (client *PrivateCloudsClient) NewListPager(regionID string, options *Privat if err != nil { return PrivateCloudsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateCloudsClientListResponse{}, err } @@ -154,7 +145,7 @@ func (client *PrivateCloudsClient) listCreateRequest(ctx context.Context, region return nil, errors.New("parameter regionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{regionId}", url.PathEscape(regionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/vmwarecloudsimple/armvmwarecloudsimple/privateclouds_client_example_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/privateclouds_client_example_test.go new file mode 100644 index 000000000000..2cec04fcfe9a --- /dev/null +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/privateclouds_client_example_test.go @@ -0,0 +1,230 @@ +//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 armvmwarecloudsimple_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListPrivateCloudInLocation.json +func ExamplePrivateCloudsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPrivateCloudsClient().NewListPager("eastus", 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.PrivateCloudList = armvmwarecloudsimple.PrivateCloudList{ + // Value: []*armvmwarecloudsimple.PrivateCloud{ + // { + // Name: to.Ptr("myPrivateCloud"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/privateClouds"), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/eastus/privateClouds/myPrivateCloud"), + // Location: to.Ptr("eastus"), + // Properties: &armvmwarecloudsimple.PrivateCloudProperties{ + // Type: to.Ptr("vSphere"), + // AvailabilityZoneID: to.Ptr("az1"), + // AvailabilityZoneName: to.Ptr("Availability Zone 1"), + // ClustersNumber: to.Ptr[int32](1), + // CreatedBy: to.Ptr("john.doe@cloudsimple.com"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-21T07:32:59.491Z"); return t}()), + // DNSServers: []*string{ + // to.Ptr("100.100.100.8"), + // to.Ptr("100.100.100.9")}, + // Expires: to.Ptr("n/a"), + // NsxType: to.Ptr("Advanced"), + // PlacementGroupID: to.Ptr("n2"), + // PlacementGroupName: to.Ptr("Placement Group 2"), + // PrivateCloudID: to.Ptr("private-cloud-id"), + // State: to.Ptr("operational"), + // TotalCPUCores: to.Ptr[int32](84), + // TotalNodes: to.Ptr[int32](3), + // TotalRAM: to.Ptr[int32](768), + // TotalStorage: to.Ptr[float32](16.875), + // VSphereVersion: to.Ptr("6.7u1"), + // VcenterFqdn: to.Ptr("vcsa-eastus.az.cloudsimple.io"), + // VcenterRefid: to.Ptr("100.100.100.6"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/GetPrivateCloud.json +func ExamplePrivateCloudsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPrivateCloudsClient().Get(ctx, "myPrivateCloud", "westus2", 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.PrivateCloud = armvmwarecloudsimple.PrivateCloud{ + // Name: to.Ptr("myPrivateCloud"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/privateClouds"), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.PrivateCloudProperties{ + // Type: to.Ptr("vSphere"), + // AvailabilityZoneID: to.Ptr("az1"), + // AvailabilityZoneName: to.Ptr("Availability Zone 1"), + // ClustersNumber: to.Ptr[int32](1), + // CreatedBy: to.Ptr("john.doe@cloudsimple.com"), + // CreatedOn: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-22T09:55:36.627Z"); return t}()), + // DNSServers: []*string{ + // to.Ptr("100.0.0.8"), + // to.Ptr("100.0.0.9")}, + // Expires: to.Ptr("n/a"), + // NsxType: to.Ptr("Advanced"), + // PlacementGroupID: to.Ptr("n1"), + // PlacementGroupName: to.Ptr("Placement Group 1"), + // PrivateCloudID: to.Ptr("{pc-id}"), + // ResourcePools: []*armvmwarecloudsimple.ResourcePool{ + // { + // Name: to.Ptr("Workload"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/resourcePools"), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/resourcePools/resgroup-26"), + // Location: to.Ptr("westus2"), + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // Properties: &armvmwarecloudsimple.ResourcePoolProperties{ + // FullName: to.Ptr("myPrivateCloud/Datacenter/Cluster/Workload"), + // }, + // }}, + // State: to.Ptr("operational"), + // TotalCPUCores: to.Ptr[int32](28), + // TotalNodes: to.Ptr[int32](1), + // TotalRAM: to.Ptr[int32](256), + // TotalStorage: to.Ptr[float32](5.625), + // VSphereVersion: to.Ptr("6.7u1"), + // VcenterFqdn: to.Ptr("vcsa-4-westus2.az.cloudsimple.io"), + // VcenterRefid: to.Ptr("100.0.0.6"), + // VirtualMachineTemplates: []*armvmwarecloudsimple.VirtualMachineTemplate{ + // { + // Name: to.Ptr("centos-template"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualMachineTemplates"), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualMachineTemplates/vm-34"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualMachineTemplateProperties{ + // Path: to.Ptr("Datacenter/Workload VMs"), + // AmountOfRAM: to.Ptr[int32](4096), + // Controllers: []*armvmwarecloudsimple.VirtualDiskController{ + // { + // Name: to.Ptr("SCSI controller 0"), + // Type: to.Ptr("SCSI"), + // ID: to.Ptr("1000"), + // SubType: to.Ptr("LSI_PARALEL"), + // }}, + // Disks: []*armvmwarecloudsimple.VirtualDisk{ + // { + // ControllerID: to.Ptr("1000"), + // IndependenceMode: to.Ptr(armvmwarecloudsimple.DiskIndependenceModePersistent), + // TotalSize: to.Ptr[int32](10485760), + // VirtualDiskID: to.Ptr("2000"), + // VirtualDiskName: to.Ptr("Hard disk 1"), + // }}, + // GuestOS: to.Ptr("Other (32-bit)"), + // GuestOSType: to.Ptr("other"), + // Nics: []*armvmwarecloudsimple.VirtualNic{ + // { + // MacAddress: to.Ptr("00:50:56:a6:7e:93"), + // Network: &armvmwarecloudsimple.VirtualNetwork{ + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-19"), + // }, + // NicType: to.Ptr(armvmwarecloudsimple.NICTypeE1000), + // PowerOnBoot: to.Ptr(true), + // VirtualNicID: to.Ptr("4000"), + // VirtualNicName: to.Ptr("Network adapter 1"), + // }}, + // NumberOfCores: to.Ptr[int32](2), + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // Vmwaretools: to.Ptr("10309"), + // }, + // }}, + // VirtualNetworks: []*armvmwarecloudsimple.VirtualNetwork{ + // { + // Name: to.Ptr("Datacenter/CS-Management"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualNetworks"), + // Assignable: to.Ptr(false), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-19"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualNetworkProperties{ + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // }, + // }, + // { + // Name: to.Ptr("Datacenter/CS-Rescue"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualNetworks"), + // Assignable: to.Ptr(true), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-20"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualNetworkProperties{ + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // }, + // }, + // { + // Name: to.Ptr("Datacenter/CS-VSAN"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualNetworks"), + // Assignable: to.Ptr(false), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-21"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualNetworkProperties{ + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // }, + // }, + // { + // Name: to.Ptr("Datacenter/CS-VMotion"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualNetworks"), + // Assignable: to.Ptr(false), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-22"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualNetworkProperties{ + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // }, + // }, + // { + // Name: to.Ptr("Datacenter/net-01"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualNetworks"), + // Assignable: to.Ptr(true), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-35"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualNetworkProperties{ + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // }, + // }}, + // }, + // } +} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_resourcepools_client.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/resourcepools_client.go similarity index 82% rename from sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_resourcepools_client.go rename to sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/resourcepools_client.go index c7ac1520cf86..6570782619c9 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_resourcepools_client.go +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/resourcepools_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 armvmwarecloudsimple @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // ResourcePoolsClient contains the methods for the ResourcePools group. // Don't use this type directly, use NewResourcePoolsClient() instead. type ResourcePoolsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewResourcePoolsClient creates a new instance of ResourcePoolsClient 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 NewResourcePoolsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ResourcePoolsClient, 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+".ResourcePoolsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ResourcePoolsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Returns resource pool templates by its name // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// regionID - The region Id (westus, eastus) -// pcName - The private cloud name -// resourcePoolName - resource pool id (vsphereId) -// options - ResourcePoolsClientGetOptions contains the optional parameters for the ResourcePoolsClient.Get method. +// - regionID - The region Id (westus, eastus) +// - pcName - The private cloud name +// - resourcePoolName - resource pool id (vsphereId) +// - options - ResourcePoolsClientGetOptions contains the optional parameters for the ResourcePoolsClient.Get method. func (client *ResourcePoolsClient) Get(ctx context.Context, regionID string, pcName string, resourcePoolName string, options *ResourcePoolsClientGetOptions) (ResourcePoolsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, regionID, pcName, resourcePoolName, options) if err != nil { return ResourcePoolsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourcePoolsClientGetResponse{}, err } @@ -95,7 +86,7 @@ func (client *ResourcePoolsClient) getCreateRequest(ctx context.Context, regionI return nil, errors.New("parameter resourcePoolName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourcePoolName}", url.PathEscape(resourcePoolName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -116,11 +107,11 @@ func (client *ResourcePoolsClient) getHandleResponse(resp *http.Response) (Resou } // NewListPager - Returns list of resource pools in region for private cloud -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// regionID - The region Id (westus, eastus) -// pcName - The private cloud name -// options - ResourcePoolsClientListOptions contains the optional parameters for the ResourcePoolsClient.List method. +// - regionID - The region Id (westus, eastus) +// - pcName - The private cloud name +// - options - ResourcePoolsClientListOptions contains the optional parameters for the ResourcePoolsClient.NewListPager method. func (client *ResourcePoolsClient) NewListPager(regionID string, pcName string, options *ResourcePoolsClientListOptions) *runtime.Pager[ResourcePoolsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ResourcePoolsClientListResponse]{ More: func(page ResourcePoolsClientListResponse) bool { @@ -137,7 +128,7 @@ func (client *ResourcePoolsClient) NewListPager(regionID string, pcName string, if err != nil { return ResourcePoolsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourcePoolsClientListResponse{}, err } @@ -164,7 +155,7 @@ func (client *ResourcePoolsClient) listCreateRequest(ctx context.Context, region return nil, errors.New("parameter pcName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{pcName}", url.PathEscape(pcName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/vmwarecloudsimple/armvmwarecloudsimple/resourcepools_client_example_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/resourcepools_client_example_test.go new file mode 100644 index 000000000000..4d235a63525d --- /dev/null +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/resourcepools_client_example_test.go @@ -0,0 +1,86 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armvmwarecloudsimple_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListResourcePools.json +func ExampleResourcePoolsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewResourcePoolsClient().NewListPager("westus2", "myPrivateCloud", 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.ResourcePoolsListResponse = armvmwarecloudsimple.ResourcePoolsListResponse{ + // Value: []*armvmwarecloudsimple.ResourcePool{ + // { + // Name: to.Ptr("Workload"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/resourcePools"), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/resourcePools/resgroup-26"), + // Location: to.Ptr("westus2"), + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // Properties: &armvmwarecloudsimple.ResourcePoolProperties{ + // FullName: to.Ptr("myPrivateCloud/Datacenter/Cluster/Workload"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/GetResourcePool.json +func ExampleResourcePoolsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewResourcePoolsClient().Get(ctx, "westus2", "myPrivateCloud", "resgroup-26", 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.ResourcePool = armvmwarecloudsimple.ResourcePool{ + // Name: to.Ptr("Workload"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/resourcePools"), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/resourcePools/resgroup-26"), + // Location: to.Ptr("westus2"), + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // Properties: &armvmwarecloudsimple.ResourcePoolProperties{ + // FullName: to.Ptr("myPrivateCloud/Datacenter/Cluster/Workload"), + // }, + // } +} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_response_types.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/response_types.go similarity index 83% rename from sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_response_types.go rename to sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/response_types.go index 4868a18e77a2..7c2ca3de0bb7 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_response_types.go +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/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 armvmwarecloudsimple @@ -13,12 +14,12 @@ type CustomizationPoliciesClientGetResponse struct { CustomizationPolicy } -// CustomizationPoliciesClientListResponse contains the response from method CustomizationPoliciesClient.List. +// CustomizationPoliciesClientListResponse contains the response from method CustomizationPoliciesClient.NewListPager. type CustomizationPoliciesClientListResponse struct { CustomizationPoliciesListResponse } -// DedicatedCloudNodesClientCreateOrUpdateResponse contains the response from method DedicatedCloudNodesClient.CreateOrUpdate. +// DedicatedCloudNodesClientCreateOrUpdateResponse contains the response from method DedicatedCloudNodesClient.BeginCreateOrUpdate. type DedicatedCloudNodesClientCreateOrUpdateResponse struct { DedicatedCloudNode } @@ -33,12 +34,12 @@ type DedicatedCloudNodesClientGetResponse struct { DedicatedCloudNode } -// DedicatedCloudNodesClientListByResourceGroupResponse contains the response from method DedicatedCloudNodesClient.ListByResourceGroup. +// DedicatedCloudNodesClientListByResourceGroupResponse contains the response from method DedicatedCloudNodesClient.NewListByResourceGroupPager. type DedicatedCloudNodesClientListByResourceGroupResponse struct { DedicatedCloudNodeListResponse } -// DedicatedCloudNodesClientListBySubscriptionResponse contains the response from method DedicatedCloudNodesClient.ListBySubscription. +// DedicatedCloudNodesClientListBySubscriptionResponse contains the response from method DedicatedCloudNodesClient.NewListBySubscriptionPager. type DedicatedCloudNodesClientListBySubscriptionResponse struct { DedicatedCloudNodeListResponse } @@ -53,7 +54,7 @@ type DedicatedCloudServicesClientCreateOrUpdateResponse struct { DedicatedCloudService } -// DedicatedCloudServicesClientDeleteResponse contains the response from method DedicatedCloudServicesClient.Delete. +// DedicatedCloudServicesClientDeleteResponse contains the response from method DedicatedCloudServicesClient.BeginDelete. type DedicatedCloudServicesClientDeleteResponse struct { // placeholder for future response values } @@ -63,12 +64,12 @@ type DedicatedCloudServicesClientGetResponse struct { DedicatedCloudService } -// DedicatedCloudServicesClientListByResourceGroupResponse contains the response from method DedicatedCloudServicesClient.ListByResourceGroup. +// DedicatedCloudServicesClientListByResourceGroupResponse contains the response from method DedicatedCloudServicesClient.NewListByResourceGroupPager. type DedicatedCloudServicesClientListByResourceGroupResponse struct { DedicatedCloudServiceListResponse } -// DedicatedCloudServicesClientListBySubscriptionResponse contains the response from method DedicatedCloudServicesClient.ListBySubscription. +// DedicatedCloudServicesClientListBySubscriptionResponse contains the response from method DedicatedCloudServicesClient.NewListBySubscriptionPager. type DedicatedCloudServicesClientListBySubscriptionResponse struct { DedicatedCloudServiceListResponse } @@ -88,7 +89,7 @@ type OperationsClientGetResponse struct { RetryAfter *int32 } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { AvailableOperationsListResponse } @@ -98,7 +99,7 @@ type PrivateCloudsClientGetResponse struct { PrivateCloud } -// PrivateCloudsClientListResponse contains the response from method PrivateCloudsClient.List. +// PrivateCloudsClientListResponse contains the response from method PrivateCloudsClient.NewListPager. type PrivateCloudsClientListResponse struct { PrivateCloudList } @@ -108,17 +109,17 @@ type ResourcePoolsClientGetResponse struct { ResourcePool } -// ResourcePoolsClientListResponse contains the response from method ResourcePoolsClient.List. +// ResourcePoolsClientListResponse contains the response from method ResourcePoolsClient.NewListPager. type ResourcePoolsClientListResponse struct { ResourcePoolsListResponse } -// SKUsAvailabilityClientListResponse contains the response from method SKUsAvailabilityClient.List. +// SKUsAvailabilityClientListResponse contains the response from method SKUsAvailabilityClient.NewListPager. type SKUsAvailabilityClientListResponse struct { SKUAvailabilityListResponse } -// UsagesClientListResponse contains the response from method UsagesClient.List. +// UsagesClientListResponse contains the response from method UsagesClient.NewListPager. type UsagesClientListResponse struct { UsageListResponse } @@ -128,17 +129,17 @@ type VirtualMachineTemplatesClientGetResponse struct { VirtualMachineTemplate } -// VirtualMachineTemplatesClientListResponse contains the response from method VirtualMachineTemplatesClient.List. +// VirtualMachineTemplatesClientListResponse contains the response from method VirtualMachineTemplatesClient.NewListPager. type VirtualMachineTemplatesClientListResponse struct { VirtualMachineTemplateListResponse } -// VirtualMachinesClientCreateOrUpdateResponse contains the response from method VirtualMachinesClient.CreateOrUpdate. +// VirtualMachinesClientCreateOrUpdateResponse contains the response from method VirtualMachinesClient.BeginCreateOrUpdate. type VirtualMachinesClientCreateOrUpdateResponse struct { VirtualMachine } -// VirtualMachinesClientDeleteResponse contains the response from method VirtualMachinesClient.Delete. +// VirtualMachinesClientDeleteResponse contains the response from method VirtualMachinesClient.BeginDelete. type VirtualMachinesClientDeleteResponse struct { // placeholder for future response values } @@ -148,27 +149,27 @@ type VirtualMachinesClientGetResponse struct { VirtualMachine } -// VirtualMachinesClientListByResourceGroupResponse contains the response from method VirtualMachinesClient.ListByResourceGroup. +// VirtualMachinesClientListByResourceGroupResponse contains the response from method VirtualMachinesClient.NewListByResourceGroupPager. type VirtualMachinesClientListByResourceGroupResponse struct { VirtualMachineListResponse } -// VirtualMachinesClientListBySubscriptionResponse contains the response from method VirtualMachinesClient.ListBySubscription. +// VirtualMachinesClientListBySubscriptionResponse contains the response from method VirtualMachinesClient.NewListBySubscriptionPager. type VirtualMachinesClientListBySubscriptionResponse struct { VirtualMachineListResponse } -// 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 } -// VirtualMachinesClientUpdateResponse contains the response from method VirtualMachinesClient.Update. +// VirtualMachinesClientUpdateResponse contains the response from method VirtualMachinesClient.BeginUpdate. type VirtualMachinesClientUpdateResponse struct { VirtualMachine } @@ -178,7 +179,7 @@ type VirtualNetworksClientGetResponse struct { VirtualNetwork } -// VirtualNetworksClientListResponse contains the response from method VirtualNetworksClient.List. +// VirtualNetworksClientListResponse contains the response from method VirtualNetworksClient.NewListPager. type VirtualNetworksClientListResponse struct { VirtualNetworkListResponse } diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_skusavailability_client.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/skusavailability_client.go similarity index 79% rename from sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_skusavailability_client.go rename to sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/skusavailability_client.go index 2b0db26368e0..63d8ca3ce261 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_skusavailability_client.go +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/skusavailability_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 armvmwarecloudsimple @@ -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,40 +24,32 @@ import ( // SKUsAvailabilityClient contains the methods for the SKUsAvailability group. // Don't use this type directly, use NewSKUsAvailabilityClient() instead. type SKUsAvailabilityClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSKUsAvailabilityClient creates a new instance of SKUsAvailabilityClient 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 NewSKUsAvailabilityClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SKUsAvailabilityClient, 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+".SKUsAvailabilityClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SKUsAvailabilityClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Returns list of available resources in region -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// regionID - The region Id (westus, eastus) -// options - SKUsAvailabilityClientListOptions contains the optional parameters for the SKUsAvailabilityClient.List method. +// - regionID - The region Id (westus, eastus) +// - options - SKUsAvailabilityClientListOptions contains the optional parameters for the SKUsAvailabilityClient.NewListPager +// method. func (client *SKUsAvailabilityClient) NewListPager(regionID string, options *SKUsAvailabilityClientListOptions) *runtime.Pager[SKUsAvailabilityClientListResponse] { return runtime.NewPager(runtime.PagingHandler[SKUsAvailabilityClientListResponse]{ More: func(page SKUsAvailabilityClientListResponse) bool { @@ -75,7 +66,7 @@ func (client *SKUsAvailabilityClient) NewListPager(regionID string, options *SKU if err != nil { return SKUsAvailabilityClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SKUsAvailabilityClientListResponse{}, err } @@ -98,7 +89,7 @@ func (client *SKUsAvailabilityClient) listCreateRequest(ctx context.Context, reg return nil, errors.New("parameter regionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{regionId}", url.PathEscape(regionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/vmwarecloudsimple/armvmwarecloudsimple/skusavailability_client_example_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/skusavailability_client_example_test.go new file mode 100644 index 000000000000..2d9122ade07d --- /dev/null +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/skusavailability_client_example_test.go @@ -0,0 +1,66 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armvmwarecloudsimple_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListAvailabilities.json +func ExampleSKUsAvailabilityClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSKUsAvailabilityClient().NewListPager("westus2", &armvmwarecloudsimple.SKUsAvailabilityClientListOptions{SKUID: 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.SKUAvailabilityListResponse = armvmwarecloudsimple.SKUAvailabilityListResponse{ + // Value: []*armvmwarecloudsimple.SKUAvailability{ + // { + // DedicatedAvailabilityZoneID: to.Ptr("az1"), + // DedicatedAvailabilityZoneName: to.Ptr("Availability Zone 1"), + // DedicatedPlacementGroupID: to.Ptr("n1"), + // DedicatedPlacementGroupName: to.Ptr("Placement Group 1"), + // Limit: to.Ptr[int32](0), + // ResourceType: to.Ptr("Microsoft.VMwareCloudSimple/dedicatedCloudNodes"), + // SKUID: to.Ptr("general"), + // SKUName: to.Ptr("CS28-Node"), + // }, + // { + // DedicatedAvailabilityZoneID: to.Ptr("az1"), + // DedicatedAvailabilityZoneName: to.Ptr("Availability Zone 1"), + // DedicatedPlacementGroupID: to.Ptr("n1"), + // DedicatedPlacementGroupName: to.Ptr("Placement Group 1"), + // Limit: to.Ptr[int32](0), + // ResourceType: to.Ptr("Microsoft.VMwareCloudSimple/dedicatedCloudNodes"), + // SKUID: to.Ptr("large"), + // SKUName: to.Ptr("CS36-Node"), + // }}, + // } + } +} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_time_rfc3339.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/time_rfc3339.go index ad4576169566..83bc0df9bdd4 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/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 armvmwarecloudsimple @@ -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/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_usages_client.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/usages_client.go similarity index 78% rename from sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_usages_client.go rename to sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/usages_client.go index 23536a37838e..d8a8f864c946 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_usages_client.go +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/usages_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 armvmwarecloudsimple @@ -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,40 +24,31 @@ import ( // UsagesClient contains the methods for the Usages group. // Don't use this type directly, use NewUsagesClient() instead. type UsagesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewUsagesClient creates a new instance of UsagesClient 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 NewUsagesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*UsagesClient, 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+".UsagesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &UsagesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Returns list of usage in region -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// regionID - The region Id (westus, eastus) -// options - UsagesClientListOptions contains the optional parameters for the UsagesClient.List method. +// - regionID - The region Id (westus, eastus) +// - options - UsagesClientListOptions contains the optional parameters for the UsagesClient.NewListPager method. func (client *UsagesClient) NewListPager(regionID string, options *UsagesClientListOptions) *runtime.Pager[UsagesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[UsagesClientListResponse]{ More: func(page UsagesClientListResponse) bool { @@ -75,7 +65,7 @@ func (client *UsagesClient) NewListPager(regionID string, options *UsagesClientL if err != nil { return UsagesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return UsagesClientListResponse{}, err } @@ -98,7 +88,7 @@ func (client *UsagesClient) listCreateRequest(ctx context.Context, regionID stri return nil, errors.New("parameter regionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{regionId}", url.PathEscape(regionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/vmwarecloudsimple/armvmwarecloudsimple/usages_client_example_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/usages_client_example_test.go new file mode 100644 index 000000000000..706870e5f929 --- /dev/null +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/usages_client_example_test.go @@ -0,0 +1,64 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armvmwarecloudsimple_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListUsages.json +func ExampleUsagesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewUsagesClient().NewListPager("westus2", &armvmwarecloudsimple.UsagesClientListOptions{Filter: 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.UsageListResponse = armvmwarecloudsimple.UsageListResponse{ + // Value: []*armvmwarecloudsimple.Usage{ + // { + // Name: &armvmwarecloudsimple.UsageName{ + // LocalizedValue: to.Ptr("CS28-Node"), + // Value: to.Ptr("general"), + // }, + // CurrentValue: to.Ptr[int32](1), + // Limit: to.Ptr[int32](5), + // Unit: to.Ptr(armvmwarecloudsimple.UsageCountCount), + // }, + // { + // Name: &armvmwarecloudsimple.UsageName{ + // LocalizedValue: to.Ptr("CS36-Node"), + // Value: to.Ptr("large"), + // }, + // CurrentValue: to.Ptr[int32](0), + // Limit: to.Ptr[int32](5), + // Unit: to.Ptr(armvmwarecloudsimple.UsageCountCount), + // }}, + // } + } +} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_virtualmachines_client.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/virtualmachines_client.go similarity index 86% rename from sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_virtualmachines_client.go rename to sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/virtualmachines_client.go index 9df3030a18d8..94bb0c9555da 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_virtualmachines_client.go +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/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 armvmwarecloudsimple @@ -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 } // BeginCreateOrUpdate - Create Or Update Virtual Machine // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// resourceGroupName - The name of the resource group -// referer - referer url -// virtualMachineName - virtual machine name -// virtualMachineRequest - Create or Update Virtual Machine request -// options - VirtualMachinesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group +// - referer - referer url +// - virtualMachineName - virtual machine name +// - virtualMachineRequest - Create or Update Virtual Machine request +// - options - VirtualMachinesClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginCreateOrUpdate +// method. func (client *VirtualMachinesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, referer string, virtualMachineName string, virtualMachineRequest VirtualMachine, options *VirtualMachinesClientBeginCreateOrUpdateOptions) (*runtime.Poller[VirtualMachinesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, referer, virtualMachineName, virtualMachineRequest, 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 Update Virtual Machine // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 func (client *VirtualMachinesClient) createOrUpdate(ctx context.Context, resourceGroupName string, referer string, virtualMachineName string, virtualMachineRequest VirtualMachine, options *VirtualMachinesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, referer, virtualMachineName, virtualMachineRequest, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -109,7 +101,7 @@ func (client *VirtualMachinesClient) createOrUpdateCreateRequest(ctx context.Con return nil, errors.New("parameter virtualMachineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) - 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 +115,35 @@ func (client *VirtualMachinesClient) createOrUpdateCreateRequest(ctx context.Con // BeginDelete - Delete virtual machine // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// resourceGroupName - The name of the resource group -// referer - referer url -// virtualMachineName - virtual machine name -// options - VirtualMachinesClientBeginDeleteOptions contains the optional parameters for the VirtualMachinesClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group +// - referer - referer url +// - virtualMachineName - virtual machine name +// - options - VirtualMachinesClientBeginDeleteOptions contains the optional parameters for the VirtualMachinesClient.BeginDelete +// method. func (client *VirtualMachinesClient) BeginDelete(ctx context.Context, resourceGroupName string, referer string, virtualMachineName string, options *VirtualMachinesClientBeginDeleteOptions) (*runtime.Poller[VirtualMachinesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, referer, virtualMachineName, 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 // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 func (client *VirtualMachinesClient) deleteOperation(ctx context.Context, resourceGroupName string, referer string, virtualMachineName string, options *VirtualMachinesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, referer, virtualMachineName, 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 +168,7 @@ func (client *VirtualMachinesClient) deleteCreateRequest(ctx context.Context, re return nil, errors.New("parameter virtualMachineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -188,16 +182,17 @@ func (client *VirtualMachinesClient) deleteCreateRequest(ctx context.Context, re // Get - Get virtual machine // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// resourceGroupName - The name of the resource group -// virtualMachineName - virtual machine name -// options - VirtualMachinesClientGetOptions contains the optional parameters for the VirtualMachinesClient.Get method. +// - resourceGroupName - The name of the resource group +// - virtualMachineName - virtual machine name +// - options - VirtualMachinesClientGetOptions contains the optional parameters for the VirtualMachinesClient.Get method. func (client *VirtualMachinesClient) Get(ctx context.Context, resourceGroupName string, virtualMachineName string, options *VirtualMachinesClientGetOptions) (VirtualMachinesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, virtualMachineName, 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 } @@ -222,7 +217,7 @@ func (client *VirtualMachinesClient) getCreateRequest(ctx context.Context, resou 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 } @@ -243,11 +238,11 @@ func (client *VirtualMachinesClient) getHandleResponse(resp *http.Response) (Vir } // NewListByResourceGroupPager - Returns list of virtual machine within resource group -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// resourceGroupName - The name of the resource group -// options - VirtualMachinesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachinesClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group +// - options - VirtualMachinesClientListByResourceGroupOptions contains the optional parameters for the VirtualMachinesClient.NewListByResourceGroupPager +// method. func (client *VirtualMachinesClient) NewListByResourceGroupPager(resourceGroupName string, options *VirtualMachinesClientListByResourceGroupOptions) *runtime.Pager[VirtualMachinesClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[VirtualMachinesClientListByResourceGroupResponse]{ More: func(page VirtualMachinesClientListByResourceGroupResponse) bool { @@ -264,7 +259,7 @@ func (client *VirtualMachinesClient) NewListByResourceGroupPager(resourceGroupNa if err != nil { return VirtualMachinesClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachinesClientListByResourceGroupResponse{}, err } @@ -287,7 +282,7 @@ func (client *VirtualMachinesClient) 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 } @@ -317,10 +312,10 @@ func (client *VirtualMachinesClient) listByResourceGroupHandleResponse(resp *htt } // NewListBySubscriptionPager - Returns list virtual machine within subscription -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// options - VirtualMachinesClientListBySubscriptionOptions contains the optional parameters for the VirtualMachinesClient.ListBySubscription -// method. +// - options - VirtualMachinesClientListBySubscriptionOptions contains the optional parameters for the VirtualMachinesClient.NewListBySubscriptionPager +// method. func (client *VirtualMachinesClient) NewListBySubscriptionPager(options *VirtualMachinesClientListBySubscriptionOptions) *runtime.Pager[VirtualMachinesClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[VirtualMachinesClientListBySubscriptionResponse]{ More: func(page VirtualMachinesClientListBySubscriptionResponse) bool { @@ -337,7 +332,7 @@ func (client *VirtualMachinesClient) NewListBySubscriptionPager(options *Virtual if err != nil { return VirtualMachinesClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachinesClientListBySubscriptionResponse{}, err } @@ -356,7 +351,7 @@ func (client *VirtualMachinesClient) 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 } @@ -387,33 +382,35 @@ func (client *VirtualMachinesClient) listBySubscriptionHandleResponse(resp *http // BeginStart - Power on virtual machine // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// resourceGroupName - The name of the resource group -// referer - referer url -// virtualMachineName - virtual machine name -// options - VirtualMachinesClientBeginStartOptions contains the optional parameters for the VirtualMachinesClient.BeginStart -// method. +// - resourceGroupName - The name of the resource group +// - referer - referer url +// - virtualMachineName - virtual machine name +// - options - VirtualMachinesClientBeginStartOptions contains the optional parameters for the VirtualMachinesClient.BeginStart +// method. func (client *VirtualMachinesClient) BeginStart(ctx context.Context, resourceGroupName string, referer string, virtualMachineName string, options *VirtualMachinesClientBeginStartOptions) (*runtime.Poller[VirtualMachinesClientStartResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.start(ctx, resourceGroupName, referer, virtualMachineName, 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 - Power on virtual machine // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 func (client *VirtualMachinesClient) start(ctx context.Context, resourceGroupName string, referer string, virtualMachineName string, options *VirtualMachinesClientBeginStartOptions) (*http.Response, error) { req, err := client.startCreateRequest(ctx, resourceGroupName, referer, virtualMachineName, 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 } @@ -438,7 +435,7 @@ func (client *VirtualMachinesClient) startCreateRequest(ctx context.Context, res return nil, errors.New("parameter virtualMachineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) - 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 } @@ -452,33 +449,35 @@ func (client *VirtualMachinesClient) startCreateRequest(ctx context.Context, res // BeginStop - Power off virtual machine, options: shutdown, poweroff, and suspend // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// resourceGroupName - The name of the resource group -// referer - referer url -// virtualMachineName - virtual machine name -// options - VirtualMachinesClientBeginStopOptions contains the optional parameters for the VirtualMachinesClient.BeginStop -// method. +// - resourceGroupName - The name of the resource group +// - referer - referer url +// - virtualMachineName - virtual machine name +// - options - VirtualMachinesClientBeginStopOptions contains the optional parameters for the VirtualMachinesClient.BeginStop +// method. func (client *VirtualMachinesClient) BeginStop(ctx context.Context, resourceGroupName string, referer string, virtualMachineName string, options *VirtualMachinesClientBeginStopOptions) (*runtime.Poller[VirtualMachinesClientStopResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.stop(ctx, resourceGroupName, referer, virtualMachineName, 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 - Power off virtual machine, options: shutdown, poweroff, and suspend // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 func (client *VirtualMachinesClient) stop(ctx context.Context, resourceGroupName string, referer string, virtualMachineName string, options *VirtualMachinesClientBeginStopOptions) (*http.Response, error) { req, err := client.stopCreateRequest(ctx, resourceGroupName, referer, virtualMachineName, 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 } @@ -503,7 +502,7 @@ func (client *VirtualMachinesClient) stopCreateRequest(ctx context.Context, reso return nil, errors.New("parameter virtualMachineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) - 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 } @@ -523,33 +522,35 @@ func (client *VirtualMachinesClient) stopCreateRequest(ctx context.Context, reso // BeginUpdate - Patch virtual machine properties // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// resourceGroupName - The name of the resource group -// virtualMachineName - virtual machine name -// virtualMachineRequest - Patch virtual machine request -// options - VirtualMachinesClientBeginUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginUpdate -// method. +// - resourceGroupName - The name of the resource group +// - virtualMachineName - virtual machine name +// - virtualMachineRequest - Patch virtual machine request +// - options - VirtualMachinesClientBeginUpdateOptions contains the optional parameters for the VirtualMachinesClient.BeginUpdate +// method. func (client *VirtualMachinesClient) BeginUpdate(ctx context.Context, resourceGroupName string, virtualMachineName string, virtualMachineRequest PatchPayload, options *VirtualMachinesClientBeginUpdateOptions) (*runtime.Poller[VirtualMachinesClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, virtualMachineName, virtualMachineRequest, options) if err != nil { return nil, err } - return runtime.NewPoller[VirtualMachinesClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[VirtualMachinesClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VirtualMachinesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Patch virtual machine properties // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 func (client *VirtualMachinesClient) update(ctx context.Context, resourceGroupName string, virtualMachineName string, virtualMachineRequest PatchPayload, options *VirtualMachinesClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, virtualMachineName, virtualMachineRequest, 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 } @@ -574,7 +575,7 @@ func (client *VirtualMachinesClient) updateCreateRequest(ctx context.Context, re return nil, errors.New("parameter virtualMachineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineName}", url.PathEscape(virtualMachineName)) - 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/vmwarecloudsimple/armvmwarecloudsimple/virtualmachines_client_example_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/virtualmachines_client_example_test.go new file mode 100644 index 000000000000..1d983976882b --- /dev/null +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/virtualmachines_client_example_test.go @@ -0,0 +1,661 @@ +//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 armvmwarecloudsimple_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/vmwarecloudsimple/armvmwarecloudsimple" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListVirtualMachines.json +func ExampleVirtualMachinesClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewVirtualMachinesClient().NewListBySubscriptionPager(&armvmwarecloudsimple.VirtualMachinesClientListBySubscriptionOptions{Filter: nil, + Top: 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.VirtualMachineListResponse = armvmwarecloudsimple.VirtualMachineListResponse{ + // Value: []*armvmwarecloudsimple.VirtualMachine{ + // { + // Name: to.Ptr("virtualMachine-1"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualMachines"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup-1/providers/Microsoft.VMwareCloudSimple/virtualMachines/virtualMachine-1"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualMachineProperties{ + // AmountOfRAM: to.Ptr[int32](4096), + // Controllers: []*armvmwarecloudsimple.VirtualDiskController{ + // { + // Name: to.Ptr("SCSI controller 0"), + // Type: to.Ptr("SCSI"), + // ID: to.Ptr("1000"), + // SubType: to.Ptr("LSI_PARALEL"), + // }}, + // Disks: []*armvmwarecloudsimple.VirtualDisk{ + // { + // ControllerID: to.Ptr("1000"), + // IndependenceMode: to.Ptr(armvmwarecloudsimple.DiskIndependenceModePersistent), + // TotalSize: to.Ptr[int32](10485760), + // VirtualDiskID: to.Ptr("2000"), + // VirtualDiskName: to.Ptr("Hard disk 1"), + // }}, + // GuestOS: to.Ptr("Other (32-bit)"), + // GuestOSType: to.Ptr(armvmwarecloudsimple.GuestOSTypeOther), + // Nics: []*armvmwarecloudsimple.VirtualNic{ + // { + // MacAddress: to.Ptr("00:50:56:a6:d0:e1"), + // Network: &armvmwarecloudsimple.VirtualNetwork{ + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-19"), + // }, + // NicType: to.Ptr(armvmwarecloudsimple.NICTypeE1000), + // PowerOnBoot: to.Ptr(true), + // VirtualNicID: to.Ptr("4000"), + // VirtualNicName: to.Ptr("Network adapter 1"), + // }}, + // NumberOfCores: to.Ptr[int32](2), + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // ResourcePool: &armvmwarecloudsimple.ResourcePool{ + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/rp-test/resourcepools/resgroup-26"), + // }, + // TemplateID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualMachineTemplates/vm-34"), + // VMID: to.Ptr("vm-100"), + // Vmwaretools: to.Ptr("10309"), + // }, + // Tags: map[string]*string{ + // "inUse": to.Ptr("true"), + // }, + // }, + // { + // Name: to.Ptr("virtualMachine-2"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualMachines"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup-2/providers/Microsoft.VMwareCloudSimple/virtualMachines/virtualMachine-2"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualMachineProperties{ + // AmountOfRAM: to.Ptr[int32](4096), + // Controllers: []*armvmwarecloudsimple.VirtualDiskController{ + // { + // Name: to.Ptr("SCSI controller 0"), + // Type: to.Ptr("SCSI"), + // ID: to.Ptr("1000"), + // SubType: to.Ptr("LSI_PARALEL"), + // }}, + // Disks: []*armvmwarecloudsimple.VirtualDisk{ + // { + // ControllerID: to.Ptr("1000"), + // IndependenceMode: to.Ptr(armvmwarecloudsimple.DiskIndependenceModePersistent), + // TotalSize: to.Ptr[int32](10485760), + // VirtualDiskID: to.Ptr("2000"), + // VirtualDiskName: to.Ptr("Hard disk 1"), + // }}, + // GuestOS: to.Ptr("Other (32-bit)"), + // GuestOSType: to.Ptr(armvmwarecloudsimple.GuestOSTypeOther), + // Nics: []*armvmwarecloudsimple.VirtualNic{ + // { + // MacAddress: to.Ptr("00:50:56:a6:33:12"), + // Network: &armvmwarecloudsimple.VirtualNetwork{ + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-19"), + // }, + // NicType: to.Ptr(armvmwarecloudsimple.NICTypeE1000), + // PowerOnBoot: to.Ptr(true), + // VirtualNicID: to.Ptr("4000"), + // VirtualNicName: to.Ptr("Network adapter 1"), + // }}, + // NumberOfCores: to.Ptr[int32](2), + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // ResourcePool: &armvmwarecloudsimple.ResourcePool{ + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/rp-test/resourcepools/resgroup-26"), + // }, + // TemplateID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualMachineTemplates/vm-34"), + // VMID: to.Ptr("vm-101"), + // Vmwaretools: to.Ptr("10309"), + // }, + // Tags: map[string]*string{ + // "inUse": to.Ptr("true"), + // }, + // }, + // { + // Name: to.Ptr("virtualMachine-3"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualMachines"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup-1/providers/Microsoft.VMwareCloudSimple/virtualMachines/virtualMachine-3"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualMachineProperties{ + // AmountOfRAM: to.Ptr[int32](4096), + // Controllers: []*armvmwarecloudsimple.VirtualDiskController{ + // { + // Name: to.Ptr("SCSI controller 0"), + // Type: to.Ptr("SCSI"), + // ID: to.Ptr("1000"), + // SubType: to.Ptr("LSI_PARALEL"), + // }}, + // Disks: []*armvmwarecloudsimple.VirtualDisk{ + // { + // ControllerID: to.Ptr("1000"), + // IndependenceMode: to.Ptr(armvmwarecloudsimple.DiskIndependenceModePersistent), + // TotalSize: to.Ptr[int32](10485760), + // VirtualDiskID: to.Ptr("2000"), + // VirtualDiskName: to.Ptr("Hard disk 1"), + // }}, + // GuestOS: to.Ptr("Other (32-bit)"), + // GuestOSType: to.Ptr(armvmwarecloudsimple.GuestOSTypeOther), + // Nics: []*armvmwarecloudsimple.VirtualNic{ + // { + // MacAddress: to.Ptr("00:50:56:a6:63:f3"), + // Network: &armvmwarecloudsimple.VirtualNetwork{ + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-19"), + // }, + // NicType: to.Ptr(armvmwarecloudsimple.NICTypeE1000), + // PowerOnBoot: to.Ptr(true), + // VirtualNicID: to.Ptr("4000"), + // VirtualNicName: to.Ptr("Network adapter 1"), + // }}, + // NumberOfCores: to.Ptr[int32](2), + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // ResourcePool: &armvmwarecloudsimple.ResourcePool{ + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/rp-test/resourcepools/resgroup-26"), + // }, + // TemplateID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualMachineTemplates/vm-34"), + // VMID: to.Ptr("vm-102"), + // Vmwaretools: to.Ptr("10309"), + // }, + // Tags: map[string]*string{ + // "inUse": to.Ptr("true"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListRGVirtualMachines.json +func ExampleVirtualMachinesClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewVirtualMachinesClient().NewListByResourceGroupPager("myResourceGroup", &armvmwarecloudsimple.VirtualMachinesClientListByResourceGroupOptions{Filter: nil, + Top: 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.VirtualMachineListResponse = armvmwarecloudsimple.VirtualMachineListResponse{ + // Value: []*armvmwarecloudsimple.VirtualMachine{ + // { + // Name: to.Ptr("virtualMachine-2"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualMachines"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.VMwareCloudSimple/virtualMachines/virtualMachine-2"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualMachineProperties{ + // AmountOfRAM: to.Ptr[int32](4096), + // Controllers: []*armvmwarecloudsimple.VirtualDiskController{ + // { + // Name: to.Ptr("SCSI controller 0"), + // Type: to.Ptr("SCSI"), + // ID: to.Ptr("1000"), + // SubType: to.Ptr("LSI_PARALEL"), + // }}, + // Disks: []*armvmwarecloudsimple.VirtualDisk{ + // { + // ControllerID: to.Ptr("1000"), + // IndependenceMode: to.Ptr(armvmwarecloudsimple.DiskIndependenceModePersistent), + // TotalSize: to.Ptr[int32](10485760), + // VirtualDiskID: to.Ptr("2000"), + // VirtualDiskName: to.Ptr("Hard disk 1"), + // }}, + // GuestOS: to.Ptr("Other (32-bit)"), + // GuestOSType: to.Ptr(armvmwarecloudsimple.GuestOSTypeOther), + // Nics: []*armvmwarecloudsimple.VirtualNic{ + // { + // MacAddress: to.Ptr("00:50:56:a6:33:12"), + // Network: &armvmwarecloudsimple.VirtualNetwork{ + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-19"), + // }, + // NicType: to.Ptr(armvmwarecloudsimple.NICTypeE1000), + // PowerOnBoot: to.Ptr(true), + // VirtualNicID: to.Ptr("4000"), + // VirtualNicName: to.Ptr("Network adapter 1"), + // }}, + // NumberOfCores: to.Ptr[int32](2), + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // ResourcePool: &armvmwarecloudsimple.ResourcePool{ + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/rp-test/resourcepools/resgroup-26"), + // }, + // TemplateID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualMachineTemplates/vm-34"), + // VMID: to.Ptr("vm-101"), + // Vmwaretools: to.Ptr("10309"), + // }, + // Tags: map[string]*string{ + // "inUse": to.Ptr("true"), + // }, + // }, + // { + // Name: to.Ptr("virtualMachine-3"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualMachines"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.VMwareCloudSimple/virtualMachines/virtualMachine-3"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualMachineProperties{ + // AmountOfRAM: to.Ptr[int32](4096), + // Controllers: []*armvmwarecloudsimple.VirtualDiskController{ + // { + // Name: to.Ptr("SCSI controller 0"), + // Type: to.Ptr("SCSI"), + // ID: to.Ptr("1000"), + // SubType: to.Ptr("LSI_PARALEL"), + // }}, + // Disks: []*armvmwarecloudsimple.VirtualDisk{ + // { + // ControllerID: to.Ptr("1000"), + // IndependenceMode: to.Ptr(armvmwarecloudsimple.DiskIndependenceModePersistent), + // TotalSize: to.Ptr[int32](10485760), + // VirtualDiskID: to.Ptr("2000"), + // VirtualDiskName: to.Ptr("Hard disk 1"), + // }}, + // GuestOS: to.Ptr("Other (32-bit)"), + // GuestOSType: to.Ptr(armvmwarecloudsimple.GuestOSTypeOther), + // Nics: []*armvmwarecloudsimple.VirtualNic{ + // { + // MacAddress: to.Ptr("00:50:56:a6:63:f3"), + // Network: &armvmwarecloudsimple.VirtualNetwork{ + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-19"), + // }, + // NicType: to.Ptr(armvmwarecloudsimple.NICTypeE1000), + // PowerOnBoot: to.Ptr(true), + // VirtualNicID: to.Ptr("4000"), + // VirtualNicName: to.Ptr("Network adapter 1"), + // }}, + // NumberOfCores: to.Ptr[int32](2), + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // ResourcePool: &armvmwarecloudsimple.ResourcePool{ + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/rp-test/resourcepools/resgroup-26"), + // }, + // TemplateID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualMachineTemplates/vm-34"), + // VMID: to.Ptr("vm-102"), + // Vmwaretools: to.Ptr("10309"), + // }, + // Tags: map[string]*string{ + // "inUse": to.Ptr("true"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/GetVirtualMachine.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 := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewVirtualMachinesClient().Get(ctx, "myResourceGroup", "myVirtualMachine", 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.VirtualMachine = armvmwarecloudsimple.VirtualMachine{ + // Name: to.Ptr("myVirtualMachine"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualMachines"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourcegroups/myResourceGroup/providers/Microsoft.VMwareCloudSimple/virtualMachines/myVirtualMachine"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualMachineProperties{ + // AmountOfRAM: to.Ptr[int32](4096), + // Controllers: []*armvmwarecloudsimple.VirtualDiskController{ + // { + // Name: to.Ptr("SCSI controller 0"), + // Type: to.Ptr("SCSI"), + // ID: to.Ptr("1000"), + // SubType: to.Ptr("LSI_PARALEL"), + // }}, + // Disks: []*armvmwarecloudsimple.VirtualDisk{ + // { + // ControllerID: to.Ptr("1000"), + // IndependenceMode: to.Ptr(armvmwarecloudsimple.DiskIndependenceModePersistent), + // TotalSize: to.Ptr[int32](10485760), + // VirtualDiskID: to.Ptr("2000"), + // VirtualDiskName: to.Ptr("Hard disk 1"), + // }}, + // Folder: to.Ptr("Datacenter/Workload VMs"), + // GuestOS: to.Ptr("Other (32-bit)"), + // GuestOSType: to.Ptr(armvmwarecloudsimple.GuestOSTypeOther), + // Nics: []*armvmwarecloudsimple.VirtualNic{ + // { + // MacAddress: to.Ptr("00:50:56:a6:d0:e1"), + // Network: &armvmwarecloudsimple.VirtualNetwork{ + // Name: to.Ptr("Datacenter/CS-Management"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualNetworks"), + // Assignable: to.Ptr(false), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualnetworks/dvportgroup-19"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualNetworkProperties{ + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // }, + // }, + // NicType: to.Ptr(armvmwarecloudsimple.NICTypeE1000), + // PowerOnBoot: to.Ptr(true), + // VirtualNicID: to.Ptr("4000"), + // VirtualNicName: to.Ptr("Network adapter 1"), + // }}, + // NumberOfCores: to.Ptr[int32](2), + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // ProvisioningState: to.Ptr("Succeeded"), + // ResourcePool: &armvmwarecloudsimple.ResourcePool{ + // Name: to.Ptr("Workload"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/resourcePools"), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/resourcepools/resgroup-26"), + // Location: to.Ptr("westus2"), + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // Properties: &armvmwarecloudsimple.ResourcePoolProperties{ + // FullName: to.Ptr("Datacenter/Cluster/Workload"), + // }, + // }, + // Status: to.Ptr(armvmwarecloudsimple.VirtualMachineStatusRunning), + // TemplateID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualmachinetemplates/vm-34"), + // VMID: to.Ptr("vm-100"), + // Vmwaretools: to.Ptr("10309"), + // }, + // Tags: map[string]*string{ + // "inUse": to.Ptr("true"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/CreateVirtualMachine.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 := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachinesClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "https://management.azure.com/", "myVirtualMachine", armvmwarecloudsimple.VirtualMachine{ + Location: to.Ptr("westus2"), + Properties: &armvmwarecloudsimple.VirtualMachineProperties{ + AmountOfRAM: to.Ptr[int32](4096), + Disks: []*armvmwarecloudsimple.VirtualDisk{ + { + ControllerID: to.Ptr("1000"), + IndependenceMode: to.Ptr(armvmwarecloudsimple.DiskIndependenceModePersistent), + TotalSize: to.Ptr[int32](10485760), + VirtualDiskID: to.Ptr("2000"), + }}, + Nics: []*armvmwarecloudsimple.VirtualNic{ + { + Network: &armvmwarecloudsimple.VirtualNetwork{ + ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-19"), + }, + NicType: to.Ptr(armvmwarecloudsimple.NICTypeE1000), + PowerOnBoot: to.Ptr(true), + VirtualNicID: to.Ptr("4000"), + }}, + NumberOfCores: to.Ptr[int32](2), + PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + ResourcePool: &armvmwarecloudsimple.ResourcePool{ + ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/resourcePools/resgroup-26"), + }, + TemplateID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualMachineTemplates/vm-34"), + }, + }, 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.VirtualMachine = armvmwarecloudsimple.VirtualMachine{ + // Name: to.Ptr("myVirtualMachine"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualMachines"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.VMwareCloudSimple/virtualMachines/myVirtualMachine"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualMachineProperties{ + // AmountOfRAM: to.Ptr[int32](4096), + // Controllers: []*armvmwarecloudsimple.VirtualDiskController{ + // }, + // Disks: []*armvmwarecloudsimple.VirtualDisk{ + // { + // ControllerID: to.Ptr("1000"), + // IndependenceMode: to.Ptr(armvmwarecloudsimple.DiskIndependenceModePersistent), + // TotalSize: to.Ptr[int32](10485760), + // VirtualDiskID: to.Ptr("2000"), + // VirtualDiskName: to.Ptr("Hard disk 1"), + // }}, + // GuestOS: to.Ptr("Other (32-bit)"), + // GuestOSType: to.Ptr(armvmwarecloudsimple.GuestOSTypeOther), + // Nics: []*armvmwarecloudsimple.VirtualNic{ + // { + // Network: &armvmwarecloudsimple.VirtualNetwork{ + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-19"), + // }, + // NicType: to.Ptr(armvmwarecloudsimple.NICTypeE1000), + // PowerOnBoot: to.Ptr(true), + // VirtualNicID: to.Ptr("4000"), + // VirtualNicName: to.Ptr("Network adapter 1"), + // }}, + // NumberOfCores: to.Ptr[int32](2), + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // ProvisioningState: to.Ptr("Succeeded"), + // ResourcePool: &armvmwarecloudsimple.ResourcePool{ + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/resourcePools/resgroup-26"), + // }, + // TemplateID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualMachineTemplates/vm-34"), + // Vmwaretools: to.Ptr("0"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/DeleteVirtualMachine.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 := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachinesClient().BeginDelete(ctx, "myResourceGroup", "https://management.azure.com/", "myVirtualMachine", 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/PatchVirtualMachine.json +func ExampleVirtualMachinesClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachinesClient().BeginUpdate(ctx, "myResourceGroup", "myVirtualMachine", armvmwarecloudsimple.PatchPayload{ + Tags: map[string]*string{ + "myTag": to.Ptr("tagValue"), + }, + }, 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.VirtualMachine = armvmwarecloudsimple.VirtualMachine{ + // Name: to.Ptr("myVirtualMachine"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualMachines"), + // ID: to.Ptr("/subscriptions/{subscription-id}/resourcegroups/myResourceGroup/providers/Microsoft.VMwareCloudSimple/virtualMachines/myVirtualMachine"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualMachineProperties{ + // AmountOfRAM: to.Ptr[int32](4096), + // Controllers: []*armvmwarecloudsimple.VirtualDiskController{ + // { + // Name: to.Ptr("SCSI controller 0"), + // Type: to.Ptr("SCSI"), + // ID: to.Ptr("1000"), + // SubType: to.Ptr("LSI_PARALEL"), + // }}, + // Disks: []*armvmwarecloudsimple.VirtualDisk{ + // { + // ControllerID: to.Ptr("1000"), + // IndependenceMode: to.Ptr(armvmwarecloudsimple.DiskIndependenceModePersistent), + // TotalSize: to.Ptr[int32](10485760), + // VirtualDiskID: to.Ptr("2000"), + // VirtualDiskName: to.Ptr("Hard disk 1"), + // }}, + // GuestOS: to.Ptr("Other (32-bit)"), + // GuestOSType: to.Ptr(armvmwarecloudsimple.GuestOSTypeOther), + // Nics: []*armvmwarecloudsimple.VirtualNic{ + // { + // Network: &armvmwarecloudsimple.VirtualNetwork{ + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-19"), + // }, + // NicType: to.Ptr(armvmwarecloudsimple.NICTypeE1000), + // PowerOnBoot: to.Ptr(true), + // VirtualNicID: to.Ptr("4000"), + // VirtualNicName: to.Ptr("Network adapter 1"), + // }}, + // NumberOfCores: to.Ptr[int32](2), + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // ProvisioningState: to.Ptr("Succeeded"), + // ResourcePool: &armvmwarecloudsimple.ResourcePool{ + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/resourcePools/resgroup-26"), + // }, + // Status: to.Ptr(armvmwarecloudsimple.VirtualMachineStatusRunning), + // TemplateID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualMachineTemplates/vm-34"), + // VMID: to.Ptr("vm-106"), + // Vmwaretools: to.Ptr("10309"), + // }, + // Tags: map[string]*string{ + // "myTag": to.Ptr("tagValue"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/StartVirtualMachine.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 := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachinesClient().BeginStart(ctx, "myResourceGroup", "https://management.azure.com/", "myVirtualMachine", 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/StopInBodyVirtualMachine.json +func ExampleVirtualMachinesClient_BeginStop_stopInBodyVirtualMachine() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachinesClient().BeginStop(ctx, "myResourceGroup", "https://management.azure.com/", "myVirtualMachine", &armvmwarecloudsimple.VirtualMachinesClientBeginStopOptions{Mode: nil, + M: &armvmwarecloudsimple.VirtualMachineStopMode{}, + }) + 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/StopInQueryVirtualMachine.json +func ExampleVirtualMachinesClient_BeginStop_stopInQueryVirtualMachine() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewVirtualMachinesClient().BeginStop(ctx, "myResourceGroup", "https://management.azure.com/", "myVirtualMachine", &armvmwarecloudsimple.VirtualMachinesClientBeginStopOptions{Mode: to.Ptr(armvmwarecloudsimple.StopModeSuspend), + M: 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/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_virtualmachinetemplates_client.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/virtualmachinetemplates_client.go similarity index 82% rename from sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_virtualmachinetemplates_client.go rename to sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/virtualmachinetemplates_client.go index 92e4a001434a..6667f9465a7b 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_virtualmachinetemplates_client.go +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/virtualmachinetemplates_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 armvmwarecloudsimple @@ -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 ( // VirtualMachineTemplatesClient contains the methods for the VirtualMachineTemplates group. // Don't use this type directly, use NewVirtualMachineTemplatesClient() instead. type VirtualMachineTemplatesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewVirtualMachineTemplatesClient creates a new instance of VirtualMachineTemplatesClient 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 NewVirtualMachineTemplatesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualMachineTemplatesClient, 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+".VirtualMachineTemplatesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &VirtualMachineTemplatesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Returns virtual machine templates by its name // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// regionID - The region Id (westus, eastus) -// pcName - The private cloud name -// virtualMachineTemplateName - virtual machine template id (vsphereId) -// options - VirtualMachineTemplatesClientGetOptions contains the optional parameters for the VirtualMachineTemplatesClient.Get -// method. +// - regionID - The region Id (westus, eastus) +// - pcName - The private cloud name +// - virtualMachineTemplateName - virtual machine template id (vsphereId) +// - options - VirtualMachineTemplatesClientGetOptions contains the optional parameters for the VirtualMachineTemplatesClient.Get +// method. func (client *VirtualMachineTemplatesClient) Get(ctx context.Context, regionID string, pcName string, virtualMachineTemplateName string, options *VirtualMachineTemplatesClientGetOptions) (VirtualMachineTemplatesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, regionID, pcName, virtualMachineTemplateName, options) if err != nil { return VirtualMachineTemplatesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachineTemplatesClientGetResponse{}, err } @@ -96,7 +87,7 @@ func (client *VirtualMachineTemplatesClient) getCreateRequest(ctx context.Contex return nil, errors.New("parameter virtualMachineTemplateName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualMachineTemplateName}", url.PathEscape(virtualMachineTemplateName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -117,13 +108,13 @@ func (client *VirtualMachineTemplatesClient) getHandleResponse(resp *http.Respon } // NewListPager - Returns list of virtual machine templates in region for private cloud -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// pcName - The private cloud name -// regionID - The region Id (westus, eastus) -// resourcePoolName - Resource pool used to derive vSphere cluster which contains VM templates -// options - VirtualMachineTemplatesClientListOptions contains the optional parameters for the VirtualMachineTemplatesClient.List -// method. +// - pcName - The private cloud name +// - regionID - The region Id (westus, eastus) +// - resourcePoolName - Resource pool used to derive vSphere cluster which contains VM templates +// - options - VirtualMachineTemplatesClientListOptions contains the optional parameters for the VirtualMachineTemplatesClient.NewListPager +// method. func (client *VirtualMachineTemplatesClient) NewListPager(pcName string, regionID string, resourcePoolName string, options *VirtualMachineTemplatesClientListOptions) *runtime.Pager[VirtualMachineTemplatesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[VirtualMachineTemplatesClientListResponse]{ More: func(page VirtualMachineTemplatesClientListResponse) bool { @@ -140,7 +131,7 @@ func (client *VirtualMachineTemplatesClient) NewListPager(pcName string, regionI if err != nil { return VirtualMachineTemplatesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachineTemplatesClientListResponse{}, err } @@ -167,7 +158,7 @@ func (client *VirtualMachineTemplatesClient) listCreateRequest(ctx context.Conte return nil, errors.New("parameter regionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{regionId}", url.PathEscape(regionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/vmwarecloudsimple/armvmwarecloudsimple/virtualmachinetemplates_client_example_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/virtualmachinetemplates_client_example_test.go new file mode 100644 index 000000000000..f12d5f54b68f --- /dev/null +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/virtualmachinetemplates_client_example_test.go @@ -0,0 +1,148 @@ +//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 armvmwarecloudsimple_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListVirtualMachineTemplates.json +func ExampleVirtualMachineTemplatesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewVirtualMachineTemplatesClient().NewListPager("myPrivateCloud", "westus2", "/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/resourcePools/resgroup-26", 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.VirtualMachineTemplateListResponse = armvmwarecloudsimple.VirtualMachineTemplateListResponse{ + // Value: []*armvmwarecloudsimple.VirtualMachineTemplate{ + // { + // Name: to.Ptr("centos-template"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualMachineTemplates"), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualMachineTemplates/vm-34"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualMachineTemplateProperties{ + // Path: to.Ptr("Datacenter/Workload VMs"), + // AmountOfRAM: to.Ptr[int32](4096), + // Controllers: []*armvmwarecloudsimple.VirtualDiskController{ + // { + // Name: to.Ptr("SCSI controller 0"), + // Type: to.Ptr("SCSI"), + // ID: to.Ptr("1000"), + // SubType: to.Ptr("LSI_PARALEL"), + // }}, + // Disks: []*armvmwarecloudsimple.VirtualDisk{ + // { + // ControllerID: to.Ptr("1000"), + // IndependenceMode: to.Ptr(armvmwarecloudsimple.DiskIndependenceModePersistent), + // TotalSize: to.Ptr[int32](10485760), + // VirtualDiskID: to.Ptr("2000"), + // VirtualDiskName: to.Ptr("Hard disk 1"), + // }}, + // GuestOS: to.Ptr("Other (32-bit)"), + // GuestOSType: to.Ptr("other"), + // Nics: []*armvmwarecloudsimple.VirtualNic{ + // { + // MacAddress: to.Ptr("00:50:56:a6:7e:93"), + // Network: &armvmwarecloudsimple.VirtualNetwork{ + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-19"), + // }, + // NicType: to.Ptr(armvmwarecloudsimple.NICTypeE1000), + // PowerOnBoot: to.Ptr(true), + // VirtualNicID: to.Ptr("4000"), + // VirtualNicName: to.Ptr("Network adapter 1"), + // }}, + // NumberOfCores: to.Ptr[int32](2), + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // Vmwaretools: to.Ptr("10309"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/GetVirtualMachineTemplate.json +func ExampleVirtualMachineTemplatesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewVirtualMachineTemplatesClient().Get(ctx, "westus2", "myPrivateCloud", "vm-34", 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.VirtualMachineTemplate = armvmwarecloudsimple.VirtualMachineTemplate{ + // Name: to.Ptr("centos-template"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualMachineTemplates"), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualMachineTemplates/vm-34"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualMachineTemplateProperties{ + // Path: to.Ptr("Datacenter/Workload VMs"), + // AmountOfRAM: to.Ptr[int32](4096), + // Controllers: []*armvmwarecloudsimple.VirtualDiskController{ + // { + // Name: to.Ptr("SCSI controller 0"), + // Type: to.Ptr("SCSI"), + // ID: to.Ptr("1000"), + // SubType: to.Ptr("LSI_PARALEL"), + // }}, + // Disks: []*armvmwarecloudsimple.VirtualDisk{ + // { + // ControllerID: to.Ptr("1000"), + // IndependenceMode: to.Ptr(armvmwarecloudsimple.DiskIndependenceModePersistent), + // TotalSize: to.Ptr[int32](10485760), + // VirtualDiskID: to.Ptr("2000"), + // VirtualDiskName: to.Ptr("Hard disk 1"), + // }}, + // GuestOS: to.Ptr("Other (32-bit)"), + // GuestOSType: to.Ptr("other"), + // Nics: []*armvmwarecloudsimple.VirtualNic{ + // { + // MacAddress: to.Ptr("00:50:56:a6:7e:93"), + // Network: &armvmwarecloudsimple.VirtualNetwork{ + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-19"), + // }, + // NicType: to.Ptr(armvmwarecloudsimple.NICTypeE1000), + // PowerOnBoot: to.Ptr(true), + // VirtualNicID: to.Ptr("4000"), + // VirtualNicName: to.Ptr("Network adapter 1"), + // }}, + // NumberOfCores: to.Ptr[int32](2), + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // Vmwaretools: to.Ptr("10309"), + // }, + // } +} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_virtualnetworks_client.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/virtualnetworks_client.go similarity index 82% rename from sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_virtualnetworks_client.go rename to sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/virtualnetworks_client.go index bc93d0675570..5c0f8583fec1 100644 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_virtualnetworks_client.go +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/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 armvmwarecloudsimple @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // 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 } // Get - Return virtual network by its name // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// regionID - The region Id (westus, eastus) -// pcName - The private cloud name -// virtualNetworkName - virtual network id (vsphereId) -// options - VirtualNetworksClientGetOptions contains the optional parameters for the VirtualNetworksClient.Get method. +// - regionID - The region Id (westus, eastus) +// - pcName - The private cloud name +// - virtualNetworkName - virtual network id (vsphereId) +// - options - VirtualNetworksClientGetOptions contains the optional parameters for the VirtualNetworksClient.Get method. func (client *VirtualNetworksClient) Get(ctx context.Context, regionID string, pcName string, virtualNetworkName string, options *VirtualNetworksClientGetOptions) (VirtualNetworksClientGetResponse, error) { req, err := client.getCreateRequest(ctx, regionID, pcName, virtualNetworkName, 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 } @@ -95,7 +86,7 @@ func (client *VirtualNetworksClient) getCreateRequest(ctx context.Context, regio return nil, errors.New("parameter virtualNetworkName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{virtualNetworkName}", url.PathEscape(virtualNetworkName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -116,12 +107,13 @@ func (client *VirtualNetworksClient) getHandleResponse(resp *http.Response) (Vir } // NewListPager - Return list of virtual networks in location for private cloud -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-04-01 -// regionID - The region Id (westus, eastus) -// pcName - The private cloud name -// resourcePoolName - Resource pool used to derive vSphere cluster which contains virtual networks -// options - VirtualNetworksClientListOptions contains the optional parameters for the VirtualNetworksClient.List method. +// - regionID - The region Id (westus, eastus) +// - pcName - The private cloud name +// - resourcePoolName - Resource pool used to derive vSphere cluster which contains virtual networks +// - options - VirtualNetworksClientListOptions contains the optional parameters for the VirtualNetworksClient.NewListPager +// method. func (client *VirtualNetworksClient) NewListPager(regionID string, pcName string, resourcePoolName string, options *VirtualNetworksClientListOptions) *runtime.Pager[VirtualNetworksClientListResponse] { return runtime.NewPager(runtime.PagingHandler[VirtualNetworksClientListResponse]{ More: func(page VirtualNetworksClientListResponse) bool { @@ -138,7 +130,7 @@ func (client *VirtualNetworksClient) NewListPager(regionID string, pcName string 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 } @@ -165,7 +157,7 @@ func (client *VirtualNetworksClient) listCreateRequest(ctx context.Context, regi return nil, errors.New("parameter pcName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{pcName}", url.PathEscape(pcName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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/vmwarecloudsimple/armvmwarecloudsimple/virtualnetworks_client_example_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/virtualnetworks_client_example_test.go new file mode 100644 index 000000000000..ff0a3f74e3f8 --- /dev/null +++ b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/virtualnetworks_client_example_test.go @@ -0,0 +1,126 @@ +//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 armvmwarecloudsimple_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListVirtualNetworks.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 := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewVirtualNetworksClient().NewListPager("westus2", "myPrivateCloud", "/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/resourcePools/resgroup-26", 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.VirtualNetworkListResponse = armvmwarecloudsimple.VirtualNetworkListResponse{ + // Value: []*armvmwarecloudsimple.VirtualNetwork{ + // { + // Name: to.Ptr("Datacenter/CS-Management"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualNetworks"), + // Assignable: to.Ptr(false), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-19"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualNetworkProperties{ + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // }, + // }, + // { + // Name: to.Ptr("Datacenter/CS-Rescue"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualNetworks"), + // Assignable: to.Ptr(true), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-20"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualNetworkProperties{ + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // }, + // }, + // { + // Name: to.Ptr("Datacenter/CS-VSAN"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualNetworks"), + // Assignable: to.Ptr(false), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-21"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualNetworkProperties{ + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // }, + // }, + // { + // Name: to.Ptr("Datacenter/CS-VMotion"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualNetworks"), + // Assignable: to.Ptr(false), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-22"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualNetworkProperties{ + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // }, + // }, + // { + // Name: to.Ptr("Datacenter/net-01"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualNetworks"), + // Assignable: to.Ptr(true), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-35"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualNetworkProperties{ + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/GetVirtualNetwork.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 := armvmwarecloudsimple.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewVirtualNetworksClient().Get(ctx, "westus2", "myPrivateCloud", "dvportgroup-19", 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 = armvmwarecloudsimple.VirtualNetwork{ + // Name: to.Ptr("Datacenter/CS-Management"), + // Type: to.Ptr("Microsoft.VMwareCloudSimple/virtualNetworks"), + // Assignable: to.Ptr(false), + // ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-19"), + // Location: to.Ptr("westus2"), + // Properties: &armvmwarecloudsimple.VirtualNetworkProperties{ + // PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), + // }, + // } +} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_customizationpolicies_client_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_customizationpolicies_client_test.go deleted file mode 100644 index 4bff28692bb9..000000000000 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_customizationpolicies_client_test.go +++ /dev/null @@ -1,66 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armvmwarecloudsimple_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListCustomizationPolicies.json -func ExampleCustomizationPoliciesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewCustomizationPoliciesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("myResourceGroup", - "myPrivateCloud", - &armvmwarecloudsimple.CustomizationPoliciesClientListOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/GetCustomizationPolicy.json -func ExampleCustomizationPoliciesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewCustomizationPoliciesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "myResourceGroup", - "myPrivateCloud", - "Linux1", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_dedicatedcloudnodes_client_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_dedicatedcloudnodes_client_test.go deleted file mode 100644 index 48a6ef740c85..000000000000 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_dedicatedcloudnodes_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 armvmwarecloudsimple_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/vmwarecloudsimple/armvmwarecloudsimple" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListDedicatedCloudNodes.json -func ExampleDedicatedCloudNodesClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewDedicatedCloudNodesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(&armvmwarecloudsimple.DedicatedCloudNodesClientListBySubscriptionOptions{Filter: nil, - Top: 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListRGDedicatedCloudNodes.json -func ExampleDedicatedCloudNodesClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewDedicatedCloudNodesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("myResourceGroup", - &armvmwarecloudsimple.DedicatedCloudNodesClientListByResourceGroupOptions{Filter: nil, - Top: 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/GetDedicatedCloudNode.json -func ExampleDedicatedCloudNodesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewDedicatedCloudNodesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "myResourceGroup", - "myNode", - 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/CreateDedicatedCloudNode.json -func ExampleDedicatedCloudNodesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewDedicatedCloudNodesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "myResourceGroup", - "https://management.azure.com/", - "myNode", - armvmwarecloudsimple.DedicatedCloudNode{ - Location: to.Ptr("westus"), - Properties: &armvmwarecloudsimple.DedicatedCloudNodeProperties{ - AvailabilityZoneID: to.Ptr("az1"), - NodesCount: to.Ptr[int32](1), - PlacementGroupID: to.Ptr("n1"), - PurchaseID: to.Ptr("56acbd46-3d36-4bbf-9b08-57c30fdf6932"), - SKUDescription: &armvmwarecloudsimple.SKUDescription{ - Name: to.Ptr("CS28-Node"), - ID: to.Ptr("general"), - }, - }, - SKU: &armvmwarecloudsimple.SKU{ - Name: to.Ptr("VMware_CloudSimple_CS28"), - }, - }, - 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/DeleteDedicatedCloudNode.json -func ExampleDedicatedCloudNodesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewDedicatedCloudNodesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "myResourceGroup", - "myNode", - 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/PatchDedicatedCloudNode.json -func ExampleDedicatedCloudNodesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewDedicatedCloudNodesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "myResourceGroup", - "myNode", - armvmwarecloudsimple.PatchPayload{ - Tags: map[string]*string{ - "myTag": to.Ptr("tagValue"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_dedicatedcloudservices_client_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_dedicatedcloudservices_client_test.go deleted file mode 100644 index 6b8d9fee9cb9..000000000000 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_dedicatedcloudservices_client_test.go +++ /dev/null @@ -1,174 +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 armvmwarecloudsimple_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/vmwarecloudsimple/armvmwarecloudsimple" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListDedicatedCloudServices.json -func ExampleDedicatedCloudServicesClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewDedicatedCloudServicesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(&armvmwarecloudsimple.DedicatedCloudServicesClientListBySubscriptionOptions{Filter: nil, - Top: 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListRGDedicatedCloudServices.json -func ExampleDedicatedCloudServicesClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewDedicatedCloudServicesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("myResourceGroup", - &armvmwarecloudsimple.DedicatedCloudServicesClientListByResourceGroupOptions{Filter: nil, - Top: 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/GetDedicatedCloudService.json -func ExampleDedicatedCloudServicesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewDedicatedCloudServicesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "myResourceGroup", - "myService", - 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/CreateDedicatedCloudService.json -func ExampleDedicatedCloudServicesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewDedicatedCloudServicesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "myResourceGroup", - "myService", - armvmwarecloudsimple.DedicatedCloudService{ - Location: to.Ptr("westus"), - Properties: &armvmwarecloudsimple.DedicatedCloudServiceProperties{ - GatewaySubnet: to.Ptr("10.0.0.0"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/DeleteDedicatedCloudService.json -func ExampleDedicatedCloudServicesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewDedicatedCloudServicesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "myResourceGroup", - "myService", - 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/PatchDedicatedService.json -func ExampleDedicatedCloudServicesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewDedicatedCloudServicesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "myResourceGroup", - "myService", - armvmwarecloudsimple.PatchPayload{ - Tags: map[string]*string{ - "myTag": to.Ptr("tagValue"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_operations_client_test.go deleted file mode 100644 index a94ebef64887..000000000000 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_operations_client_test.go +++ /dev/null @@ -1,64 +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 armvmwarecloudsimple_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/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 := armvmwarecloudsimple.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 - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/GetFailedOperationResult.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 := armvmwarecloudsimple.NewOperationsClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "westus2", - "https://management.azure.com/", - "d030bb3f-7d53-11e9-8e09-9a86872085ff", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_privateclouds_client_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_privateclouds_client_test.go deleted file mode 100644 index f6b689162a18..000000000000 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_privateclouds_client_test.go +++ /dev/null @@ -1,64 +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 armvmwarecloudsimple_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListPrivateCloudInLocation.json -func ExamplePrivateCloudsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewPrivateCloudsClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("eastus", - 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/GetPrivateCloud.json -func ExamplePrivateCloudsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewPrivateCloudsClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "myPrivateCloud", - "westus2", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_resourcepools_client_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_resourcepools_client_test.go deleted file mode 100644 index 8d2b86a80dc7..000000000000 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_resourcepools_client_test.go +++ /dev/null @@ -1,66 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armvmwarecloudsimple_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListResourcePools.json -func ExampleResourcePoolsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewResourcePoolsClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("westus2", - "myPrivateCloud", - 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/GetResourcePool.json -func ExampleResourcePoolsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewResourcePoolsClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "westus2", - "myPrivateCloud", - "resgroup-26", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_skusavailability_client_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_skusavailability_client_test.go deleted file mode 100644 index 40c336875b54..000000000000 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_skusavailability_client_test.go +++ /dev/null @@ -1,42 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armvmwarecloudsimple_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListAvailabilities.json -func ExampleSKUsAvailabilityClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewSKUsAvailabilityClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("westus2", - &armvmwarecloudsimple.SKUsAvailabilityClientListOptions{SKUID: 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/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_usages_client_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_usages_client_test.go deleted file mode 100644 index b834e61bab27..000000000000 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_usages_client_test.go +++ /dev/null @@ -1,42 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armvmwarecloudsimple_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListUsages.json -func ExampleUsagesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewUsagesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("westus2", - &armvmwarecloudsimple.UsagesClientListOptions{Filter: nil}) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_virtualmachines_client_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_virtualmachines_client_test.go deleted file mode 100644 index bcc0720052d6..000000000000 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_virtualmachines_client_test.go +++ /dev/null @@ -1,258 +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 armvmwarecloudsimple_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/vmwarecloudsimple/armvmwarecloudsimple" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListVirtualMachines.json -func ExampleVirtualMachinesClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewVirtualMachinesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(&armvmwarecloudsimple.VirtualMachinesClientListBySubscriptionOptions{Filter: nil, - Top: 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListRGVirtualMachines.json -func ExampleVirtualMachinesClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewVirtualMachinesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("myResourceGroup", - &armvmwarecloudsimple.VirtualMachinesClientListByResourceGroupOptions{Filter: nil, - Top: 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/GetVirtualMachine.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 := armvmwarecloudsimple.NewVirtualMachinesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "myResourceGroup", - "myVirtualMachine", - 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/CreateVirtualMachine.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 := armvmwarecloudsimple.NewVirtualMachinesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "myResourceGroup", - "https://management.azure.com/", - "myVirtualMachine", - armvmwarecloudsimple.VirtualMachine{ - Location: to.Ptr("westus2"), - Properties: &armvmwarecloudsimple.VirtualMachineProperties{ - AmountOfRAM: to.Ptr[int32](4096), - Disks: []*armvmwarecloudsimple.VirtualDisk{ - { - ControllerID: to.Ptr("1000"), - IndependenceMode: to.Ptr(armvmwarecloudsimple.DiskIndependenceModePersistent), - TotalSize: to.Ptr[int32](10485760), - VirtualDiskID: to.Ptr("2000"), - }}, - Nics: []*armvmwarecloudsimple.VirtualNic{ - { - Network: &armvmwarecloudsimple.VirtualNetwork{ - ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualNetworks/dvportgroup-19"), - }, - NicType: to.Ptr(armvmwarecloudsimple.NICTypeE1000), - PowerOnBoot: to.Ptr(true), - VirtualNicID: to.Ptr("4000"), - }}, - NumberOfCores: to.Ptr[int32](2), - PrivateCloudID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud"), - ResourcePool: &armvmwarecloudsimple.ResourcePool{ - ID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/resourcePools/resgroup-26"), - }, - TemplateID: to.Ptr("/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/virtualMachineTemplates/vm-34"), - }, - }, - 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/DeleteVirtualMachine.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 := armvmwarecloudsimple.NewVirtualMachinesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "myResourceGroup", - "https://management.azure.com/", - "myVirtualMachine", - 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/PatchVirtualMachine.json -func ExampleVirtualMachinesClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewVirtualMachinesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, - "myResourceGroup", - "myVirtualMachine", - armvmwarecloudsimple.PatchPayload{ - Tags: map[string]*string{ - "myTag": to.Ptr("tagValue"), - }, - }, - 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/StartVirtualMachine.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 := armvmwarecloudsimple.NewVirtualMachinesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginStart(ctx, - "myResourceGroup", - "https://management.azure.com/", - "myVirtualMachine", - 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/StopInBodyVirtualMachine.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 := armvmwarecloudsimple.NewVirtualMachinesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginStop(ctx, - "myResourceGroup", - "https://management.azure.com/", - "myVirtualMachine", - &armvmwarecloudsimple.VirtualMachinesClientBeginStopOptions{Mode: nil, - M: &armvmwarecloudsimple.VirtualMachineStopMode{}, - }) - 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/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_virtualmachinetemplates_client_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_virtualmachinetemplates_client_test.go deleted file mode 100644 index 735a28b0e648..000000000000 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_virtualmachinetemplates_client_test.go +++ /dev/null @@ -1,67 +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 armvmwarecloudsimple_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListVirtualMachineTemplates.json -func ExampleVirtualMachineTemplatesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewVirtualMachineTemplatesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("myPrivateCloud", - "westus2", - "/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/resourcePools/resgroup-26", - 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/GetVirtualMachineTemplate.json -func ExampleVirtualMachineTemplatesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armvmwarecloudsimple.NewVirtualMachineTemplatesClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "westus2", - "myPrivateCloud", - "vm-34", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_virtualnetworks_client_test.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_virtualnetworks_client_test.go deleted file mode 100644 index ac1800bd0876..000000000000 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/ze_generated_example_virtualnetworks_client_test.go +++ /dev/null @@ -1,67 +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 armvmwarecloudsimple_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/ListVirtualNetworks.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 := armvmwarecloudsimple.NewVirtualNetworksClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("westus2", - "myPrivateCloud", - "/subscriptions/{subscription-id}/providers/Microsoft.VMwareCloudSimple/locations/westus2/privateClouds/myPrivateCloud/resourcePools/resgroup-26", - 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/vmwarecloudsimple/resource-manager/Microsoft.VMwareCloudSimple/stable/2019-04-01/examples/GetVirtualNetwork.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 := armvmwarecloudsimple.NewVirtualNetworksClient("{subscription-id}", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "westus2", - "myPrivateCloud", - "dvportgroup-19", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_models_serde.go b/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_models_serde.go deleted file mode 100644 index c419c81e6434..000000000000 --- a/sdk/resourcemanager/vmwarecloudsimple/armvmwarecloudsimple/zz_generated_models_serde.go +++ /dev/null @@ -1,349 +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 armvmwarecloudsimple - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type DedicatedCloudNode. -func (d DedicatedCloudNode) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", d.ID) - populate(objectMap, "location", d.Location) - populate(objectMap, "name", d.Name) - populate(objectMap, "properties", d.Properties) - populate(objectMap, "sku", d.SKU) - populate(objectMap, "tags", d.Tags) - populate(objectMap, "type", d.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type DedicatedCloudNodeProperties. -func (d DedicatedCloudNodeProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "availabilityZoneId", d.AvailabilityZoneID) - populate(objectMap, "availabilityZoneName", d.AvailabilityZoneName) - populate(objectMap, "cloudRackName", d.CloudRackName) - populateTimeRFC3339(objectMap, "created", d.Created) - populate(objectMap, "nodesCount", d.NodesCount) - populate(objectMap, "placementGroupId", d.PlacementGroupID) - populate(objectMap, "placementGroupName", d.PlacementGroupName) - populate(objectMap, "privateCloudId", d.PrivateCloudID) - populate(objectMap, "privateCloudName", d.PrivateCloudName) - populate(objectMap, "provisioningState", d.ProvisioningState) - populate(objectMap, "purchaseId", d.PurchaseID) - populate(objectMap, "skuDescription", d.SKUDescription) - populate(objectMap, "status", d.Status) - populate(objectMap, "vmwareClusterName", d.VmwareClusterName) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DedicatedCloudNodeProperties. -func (d *DedicatedCloudNodeProperties) UnmarshalJSON(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 "availabilityZoneId": - err = unpopulate(val, "AvailabilityZoneID", &d.AvailabilityZoneID) - delete(rawMsg, key) - case "availabilityZoneName": - err = unpopulate(val, "AvailabilityZoneName", &d.AvailabilityZoneName) - delete(rawMsg, key) - case "cloudRackName": - err = unpopulate(val, "CloudRackName", &d.CloudRackName) - delete(rawMsg, key) - case "created": - err = unpopulateTimeRFC3339(val, "Created", &d.Created) - delete(rawMsg, key) - case "nodesCount": - err = unpopulate(val, "NodesCount", &d.NodesCount) - delete(rawMsg, key) - case "placementGroupId": - err = unpopulate(val, "PlacementGroupID", &d.PlacementGroupID) - delete(rawMsg, key) - case "placementGroupName": - err = unpopulate(val, "PlacementGroupName", &d.PlacementGroupName) - delete(rawMsg, key) - case "privateCloudId": - err = unpopulate(val, "PrivateCloudID", &d.PrivateCloudID) - delete(rawMsg, key) - case "privateCloudName": - err = unpopulate(val, "PrivateCloudName", &d.PrivateCloudName) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) - delete(rawMsg, key) - case "purchaseId": - err = unpopulate(val, "PurchaseID", &d.PurchaseID) - delete(rawMsg, key) - case "skuDescription": - err = unpopulate(val, "SKUDescription", &d.SKUDescription) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &d.Status) - delete(rawMsg, key) - case "vmwareClusterName": - err = unpopulate(val, "VmwareClusterName", &d.VmwareClusterName) - 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 DedicatedCloudService. -func (d DedicatedCloudService) 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 GuestOSCustomization. -func (g GuestOSCustomization) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "dnsServers", g.DNSServers) - populate(objectMap, "hostName", g.HostName) - populate(objectMap, "password", g.Password) - populate(objectMap, "policyId", g.PolicyID) - populate(objectMap, "username", g.Username) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type GuestOSNICCustomization. -func (g GuestOSNICCustomization) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "allocation", g.Allocation) - populate(objectMap, "dnsServers", g.DNSServers) - populate(objectMap, "gateway", g.Gateway) - populate(objectMap, "ipAddress", g.IPAddress) - populate(objectMap, "mask", g.Mask) - populate(objectMap, "primaryWinsServer", g.PrimaryWinsServer) - populate(objectMap, "secondaryWinsServer", g.SecondaryWinsServer) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationResource. -func (o *OperationResource) UnmarshalJSON(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 "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &o.EndTime) - delete(rawMsg, key) - case "error": - err = unpopulate(val, "Error", &o.Error) - delete(rawMsg, key) - case "id": - err = unpopulate(val, "ID", &o.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &o.Name) - delete(rawMsg, key) - case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &o.StartTime) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &o.Status) - 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 PatchPayload. -func (p PatchPayload) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", p.Tags) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type PrivateCloudProperties. -func (p *PrivateCloudProperties) UnmarshalJSON(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 "availabilityZoneId": - err = unpopulate(val, "AvailabilityZoneID", &p.AvailabilityZoneID) - delete(rawMsg, key) - case "availabilityZoneName": - err = unpopulate(val, "AvailabilityZoneName", &p.AvailabilityZoneName) - delete(rawMsg, key) - case "clustersNumber": - err = unpopulate(val, "ClustersNumber", &p.ClustersNumber) - delete(rawMsg, key) - case "createdBy": - err = unpopulate(val, "CreatedBy", &p.CreatedBy) - delete(rawMsg, key) - case "createdOn": - err = unpopulateTimeRFC3339(val, "CreatedOn", &p.CreatedOn) - delete(rawMsg, key) - case "dnsServers": - err = unpopulate(val, "DNSServers", &p.DNSServers) - delete(rawMsg, key) - case "expires": - err = unpopulate(val, "Expires", &p.Expires) - delete(rawMsg, key) - case "nsxType": - err = unpopulate(val, "NsxType", &p.NsxType) - delete(rawMsg, key) - case "placementGroupId": - err = unpopulate(val, "PlacementGroupID", &p.PlacementGroupID) - delete(rawMsg, key) - case "placementGroupName": - err = unpopulate(val, "PlacementGroupName", &p.PlacementGroupName) - delete(rawMsg, key) - case "privateCloudId": - err = unpopulate(val, "PrivateCloudID", &p.PrivateCloudID) - delete(rawMsg, key) - case "resourcePools": - err = unpopulate(val, "ResourcePools", &p.ResourcePools) - delete(rawMsg, key) - case "state": - err = unpopulate(val, "State", &p.State) - delete(rawMsg, key) - case "totalCpuCores": - err = unpopulate(val, "TotalCPUCores", &p.TotalCPUCores) - delete(rawMsg, key) - case "totalNodes": - err = unpopulate(val, "TotalNodes", &p.TotalNodes) - delete(rawMsg, key) - case "totalRam": - err = unpopulate(val, "TotalRAM", &p.TotalRAM) - delete(rawMsg, key) - case "totalStorage": - err = unpopulate(val, "TotalStorage", &p.TotalStorage) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &p.Type) - delete(rawMsg, key) - case "vSphereVersion": - err = unpopulate(val, "VSphereVersion", &p.VSphereVersion) - delete(rawMsg, key) - case "vcenterFqdn": - err = unpopulate(val, "VcenterFqdn", &p.VcenterFqdn) - delete(rawMsg, key) - case "vcenterRefid": - err = unpopulate(val, "VcenterRefid", &p.VcenterRefid) - delete(rawMsg, key) - case "virtualMachineTemplates": - err = unpopulate(val, "VirtualMachineTemplates", &p.VirtualMachineTemplates) - delete(rawMsg, key) - case "virtualNetworks": - err = unpopulate(val, "VirtualNetworks", &p.VirtualNetworks) - delete(rawMsg, key) - case "vrOpsEnabled": - err = unpopulate(val, "VrOpsEnabled", &p.VrOpsEnabled) - 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 VirtualMachine. -func (v VirtualMachine) 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 VirtualMachineProperties. -func (v VirtualMachineProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "amountOfRam", v.AmountOfRAM) - populate(objectMap, "controllers", v.Controllers) - populate(objectMap, "customization", v.Customization) - populate(objectMap, "disks", v.Disks) - populate(objectMap, "dnsname", v.Dnsname) - populate(objectMap, "exposeToGuestVM", v.ExposeToGuestVM) - populate(objectMap, "folder", v.Folder) - populate(objectMap, "guestOS", v.GuestOS) - populate(objectMap, "guestOSType", v.GuestOSType) - populate(objectMap, "nics", v.Nics) - populate(objectMap, "numberOfCores", v.NumberOfCores) - populate(objectMap, "password", v.Password) - populate(objectMap, "privateCloudId", v.PrivateCloudID) - populate(objectMap, "provisioningState", v.ProvisioningState) - populate(objectMap, "publicIP", v.PublicIP) - populate(objectMap, "resourcePool", v.ResourcePool) - populate(objectMap, "status", v.Status) - populate(objectMap, "templateId", v.TemplateID) - populate(objectMap, "username", v.Username) - populate(objectMap, "vmId", v.VMID) - populate(objectMap, "vSphereNetworks", v.VSphereNetworks) - populate(objectMap, "vmwaretools", v.Vmwaretools) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type VirtualNic. -func (v VirtualNic) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "customization", v.Customization) - populate(objectMap, "ipAddresses", v.IPAddresses) - populate(objectMap, "macAddress", v.MacAddress) - populate(objectMap, "network", v.Network) - populate(objectMap, "nicType", v.NicType) - populate(objectMap, "powerOnBoot", v.PowerOnBoot) - populate(objectMap, "virtualNicId", v.VirtualNicID) - populate(objectMap, "virtualNicName", v.VirtualNicName) - 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/windowsesu/armwindowsesu/CHANGELOG.md b/sdk/resourcemanager/windowsesu/armwindowsesu/CHANGELOG.md index 78d538a72f33..84f95db62f1f 100644 --- a/sdk/resourcemanager/windowsesu/armwindowsesu/CHANGELOG.md +++ b/sdk/resourcemanager/windowsesu/armwindowsesu/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 0.6.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 0.5.0 (2022-05-18) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/windowsesu/armwindowsesu` 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/windowsesu/armwindowsesu/README.md b/sdk/resourcemanager/windowsesu/armwindowsesu/README.md index d44acb24ef7b..48fb435c944c 100644 --- a/sdk/resourcemanager/windowsesu/armwindowsesu/README.md +++ b/sdk/resourcemanager/windowsesu/armwindowsesu/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 Windows ESU 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 Windows ESU 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 := armwindowsesu.NewMultipleActivationKeysClient(, cred, nil) +clientFactory, err := armwindowsesu.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 := armwindowsesu.NewMultipleActivationKeysClient(, cred, &options) +clientFactory, err := armwindowsesu.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.NewMultipleActivationKeysClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/windowsesu/armwindowsesu/autorest.md b/sdk/resourcemanager/windowsesu/armwindowsesu/autorest.md index 71d1c93437ce..5f3f63598961 100644 --- a/sdk/resourcemanager/windowsesu/armwindowsesu/autorest.md +++ b/sdk/resourcemanager/windowsesu/armwindowsesu/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/windowsesu/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/windowsesu/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/windowsesu/armwindowsesu/client_factory.go b/sdk/resourcemanager/windowsesu/armwindowsesu/client_factory.go new file mode 100644 index 000000000000..b3f777b36b0f --- /dev/null +++ b/sdk/resourcemanager/windowsesu/armwindowsesu/client_factory.go @@ -0,0 +1,49 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armwindowsesu + +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) NewMultipleActivationKeysClient() *MultipleActivationKeysClient { + subClient, _ := NewMultipleActivationKeysClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/windowsesu/armwindowsesu/zz_generated_constants.go b/sdk/resourcemanager/windowsesu/armwindowsesu/constants.go similarity index 97% rename from sdk/resourcemanager/windowsesu/armwindowsesu/zz_generated_constants.go rename to sdk/resourcemanager/windowsesu/armwindowsesu/constants.go index 81644ab11abe..71066a69b1ed 100644 --- a/sdk/resourcemanager/windowsesu/armwindowsesu/zz_generated_constants.go +++ b/sdk/resourcemanager/windowsesu/armwindowsesu/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 armwindowsesu const ( moduleName = "armwindowsesu" - moduleVersion = "v0.5.0" + moduleVersion = "v0.6.0" ) // OsType - Type of OS for which the key is requested. diff --git a/sdk/resourcemanager/windowsesu/armwindowsesu/go.mod b/sdk/resourcemanager/windowsesu/armwindowsesu/go.mod index 12bfdad58460..73e46db2fd71 100644 --- a/sdk/resourcemanager/windowsesu/armwindowsesu/go.mod +++ b/sdk/resourcemanager/windowsesu/armwindowsesu/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/windowsesu/armwindo 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/windowsesu/armwindowsesu/go.sum b/sdk/resourcemanager/windowsesu/armwindowsesu/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/windowsesu/armwindowsesu/go.sum +++ b/sdk/resourcemanager/windowsesu/armwindowsesu/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/windowsesu/armwindowsesu/zz_generated_models.go b/sdk/resourcemanager/windowsesu/armwindowsesu/models.go similarity index 97% rename from sdk/resourcemanager/windowsesu/armwindowsesu/zz_generated_models.go rename to sdk/resourcemanager/windowsesu/armwindowsesu/models.go index 80e5635f23e9..f8a36bf0c15c 100644 --- a/sdk/resourcemanager/windowsesu/armwindowsesu/zz_generated_models.go +++ b/sdk/resourcemanager/windowsesu/armwindowsesu/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 armwindowsesu @@ -110,13 +111,14 @@ type MultipleActivationKeysClientGetOptions struct { // placeholder for future optional parameters } -// MultipleActivationKeysClientListByResourceGroupOptions contains the optional parameters for the MultipleActivationKeysClient.ListByResourceGroup +// MultipleActivationKeysClientListByResourceGroupOptions contains the optional parameters for the MultipleActivationKeysClient.NewListByResourceGroupPager // method. type MultipleActivationKeysClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// MultipleActivationKeysClientListOptions contains the optional parameters for the MultipleActivationKeysClient.List method. +// MultipleActivationKeysClientListOptions contains the optional parameters for the MultipleActivationKeysClient.NewListPager +// method. type MultipleActivationKeysClientListOptions struct { // placeholder for future optional parameters } @@ -153,7 +155,7 @@ type OperationList struct { NextLink *string `json:"nextLink,omitempty" azure:"ro"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/windowsesu/armwindowsesu/models_serde.go b/sdk/resourcemanager/windowsesu/armwindowsesu/models_serde.go new file mode 100644 index 000000000000..5b314c504fee --- /dev/null +++ b/sdk/resourcemanager/windowsesu/armwindowsesu/models_serde.go @@ -0,0 +1,438 @@ +//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 armwindowsesu + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type ErrorDefinition. +func (e ErrorDefinition) 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 ErrorDefinition. +func (e *ErrorDefinition) UnmarshalJSON(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 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 MultipleActivationKey. +func (m MultipleActivationKey) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", m.ID) + populate(objectMap, "location", m.Location) + populate(objectMap, "name", m.Name) + populate(objectMap, "properties", m.Properties) + populate(objectMap, "tags", m.Tags) + populate(objectMap, "type", m.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MultipleActivationKey. +func (m *MultipleActivationKey) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &m.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &m.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &m.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &m.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &m.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MultipleActivationKeyList. +func (m MultipleActivationKeyList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", m.NextLink) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MultipleActivationKeyList. +func (m *MultipleActivationKeyList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &m.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &m.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MultipleActivationKeyProperties. +func (m MultipleActivationKeyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "agreementNumber", m.AgreementNumber) + populateTimeRFC3339(objectMap, "expirationDate", m.ExpirationDate) + populate(objectMap, "installedServerNumber", m.InstalledServerNumber) + populate(objectMap, "isEligible", m.IsEligible) + populate(objectMap, "multipleActivationKey", m.MultipleActivationKey) + populate(objectMap, "osType", m.OSType) + populate(objectMap, "provisioningState", m.ProvisioningState) + populate(objectMap, "supportType", m.SupportType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MultipleActivationKeyProperties. +func (m *MultipleActivationKeyProperties) UnmarshalJSON(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 "agreementNumber": + err = unpopulate(val, "AgreementNumber", &m.AgreementNumber) + delete(rawMsg, key) + case "expirationDate": + err = unpopulateTimeRFC3339(val, "ExpirationDate", &m.ExpirationDate) + delete(rawMsg, key) + case "installedServerNumber": + err = unpopulate(val, "InstalledServerNumber", &m.InstalledServerNumber) + delete(rawMsg, key) + case "isEligible": + err = unpopulate(val, "IsEligible", &m.IsEligible) + delete(rawMsg, key) + case "multipleActivationKey": + err = unpopulate(val, "MultipleActivationKey", &m.MultipleActivationKey) + delete(rawMsg, key) + case "osType": + err = unpopulate(val, "OSType", &m.OSType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &m.ProvisioningState) + delete(rawMsg, key) + case "supportType": + err = unpopulate(val, "SupportType", &m.SupportType) + 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 MultipleActivationKeyUpdate. +func (m MultipleActivationKeyUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", m.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MultipleActivationKeyUpdate. +func (m *MultipleActivationKeyUpdate) UnmarshalJSON(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 "tags": + err = unpopulate(val, "Tags", &m.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", o.Display) + populate(objectMap, "name", o.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "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 OperationList. +func (o OperationList) 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 OperationList. +func (o *OperationList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResource. +func (t *TrackedResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/windowsesu/armwindowsesu/zz_generated_multipleactivationkeys_client.go b/sdk/resourcemanager/windowsesu/armwindowsesu/multipleactivationkeys_client.go similarity index 85% rename from sdk/resourcemanager/windowsesu/armwindowsesu/zz_generated_multipleactivationkeys_client.go rename to sdk/resourcemanager/windowsesu/armwindowsesu/multipleactivationkeys_client.go index 0bb514ed0443..819a685031dd 100644 --- a/sdk/resourcemanager/windowsesu/armwindowsesu/zz_generated_multipleactivationkeys_client.go +++ b/sdk/resourcemanager/windowsesu/armwindowsesu/multipleactivationkeys_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 armwindowsesu @@ -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 ( // MultipleActivationKeysClient contains the methods for the MultipleActivationKeys group. // Don't use this type directly, use NewMultipleActivationKeysClient() instead. type MultipleActivationKeysClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewMultipleActivationKeysClient creates a new instance of MultipleActivationKeysClient 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 NewMultipleActivationKeysClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MultipleActivationKeysClient, 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+".MultipleActivationKeysClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &MultipleActivationKeysClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create a MAK key. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-09-16-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// multipleActivationKeyName - The name of the MAK key. -// multipleActivationKey - Details of the MAK key. -// options - MultipleActivationKeysClientBeginCreateOptions contains the optional parameters for the MultipleActivationKeysClient.BeginCreate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - multipleActivationKeyName - The name of the MAK key. +// - multipleActivationKey - Details of the MAK key. +// - options - MultipleActivationKeysClientBeginCreateOptions contains the optional parameters for the MultipleActivationKeysClient.BeginCreate +// method. func (client *MultipleActivationKeysClient) BeginCreate(ctx context.Context, resourceGroupName string, multipleActivationKeyName string, multipleActivationKey MultipleActivationKey, options *MultipleActivationKeysClientBeginCreateOptions) (*runtime.Poller[MultipleActivationKeysClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, multipleActivationKeyName, multipleActivationKey, options) if err != nil { return nil, err } - return runtime.NewPoller[MultipleActivationKeysClientCreateResponse](resp, client.pl, nil) + return runtime.NewPoller[MultipleActivationKeysClientCreateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[MultipleActivationKeysClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[MultipleActivationKeysClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create a MAK key. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-09-16-preview func (client *MultipleActivationKeysClient) create(ctx context.Context, resourceGroupName string, multipleActivationKeyName string, multipleActivationKey MultipleActivationKey, options *MultipleActivationKeysClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, multipleActivationKeyName, multipleActivationKey, 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 *MultipleActivationKeysClient) createCreateRequest(ctx context.Cont return nil, errors.New("parameter multipleActivationKeyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{multipleActivationKeyName}", url.PathEscape(multipleActivationKeyName)) - 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 +112,18 @@ func (client *MultipleActivationKeysClient) createCreateRequest(ctx context.Cont // Delete - Delete a MAK key. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-09-16-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// multipleActivationKeyName - The name of the MAK key. -// options - MultipleActivationKeysClientDeleteOptions contains the optional parameters for the MultipleActivationKeysClient.Delete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - multipleActivationKeyName - The name of the MAK key. +// - options - MultipleActivationKeysClientDeleteOptions contains the optional parameters for the MultipleActivationKeysClient.Delete +// method. func (client *MultipleActivationKeysClient) Delete(ctx context.Context, resourceGroupName string, multipleActivationKeyName string, options *MultipleActivationKeysClientDeleteOptions) (MultipleActivationKeysClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, multipleActivationKeyName, options) if err != nil { return MultipleActivationKeysClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MultipleActivationKeysClientDeleteResponse{}, err } @@ -155,7 +148,7 @@ func (client *MultipleActivationKeysClient) deleteCreateRequest(ctx context.Cont return nil, errors.New("parameter multipleActivationKeyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{multipleActivationKeyName}", url.PathEscape(multipleActivationKeyName)) - 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 } @@ -168,17 +161,18 @@ func (client *MultipleActivationKeysClient) deleteCreateRequest(ctx context.Cont // Get - Get a MAK key. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-09-16-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// multipleActivationKeyName - The name of the MAK key. -// options - MultipleActivationKeysClientGetOptions contains the optional parameters for the MultipleActivationKeysClient.Get -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - multipleActivationKeyName - The name of the MAK key. +// - options - MultipleActivationKeysClientGetOptions contains the optional parameters for the MultipleActivationKeysClient.Get +// method. func (client *MultipleActivationKeysClient) Get(ctx context.Context, resourceGroupName string, multipleActivationKeyName string, options *MultipleActivationKeysClientGetOptions) (MultipleActivationKeysClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, multipleActivationKeyName, options) if err != nil { return MultipleActivationKeysClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MultipleActivationKeysClientGetResponse{}, err } @@ -203,7 +197,7 @@ func (client *MultipleActivationKeysClient) getCreateRequest(ctx context.Context return nil, errors.New("parameter multipleActivationKeyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{multipleActivationKeyName}", url.PathEscape(multipleActivationKeyName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, 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,10 +218,10 @@ func (client *MultipleActivationKeysClient) getHandleResponse(resp *http.Respons } // NewListPager - List all Multiple Activation Keys (MAK) created for a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-09-16-preview -// options - MultipleActivationKeysClientListOptions contains the optional parameters for the MultipleActivationKeysClient.List -// method. +// - options - MultipleActivationKeysClientListOptions contains the optional parameters for the MultipleActivationKeysClient.NewListPager +// method. func (client *MultipleActivationKeysClient) NewListPager(options *MultipleActivationKeysClientListOptions) *runtime.Pager[MultipleActivationKeysClientListResponse] { return runtime.NewPager(runtime.PagingHandler[MultipleActivationKeysClientListResponse]{ More: func(page MultipleActivationKeysClientListResponse) bool { @@ -244,7 +238,7 @@ func (client *MultipleActivationKeysClient) NewListPager(options *MultipleActiva if err != nil { return MultipleActivationKeysClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MultipleActivationKeysClientListResponse{}, err } @@ -263,7 +257,7 @@ func (client *MultipleActivationKeysClient) listCreateRequest(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 } @@ -284,11 +278,11 @@ func (client *MultipleActivationKeysClient) listHandleResponse(resp *http.Respon } // NewListByResourceGroupPager - List all Multiple Activation Keys (MAK) in a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-09-16-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - MultipleActivationKeysClientListByResourceGroupOptions contains the optional parameters for the MultipleActivationKeysClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - MultipleActivationKeysClientListByResourceGroupOptions contains the optional parameters for the MultipleActivationKeysClient.NewListByResourceGroupPager +// method. func (client *MultipleActivationKeysClient) NewListByResourceGroupPager(resourceGroupName string, options *MultipleActivationKeysClientListByResourceGroupOptions) *runtime.Pager[MultipleActivationKeysClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[MultipleActivationKeysClientListByResourceGroupResponse]{ More: func(page MultipleActivationKeysClientListByResourceGroupResponse) bool { @@ -305,7 +299,7 @@ func (client *MultipleActivationKeysClient) NewListByResourceGroupPager(resource if err != nil { return MultipleActivationKeysClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MultipleActivationKeysClientListByResourceGroupResponse{}, err } @@ -328,7 +322,7 @@ func (client *MultipleActivationKeysClient) 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 } @@ -350,18 +344,19 @@ func (client *MultipleActivationKeysClient) listByResourceGroupHandleResponse(re // Update - Update a MAK key. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-09-16-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// multipleActivationKeyName - The name of the MAK key. -// multipleActivationKey - Details of the MAK key. -// options - MultipleActivationKeysClientUpdateOptions contains the optional parameters for the MultipleActivationKeysClient.Update -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - multipleActivationKeyName - The name of the MAK key. +// - multipleActivationKey - Details of the MAK key. +// - options - MultipleActivationKeysClientUpdateOptions contains the optional parameters for the MultipleActivationKeysClient.Update +// method. func (client *MultipleActivationKeysClient) Update(ctx context.Context, resourceGroupName string, multipleActivationKeyName string, multipleActivationKey MultipleActivationKeyUpdate, options *MultipleActivationKeysClientUpdateOptions) (MultipleActivationKeysClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, multipleActivationKeyName, multipleActivationKey, options) if err != nil { return MultipleActivationKeysClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MultipleActivationKeysClientUpdateResponse{}, err } @@ -386,7 +381,7 @@ func (client *MultipleActivationKeysClient) updateCreateRequest(ctx context.Cont return nil, errors.New("parameter multipleActivationKeyName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{multipleActivationKeyName}", url.PathEscape(multipleActivationKeyName)) - 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/windowsesu/armwindowsesu/multipleactivationkeys_client_example_test.go b/sdk/resourcemanager/windowsesu/armwindowsesu/multipleactivationkeys_client_example_test.go new file mode 100644 index 000000000000..e3cf16e79282 --- /dev/null +++ b/sdk/resourcemanager/windowsesu/armwindowsesu/multipleactivationkeys_client_example_test.go @@ -0,0 +1,286 @@ +//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 armwindowsesu_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/windowsesu/armwindowsesu" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/ListMultipleActivationKeys.json +func ExampleMultipleActivationKeysClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armwindowsesu.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewMultipleActivationKeysClient().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.MultipleActivationKeyList = armwindowsesu.MultipleActivationKeyList{ + // Value: []*armwindowsesu.MultipleActivationKey{ + // { + // Name: to.Ptr("server08-key-2019"), + // Type: to.Ptr("Microsoft.WindowsESU/multipleActivationKeys"), + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg1/providers/Microsoft.WindowsESU/multipleActivationKeys/server08-key-2019"), + // Location: to.Ptr("East US"), + // Properties: &armwindowsesu.MultipleActivationKeyProperties{ + // AgreementNumber: to.Ptr("1a2b45ag"), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-21T21:12:26+00:00"); return t}()), + // InstalledServerNumber: to.Ptr[int32](100), + // IsEligible: to.Ptr(true), + // MultipleActivationKey: to.Ptr("aaaaa-bbbbb-ccccc-ddddd-eeeee"), + // OSType: to.Ptr(armwindowsesu.OsTypeWindowsServer2008), + // ProvisioningState: to.Ptr(armwindowsesu.ProvisioningStateSucceeded), + // SupportType: to.Ptr(armwindowsesu.SupportTypeSupplementalServicing), + // }, + // }, + // { + // Name: to.Ptr("server08r2-key-2019"), + // Type: to.Ptr("Microsoft.WindowsESU/multipleActivationKeys"), + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg1/providers/Microsoft.WindowsESU/multipleActivationKeys/server08r2-key-2019"), + // Location: to.Ptr("East US"), + // Properties: &armwindowsesu.MultipleActivationKeyProperties{ + // AgreementNumber: to.Ptr("1a2b45ag"), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-01T10:33:09+00:00"); return t}()), + // InstalledServerNumber: to.Ptr[int32](100), + // IsEligible: to.Ptr(true), + // MultipleActivationKey: to.Ptr("aaaaa-bbbbb-ccccc-ddddd-eeeee"), + // OSType: to.Ptr(armwindowsesu.OsTypeWindowsServer2008R2), + // ProvisioningState: to.Ptr(armwindowsesu.ProvisioningStateSucceeded), + // SupportType: to.Ptr(armwindowsesu.SupportTypeSupplementalServicing), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/ListMultipleActivationKeysByResourceGroup.json +func ExampleMultipleActivationKeysClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armwindowsesu.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewMultipleActivationKeysClient().NewListByResourceGroupPager("testrg1", 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.MultipleActivationKeyList = armwindowsesu.MultipleActivationKeyList{ + // Value: []*armwindowsesu.MultipleActivationKey{ + // { + // Name: to.Ptr("server08-key-2019"), + // Type: to.Ptr("Microsoft.WindowsESU/multipleActivationKeys"), + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg1/providers/Microsoft.WindowsESU/multipleActivationKeys/server08-key-2019"), + // Location: to.Ptr("East US"), + // Properties: &armwindowsesu.MultipleActivationKeyProperties{ + // AgreementNumber: to.Ptr("1a2b45ag"), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-21T21:12:26+00:00"); return t}()), + // InstalledServerNumber: to.Ptr[int32](100), + // IsEligible: to.Ptr(true), + // MultipleActivationKey: to.Ptr("aaaaa-bbbbb-ccccc-ddddd-eeeee"), + // OSType: to.Ptr(armwindowsesu.OsTypeWindowsServer2008), + // ProvisioningState: to.Ptr(armwindowsesu.ProvisioningStateSucceeded), + // SupportType: to.Ptr(armwindowsesu.SupportTypeSupplementalServicing), + // }, + // }, + // { + // Name: to.Ptr("server08r2-key-2019"), + // Type: to.Ptr("Microsoft.WindowsESU/multipleActivationKeys"), + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg1/providers/Microsoft.WindowsESU/multipleActivationKeys/server08r2-key-2019"), + // Location: to.Ptr("East US"), + // Properties: &armwindowsesu.MultipleActivationKeyProperties{ + // AgreementNumber: to.Ptr("1a2b45ag"), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-01T10:33:09+00:00"); return t}()), + // InstalledServerNumber: to.Ptr[int32](100), + // IsEligible: to.Ptr(true), + // MultipleActivationKey: to.Ptr("aaaaa-bbbbb-ccccc-ddddd-eeeee"), + // OSType: to.Ptr(armwindowsesu.OsTypeWindowsServer2008R2), + // ProvisioningState: to.Ptr(armwindowsesu.ProvisioningStateSucceeded), + // SupportType: to.Ptr(armwindowsesu.SupportTypeSupplementalServicing), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/GetMultipleActivationKey.json +func ExampleMultipleActivationKeysClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armwindowsesu.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMultipleActivationKeysClient().Get(ctx, "testgr1", "server08-key-2019", 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.MultipleActivationKey = armwindowsesu.MultipleActivationKey{ + // Name: to.Ptr("server08-key-2019"), + // Type: to.Ptr("Microsoft.WindowsESU/multipleActivationKeys"), + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testgr1/providers/Microsoft.WindowsESU/multipleActivationKeys/server08-key-2019"), + // Location: to.Ptr("East US"), + // Properties: &armwindowsesu.MultipleActivationKeyProperties{ + // AgreementNumber: to.Ptr("1a2b45ag"), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-21T21:12:26+00:00"); return t}()), + // InstalledServerNumber: to.Ptr[int32](100), + // IsEligible: to.Ptr(true), + // MultipleActivationKey: to.Ptr("aaaaa-bbbbb-ccccc-ddddd-eeeee"), + // OSType: to.Ptr(armwindowsesu.OsTypeWindowsServer2008), + // ProvisioningState: to.Ptr(armwindowsesu.ProvisioningStateSucceeded), + // SupportType: to.Ptr(armwindowsesu.SupportTypeSupplementalServicing), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/CreateMultipleActivationKey.json +func ExampleMultipleActivationKeysClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armwindowsesu.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewMultipleActivationKeysClient().BeginCreate(ctx, "testgr1", "server08-key-2019", armwindowsesu.MultipleActivationKey{ + Location: to.Ptr("East US"), + Properties: &armwindowsesu.MultipleActivationKeyProperties{ + AgreementNumber: to.Ptr("1a2b45ag"), + InstalledServerNumber: to.Ptr[int32](100), + IsEligible: to.Ptr(true), + OSType: to.Ptr(armwindowsesu.OsTypeWindowsServer2008), + SupportType: to.Ptr(armwindowsesu.SupportTypeSupplementalServicing), + }, + }, 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.MultipleActivationKey = armwindowsesu.MultipleActivationKey{ + // Name: to.Ptr("server08-key-2019"), + // Type: to.Ptr("Microsoft.WindowsESU/multipleActivationKeys"), + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testgr1/providers/Microsoft.WindowsESU/multipleActivationKeys/server08-key-2019"), + // Location: to.Ptr("East US"), + // Properties: &armwindowsesu.MultipleActivationKeyProperties{ + // AgreementNumber: to.Ptr("1a2b45ag"), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-21T21:12:26+00:00"); return t}()), + // InstalledServerNumber: to.Ptr[int32](100), + // IsEligible: to.Ptr(true), + // MultipleActivationKey: to.Ptr("aaaaa-bbbbb-ccccc-ddddd-eeeee"), + // OSType: to.Ptr(armwindowsesu.OsTypeWindowsServer2008), + // ProvisioningState: to.Ptr(armwindowsesu.ProvisioningStateSucceeded), + // SupportType: to.Ptr(armwindowsesu.SupportTypeSupplementalServicing), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/UpdateMultipleActivationKey.json +func ExampleMultipleActivationKeysClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armwindowsesu.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewMultipleActivationKeysClient().Update(ctx, "testgr1", "server08-key-2019", armwindowsesu.MultipleActivationKeyUpdate{ + Tags: map[string]*string{ + "tag1": to.Ptr("value1"), + "tag2": to.Ptr("value2"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.MultipleActivationKey = armwindowsesu.MultipleActivationKey{ + // Name: to.Ptr("server08-key-2019"), + // Type: to.Ptr("Microsoft.WindowsESU/multipleActivationKeys"), + // ID: to.Ptr("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testgr1/providers/Microsoft.WindowsESU/multipleActivationKeys/server08-key-2019"), + // Location: to.Ptr("East US"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armwindowsesu.MultipleActivationKeyProperties{ + // AgreementNumber: to.Ptr("1a2b45ag"), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-21T21:12:26+00:00"); return t}()), + // InstalledServerNumber: to.Ptr[int32](100), + // IsEligible: to.Ptr(true), + // MultipleActivationKey: to.Ptr("aaaaa-bbbbb-ccccc-ddddd-eeeee"), + // OSType: to.Ptr(armwindowsesu.OsTypeWindowsServer2008), + // ProvisioningState: to.Ptr(armwindowsesu.ProvisioningStateSucceeded), + // SupportType: to.Ptr(armwindowsesu.SupportTypeSupplementalServicing), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/DeleteMultipleActivationKey.json +func ExampleMultipleActivationKeysClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armwindowsesu.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewMultipleActivationKeysClient().Delete(ctx, "testgr1", "server08-key-2019", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} diff --git a/sdk/resourcemanager/windowsesu/armwindowsesu/zz_generated_operations_client.go b/sdk/resourcemanager/windowsesu/armwindowsesu/operations_client.go similarity index 77% rename from sdk/resourcemanager/windowsesu/armwindowsesu/zz_generated_operations_client.go rename to sdk/resourcemanager/windowsesu/armwindowsesu/operations_client.go index 682c11c0b882..ae135dde5f36 100644 --- a/sdk/resourcemanager/windowsesu/armwindowsesu/zz_generated_operations_client.go +++ b/sdk/resourcemanager/windowsesu/armwindowsesu/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 armwindowsesu @@ -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 - List all available Windows.ESU provider operations. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-09-16-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.WindowsESU/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/windowsesu/armwindowsesu/operations_client_example_test.go b/sdk/resourcemanager/windowsesu/armwindowsesu/operations_client_example_test.go new file mode 100644 index 000000000000..82f014d2ab62 --- /dev/null +++ b/sdk/resourcemanager/windowsesu/armwindowsesu/operations_client_example_test.go @@ -0,0 +1,55 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armwindowsesu_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/windowsesu/armwindowsesu" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-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 := armwindowsesu.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.OperationList = armwindowsesu.OperationList{ + // Value: []*armwindowsesu.Operation{ + // { + // Name: to.Ptr("Microsoft.WindowsESU/multipleActivationKeys/Read"), + // Display: &armwindowsesu.OperationDisplay{ + // Description: to.Ptr("List MAK keys."), + // Operation: to.Ptr("List MAK keys"), + // Provider: to.Ptr("Microsoft Windows Extended Security Updates"), + // Resource: to.Ptr("multipleActivationKey"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/windowsesu/armwindowsesu/zz_generated_response_types.go b/sdk/resourcemanager/windowsesu/armwindowsesu/response_types.go similarity index 86% rename from sdk/resourcemanager/windowsesu/armwindowsesu/zz_generated_response_types.go rename to sdk/resourcemanager/windowsesu/armwindowsesu/response_types.go index 64e1d94cc384..3c52ba778d65 100644 --- a/sdk/resourcemanager/windowsesu/armwindowsesu/zz_generated_response_types.go +++ b/sdk/resourcemanager/windowsesu/armwindowsesu/response_types.go @@ -5,10 +5,11 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armwindowsesu -// MultipleActivationKeysClientCreateResponse contains the response from method MultipleActivationKeysClient.Create. +// MultipleActivationKeysClientCreateResponse contains the response from method MultipleActivationKeysClient.BeginCreate. type MultipleActivationKeysClientCreateResponse struct { MultipleActivationKey } @@ -23,12 +24,12 @@ type MultipleActivationKeysClientGetResponse struct { MultipleActivationKey } -// MultipleActivationKeysClientListByResourceGroupResponse contains the response from method MultipleActivationKeysClient.ListByResourceGroup. +// MultipleActivationKeysClientListByResourceGroupResponse contains the response from method MultipleActivationKeysClient.NewListByResourceGroupPager. type MultipleActivationKeysClientListByResourceGroupResponse struct { MultipleActivationKeyList } -// MultipleActivationKeysClientListResponse contains the response from method MultipleActivationKeysClient.List. +// MultipleActivationKeysClientListResponse contains the response from method MultipleActivationKeysClient.NewListPager. type MultipleActivationKeysClientListResponse struct { MultipleActivationKeyList } @@ -38,7 +39,7 @@ type MultipleActivationKeysClientUpdateResponse struct { MultipleActivationKey } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationList } diff --git a/sdk/resourcemanager/windowsesu/armwindowsesu/zz_generated_time_rfc3339.go b/sdk/resourcemanager/windowsesu/armwindowsesu/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/windowsesu/armwindowsesu/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/windowsesu/armwindowsesu/time_rfc3339.go index 899a00afb81e..7c3f4de88701 100644 --- a/sdk/resourcemanager/windowsesu/armwindowsesu/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/windowsesu/armwindowsesu/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 armwindowsesu @@ -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/windowsesu/armwindowsesu/ze_generated_example_multipleactivationkeys_client_test.go b/sdk/resourcemanager/windowsesu/armwindowsesu/ze_generated_example_multipleactivationkeys_client_test.go deleted file mode 100644 index 6eba645979c3..000000000000 --- a/sdk/resourcemanager/windowsesu/armwindowsesu/ze_generated_example_multipleactivationkeys_client_test.go +++ /dev/null @@ -1,173 +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 armwindowsesu_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/windowsesu/armwindowsesu" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/ListMultipleActivationKeys.json -func ExampleMultipleActivationKeysClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armwindowsesu.NewMultipleActivationKeysClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", 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/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/ListMultipleActivationKeysByResourceGroup.json -func ExampleMultipleActivationKeysClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armwindowsesu.NewMultipleActivationKeysClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("testrg1", - 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/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/GetMultipleActivationKey.json -func ExampleMultipleActivationKeysClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armwindowsesu.NewMultipleActivationKeysClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "testgr1", - "server08-key-2019", - 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/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/CreateMultipleActivationKey.json -func ExampleMultipleActivationKeysClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armwindowsesu.NewMultipleActivationKeysClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, - "testgr1", - "server08-key-2019", - armwindowsesu.MultipleActivationKey{ - Location: to.Ptr("East US"), - Properties: &armwindowsesu.MultipleActivationKeyProperties{ - AgreementNumber: to.Ptr("1a2b45ag"), - InstalledServerNumber: to.Ptr[int32](100), - IsEligible: to.Ptr(true), - OSType: to.Ptr(armwindowsesu.OsTypeWindowsServer2008), - SupportType: to.Ptr(armwindowsesu.SupportTypeSupplementalServicing), - }, - }, - 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/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/UpdateMultipleActivationKey.json -func ExampleMultipleActivationKeysClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armwindowsesu.NewMultipleActivationKeysClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "testgr1", - "server08-key-2019", - armwindowsesu.MultipleActivationKeyUpdate{ - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-preview/examples/DeleteMultipleActivationKey.json -func ExampleMultipleActivationKeysClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armwindowsesu.NewMultipleActivationKeysClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "testgr1", - "server08-key-2019", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/windowsesu/armwindowsesu/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/windowsesu/armwindowsesu/ze_generated_example_operations_client_test.go deleted file mode 100644 index e7ed2f098aea..000000000000 --- a/sdk/resourcemanager/windowsesu/armwindowsesu/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 armwindowsesu_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/windowsesu/armwindowsesu" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/windowsesu/resource-manager/Microsoft.WindowsESU/preview/2019-09-16-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 := armwindowsesu.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/windowsesu/armwindowsesu/zz_generated_models_serde.go b/sdk/resourcemanager/windowsesu/armwindowsesu/zz_generated_models_serde.go deleted file mode 100644 index f9fa755aee40..000000000000 --- a/sdk/resourcemanager/windowsesu/armwindowsesu/zz_generated_models_serde.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 armwindowsesu - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type MultipleActivationKey. -func (m MultipleActivationKey) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", m.ID) - populate(objectMap, "location", m.Location) - populate(objectMap, "name", m.Name) - populate(objectMap, "properties", m.Properties) - populate(objectMap, "tags", m.Tags) - populate(objectMap, "type", m.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type MultipleActivationKeyProperties. -func (m MultipleActivationKeyProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "agreementNumber", m.AgreementNumber) - populateTimeRFC3339(objectMap, "expirationDate", m.ExpirationDate) - populate(objectMap, "installedServerNumber", m.InstalledServerNumber) - populate(objectMap, "isEligible", m.IsEligible) - populate(objectMap, "multipleActivationKey", m.MultipleActivationKey) - populate(objectMap, "osType", m.OSType) - populate(objectMap, "provisioningState", m.ProvisioningState) - populate(objectMap, "supportType", m.SupportType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type MultipleActivationKeyProperties. -func (m *MultipleActivationKeyProperties) UnmarshalJSON(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 "agreementNumber": - err = unpopulate(val, "AgreementNumber", &m.AgreementNumber) - delete(rawMsg, key) - case "expirationDate": - err = unpopulateTimeRFC3339(val, "ExpirationDate", &m.ExpirationDate) - delete(rawMsg, key) - case "installedServerNumber": - err = unpopulate(val, "InstalledServerNumber", &m.InstalledServerNumber) - delete(rawMsg, key) - case "isEligible": - err = unpopulate(val, "IsEligible", &m.IsEligible) - delete(rawMsg, key) - case "multipleActivationKey": - err = unpopulate(val, "MultipleActivationKey", &m.MultipleActivationKey) - delete(rawMsg, key) - case "osType": - err = unpopulate(val, "OSType", &m.OSType) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &m.ProvisioningState) - delete(rawMsg, key) - case "supportType": - err = unpopulate(val, "SupportType", &m.SupportType) - 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 MultipleActivationKeyUpdate. -func (m MultipleActivationKeyUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", m.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type TrackedResource. -func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) - populate(objectMap, "name", t.Name) - populate(objectMap, "tags", t.Tags) - populate(objectMap, "type", t.Type) - return json.Marshal(objectMap) -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} - -func unpopulate(data json.RawMessage, fn string, v interface{}) error { - if data == nil { - return nil - } - if err := json.Unmarshal(data, v); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - return nil -} diff --git a/sdk/resourcemanager/windowsiot/armwindowsiot/CHANGELOG.md b/sdk/resourcemanager/windowsiot/armwindowsiot/CHANGELOG.md index 1d42b3311d85..f4c452f882d9 100644 --- a/sdk/resourcemanager/windowsiot/armwindowsiot/CHANGELOG.md +++ b/sdk/resourcemanager/windowsiot/armwindowsiot/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-31) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2022-05-18) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/windowsiot/armwindowsiot` 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/windowsiot/armwindowsiot/README.md b/sdk/resourcemanager/windowsiot/armwindowsiot/README.md index 76f93e78d942..888eec0128e4 100644 --- a/sdk/resourcemanager/windowsiot/armwindowsiot/README.md +++ b/sdk/resourcemanager/windowsiot/armwindowsiot/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 Windows IoT 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 Windows IoT 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 := armwindowsiot.NewServicesClient(, cred, nil) +clientFactory, err := armwindowsiot.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 := armwindowsiot.NewServicesClient(, cred, &options) +clientFactory, err := armwindowsiot.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.NewServicesClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/windowsiot/armwindowsiot/autorest.md b/sdk/resourcemanager/windowsiot/armwindowsiot/autorest.md index b11160bb5ac8..35f06ee72266 100644 --- a/sdk/resourcemanager/windowsiot/armwindowsiot/autorest.md +++ b/sdk/resourcemanager/windowsiot/armwindowsiot/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/windowsiot/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/windowsiot/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/windowsiot/armwindowsiot/client_factory.go b/sdk/resourcemanager/windowsiot/armwindowsiot/client_factory.go new file mode 100644 index 000000000000..f136c8ef2a65 --- /dev/null +++ b/sdk/resourcemanager/windowsiot/armwindowsiot/client_factory.go @@ -0,0 +1,49 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armwindowsiot + +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) NewServicesClient() *ServicesClient { + subClient, _ := NewServicesClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_constants.go b/sdk/resourcemanager/windowsiot/armwindowsiot/constants.go similarity index 96% rename from sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_constants.go rename to sdk/resourcemanager/windowsiot/armwindowsiot/constants.go index e5ac721da6da..b3334b26d01b 100644 --- a/sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_constants.go +++ b/sdk/resourcemanager/windowsiot/armwindowsiot/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 armwindowsiot const ( moduleName = "armwindowsiot" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // ServiceNameUnavailabilityReason - The reason for unavailability. diff --git a/sdk/resourcemanager/windowsiot/armwindowsiot/go.mod b/sdk/resourcemanager/windowsiot/armwindowsiot/go.mod index 15dd0c275bd4..a21364bf1206 100644 --- a/sdk/resourcemanager/windowsiot/armwindowsiot/go.mod +++ b/sdk/resourcemanager/windowsiot/armwindowsiot/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/windowsiot/armwindo 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/windowsiot/armwindowsiot/go.sum b/sdk/resourcemanager/windowsiot/armwindowsiot/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/windowsiot/armwindowsiot/go.sum +++ b/sdk/resourcemanager/windowsiot/armwindowsiot/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/windowsiot/armwindowsiot/zz_generated_models.go b/sdk/resourcemanager/windowsiot/armwindowsiot/models.go similarity index 97% rename from sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_models.go rename to sdk/resourcemanager/windowsiot/armwindowsiot/models.go index 31d6f36e16fb..9141af61851a 100644 --- a/sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_models.go +++ b/sdk/resourcemanager/windowsiot/armwindowsiot/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 armwindowsiot @@ -141,7 +142,7 @@ type OperationListResult struct { Value []*OperationEntity `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 } @@ -194,12 +195,13 @@ type ServicesClientGetOptions struct { // placeholder for future optional parameters } -// ServicesClientListByResourceGroupOptions contains the optional parameters for the ServicesClient.ListByResourceGroup method. +// ServicesClientListByResourceGroupOptions contains the optional parameters for the ServicesClient.NewListByResourceGroupPager +// method. type ServicesClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// ServicesClientListOptions contains the optional parameters for the ServicesClient.List method. +// ServicesClientListOptions contains the optional parameters for the ServicesClient.NewListPager method. type ServicesClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/windowsiot/armwindowsiot/models_serde.go b/sdk/resourcemanager/windowsiot/armwindowsiot/models_serde.go new file mode 100644 index 000000000000..33ae8e937071 --- /dev/null +++ b/sdk/resourcemanager/windowsiot/armwindowsiot/models_serde.go @@ -0,0 +1,512 @@ +//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 armwindowsiot + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type DeviceService. +func (d DeviceService) 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, "tags", d.Tags) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceService. +func (d *DeviceService) UnmarshalJSON(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 "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 DeviceServiceCheckNameAvailabilityParameters. +func (d DeviceServiceCheckNameAvailabilityParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", d.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceServiceCheckNameAvailabilityParameters. +func (d *DeviceServiceCheckNameAvailabilityParameters) UnmarshalJSON(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 "name": + err = unpopulate(val, "Name", &d.Name) + 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 DeviceServiceDescriptionListResult. +func (d DeviceServiceDescriptionListResult) 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 DeviceServiceDescriptionListResult. +func (d *DeviceServiceDescriptionListResult) UnmarshalJSON(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 DeviceServiceNameAvailabilityInfo. +func (d DeviceServiceNameAvailabilityInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", d.Message) + populate(objectMap, "nameAvailable", d.NameAvailable) + populate(objectMap, "reason", d.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceServiceNameAvailabilityInfo. +func (d *DeviceServiceNameAvailabilityInfo) UnmarshalJSON(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 "message": + err = unpopulate(val, "Message", &d.Message) + delete(rawMsg, key) + case "nameAvailable": + err = unpopulate(val, "NameAvailable", &d.NameAvailable) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &d.Reason) + 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 DeviceServiceProperties. +func (d DeviceServiceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "adminDomainName", d.AdminDomainName) + populate(objectMap, "billingDomainName", d.BillingDomainName) + populate(objectMap, "notes", d.Notes) + populate(objectMap, "quantity", d.Quantity) + populateTimeRFC3339(objectMap, "startDate", d.StartDate) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceServiceProperties. +func (d *DeviceServiceProperties) UnmarshalJSON(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 "adminDomainName": + err = unpopulate(val, "AdminDomainName", &d.AdminDomainName) + delete(rawMsg, key) + case "billingDomainName": + err = unpopulate(val, "BillingDomainName", &d.BillingDomainName) + delete(rawMsg, key) + case "notes": + err = unpopulate(val, "Notes", &d.Notes) + delete(rawMsg, key) + case "quantity": + err = unpopulate(val, "Quantity", &d.Quantity) + delete(rawMsg, key) + case "startDate": + err = unpopulateTimeRFC3339(val, "StartDate", &d.StartDate) + 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 ErrorDetails. +func (e ErrorDetails) 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 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 "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 ErrorDetailsError. +func (e ErrorDetailsError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 ErrorDetailsError. +func (e *ErrorDetailsError) UnmarshalJSON(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) + 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 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, "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 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 "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 OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProxyResource. +func (p ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyResource. +func (p *ProxyResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResource. +func (t *TrackedResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_operations_client.go b/sdk/resourcemanager/windowsiot/armwindowsiot/operations_client.go similarity index 77% rename from sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_operations_client.go rename to sdk/resourcemanager/windowsiot/armwindowsiot/operations_client.go index 4615432bf3d4..4c7a65d37fa8 100644 --- a/sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_operations_client.go +++ b/sdk/resourcemanager/windowsiot/armwindowsiot/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 armwindowsiot @@ -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 Windows IoT Services REST API operations. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-06-01 -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { @@ -68,7 +58,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -83,7 +73,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.WindowsIoT/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/windowsiot/armwindowsiot/operations_client_example_test.go b/sdk/resourcemanager/windowsiot/armwindowsiot/operations_client_example_test.go new file mode 100644 index 000000000000..ec6c531fa426 --- /dev/null +++ b/sdk/resourcemanager/windowsiot/armwindowsiot/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 armwindowsiot_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/windowsiot/armwindowsiot" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/OperationsList.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armwindowsiot.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 = armwindowsiot.OperationListResult{ + // Value: []*armwindowsiot.OperationEntity{ + // { + // Name: to.Ptr("Microsoft.WindowsIoT/Services/write"), + // Display: &armwindowsiot.OperationDisplayInfo{ + // Description: to.Ptr("Creates a Windows IoT Subscription with the specified parameters or update the properties or tags or adds custom domain for the specified Windows IoT Subscription."), + // Operation: to.Ptr("Create/Update Windows IoT Subscription"), + // Provider: to.Ptr("Windows IoT"), + // Resource: to.Ptr("Windows IoT Services"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.WindowsIoT/Services/delete"), + // Display: &armwindowsiot.OperationDisplayInfo{ + // Description: to.Ptr("Deletes an existing Windows IoT Subscription."), + // Operation: to.Ptr("Delete Windows IoT Subscription"), + // Provider: to.Ptr("Windows IoT"), + // Resource: to.Ptr("Windows IoT Services"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.WindowsIoT/checkNameAvailability/read"), + // Display: &armwindowsiot.OperationDisplayInfo{ + // Description: to.Ptr("Checks that account name is valid and is not in use."), + // Operation: to.Ptr("Check Name Availability"), + // Provider: to.Ptr("Windows IoT"), + // Resource: to.Ptr("Name Availability"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.WindowsIoT/Services/read"), + // Display: &armwindowsiot.OperationDisplayInfo{ + // Description: to.Ptr("Returns the list of Windows IoT Services or gets the properties for the specified Windows IoT Subscription."), + // Operation: to.Ptr("List/Get Windows IoT Subscription(s)"), + // Provider: to.Ptr("Windows IoT"), + // Resource: to.Ptr("Windows IoT Services"), + // }, + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.WindowsIoT/operations/read"), + // Display: &armwindowsiot.OperationDisplayInfo{ + // Description: to.Ptr("Polls the status of an asynchronous operation."), + // Operation: to.Ptr("Poll Asynchronous Operation"), + // Provider: to.Ptr("Windows IoT"), + // Resource: to.Ptr("Operations"), + // }, + // Origin: to.Ptr("user,system"), + // }}, + // } + } +} diff --git a/sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_response_types.go b/sdk/resourcemanager/windowsiot/armwindowsiot/response_types.go similarity index 92% rename from sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_response_types.go rename to sdk/resourcemanager/windowsiot/armwindowsiot/response_types.go index eaf0e725a0ce..4480a8f2c832 100644 --- a/sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_response_types.go +++ b/sdk/resourcemanager/windowsiot/armwindowsiot/response_types.go @@ -5,10 +5,11 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. package armwindowsiot -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationListResult } @@ -33,12 +34,12 @@ type ServicesClientGetResponse struct { DeviceService } -// ServicesClientListByResourceGroupResponse contains the response from method ServicesClient.ListByResourceGroup. +// ServicesClientListByResourceGroupResponse contains the response from method ServicesClient.NewListByResourceGroupPager. type ServicesClientListByResourceGroupResponse struct { DeviceServiceDescriptionListResult } -// ServicesClientListResponse contains the response from method ServicesClient.List. +// ServicesClientListResponse contains the response from method ServicesClient.NewListPager. type ServicesClientListResponse struct { DeviceServiceDescriptionListResult } diff --git a/sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_services_client.go b/sdk/resourcemanager/windowsiot/armwindowsiot/services_client.go similarity index 85% rename from sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_services_client.go rename to sdk/resourcemanager/windowsiot/armwindowsiot/services_client.go index c05a1bcafc90..0ec8f3ca3e63 100644 --- a/sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_services_client.go +++ b/sdk/resourcemanager/windowsiot/armwindowsiot/services_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 armwindowsiot @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // ServicesClient contains the methods for the Services group. // Don't use this type directly, use NewServicesClient() instead. type ServicesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewServicesClient creates a new instance of ServicesClient with the specified values. -// subscriptionID - The 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 NewServicesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServicesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ServicesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ServicesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CheckDeviceServiceNameAvailability - Check if a Windows IoT Device Service name is available. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-06-01 -// deviceServiceCheckNameAvailabilityParameters - Set the name parameter in the DeviceServiceCheckNameAvailabilityParameters -// structure to the name of the Windows IoT Device Service to check. -// options - ServicesClientCheckDeviceServiceNameAvailabilityOptions contains the optional parameters for the ServicesClient.CheckDeviceServiceNameAvailability -// method. +// - deviceServiceCheckNameAvailabilityParameters - Set the name parameter in the DeviceServiceCheckNameAvailabilityParameters +// structure to the name of the Windows IoT Device Service to check. +// - options - ServicesClientCheckDeviceServiceNameAvailabilityOptions contains the optional parameters for the ServicesClient.CheckDeviceServiceNameAvailability +// method. func (client *ServicesClient) CheckDeviceServiceNameAvailability(ctx context.Context, deviceServiceCheckNameAvailabilityParameters DeviceServiceCheckNameAvailabilityParameters, options *ServicesClientCheckDeviceServiceNameAvailabilityOptions) (ServicesClientCheckDeviceServiceNameAvailabilityResponse, error) { req, err := client.checkDeviceServiceNameAvailabilityCreateRequest(ctx, deviceServiceCheckNameAvailabilityParameters, options) if err != nil { return ServicesClientCheckDeviceServiceNameAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServicesClientCheckDeviceServiceNameAvailabilityResponse{}, err } @@ -83,7 +74,7 @@ func (client *ServicesClient) checkDeviceServiceNameAvailabilityCreateRequest(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.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,17 +98,18 @@ func (client *ServicesClient) checkDeviceServiceNameAvailabilityHandleResponse(r // is to retrieve the Windows IoT Device Service metadata and security metadata, and then combine // them with the modified values in a new body to update the Windows IoT Device Service. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-06-01 -// resourceGroupName - The name of the resource group that contains the Windows IoT Device Service. -// deviceName - The name of the Windows IoT Device Service. -// deviceService - The Windows IoT Device Service metadata and security metadata. -// options - ServicesClientCreateOrUpdateOptions contains the optional parameters for the ServicesClient.CreateOrUpdate method. +// - resourceGroupName - The name of the resource group that contains the Windows IoT Device Service. +// - deviceName - The name of the Windows IoT Device Service. +// - deviceService - The Windows IoT Device Service metadata and security metadata. +// - options - ServicesClientCreateOrUpdateOptions contains the optional parameters for the ServicesClient.CreateOrUpdate method. func (client *ServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, deviceName string, deviceService DeviceService, options *ServicesClientCreateOrUpdateOptions) (ServicesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, deviceName, deviceService, options) if err != nil { return ServicesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServicesClientCreateOrUpdateResponse{}, err } @@ -142,7 +134,7 @@ func (client *ServicesClient) createOrUpdateCreateRequest(ctx context.Context, r return nil, errors.New("parameter deviceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName)) - 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 } @@ -167,16 +159,17 @@ func (client *ServicesClient) createOrUpdateHandleResponse(resp *http.Response) // Delete - Delete a Windows IoT Device Service. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-06-01 -// resourceGroupName - The name of the resource group that contains the Windows IoT Device Service. -// deviceName - The name of the Windows IoT Device Service. -// options - ServicesClientDeleteOptions contains the optional parameters for the ServicesClient.Delete method. +// - resourceGroupName - The name of the resource group that contains the Windows IoT Device Service. +// - deviceName - The name of the Windows IoT Device Service. +// - options - ServicesClientDeleteOptions contains the optional parameters for the ServicesClient.Delete method. func (client *ServicesClient) Delete(ctx context.Context, resourceGroupName string, deviceName string, options *ServicesClientDeleteOptions) (ServicesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, deviceName, options) if err != nil { return ServicesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServicesClientDeleteResponse{}, err } @@ -201,7 +194,7 @@ func (client *ServicesClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter deviceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName)) - 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 } @@ -223,16 +216,17 @@ func (client *ServicesClient) deleteHandleResponse(resp *http.Response) (Service // Get - Get the non-security related metadata of a Windows IoT Device Service. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-06-01 -// resourceGroupName - The name of the resource group that contains the Windows IoT Device Service. -// deviceName - The name of the Windows IoT Device Service. -// options - ServicesClientGetOptions contains the optional parameters for the ServicesClient.Get method. +// - resourceGroupName - The name of the resource group that contains the Windows IoT Device Service. +// - deviceName - The name of the Windows IoT Device Service. +// - options - ServicesClientGetOptions contains the optional parameters for the ServicesClient.Get method. func (client *ServicesClient) Get(ctx context.Context, resourceGroupName string, deviceName string, options *ServicesClientGetOptions) (ServicesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, deviceName, options) if err != nil { return ServicesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServicesClientGetResponse{}, err } @@ -257,7 +251,7 @@ func (client *ServicesClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter deviceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -278,9 +272,9 @@ func (client *ServicesClient) getHandleResponse(resp *http.Response) (ServicesCl } // NewListPager - Get all the IoT hubs in a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-06-01 -// options - ServicesClientListOptions contains the optional parameters for the ServicesClient.List method. +// - options - ServicesClientListOptions contains the optional parameters for the ServicesClient.NewListPager method. func (client *ServicesClient) NewListPager(options *ServicesClientListOptions) *runtime.Pager[ServicesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ServicesClientListResponse]{ More: func(page ServicesClientListResponse) bool { @@ -297,7 +291,7 @@ func (client *ServicesClient) NewListPager(options *ServicesClientListOptions) * if err != nil { return ServicesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServicesClientListResponse{}, err } @@ -316,7 +310,7 @@ func (client *ServicesClient) listCreateRequest(ctx context.Context, options *Se 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 } @@ -337,11 +331,11 @@ func (client *ServicesClient) listHandleResponse(resp *http.Response) (ServicesC } // NewListByResourceGroupPager - Get all the IoT hubs in a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-06-01 -// resourceGroupName - The name of the resource group that contains the Windows IoT Device Service. -// options - ServicesClientListByResourceGroupOptions contains the optional parameters for the ServicesClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group that contains the Windows IoT Device Service. +// - options - ServicesClientListByResourceGroupOptions contains the optional parameters for the ServicesClient.NewListByResourceGroupPager +// method. func (client *ServicesClient) NewListByResourceGroupPager(resourceGroupName string, options *ServicesClientListByResourceGroupOptions) *runtime.Pager[ServicesClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[ServicesClientListByResourceGroupResponse]{ More: func(page ServicesClientListByResourceGroupResponse) bool { @@ -358,7 +352,7 @@ func (client *ServicesClient) NewListByResourceGroupPager(resourceGroupName stri if err != nil { return ServicesClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServicesClientListByResourceGroupResponse{}, err } @@ -381,7 +375,7 @@ func (client *ServicesClient) 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 } @@ -405,17 +399,18 @@ func (client *ServicesClient) listByResourceGroupHandleResponse(resp *http.Respo // Windows IoT Device Service metadata and security metadata, and then combine them with // the modified values in a new body to update the Windows IoT Device Service. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-06-01 -// resourceGroupName - The name of the resource group that contains the Windows IoT Device Service. -// deviceName - The name of the Windows IoT Device Service. -// deviceService - The Windows IoT Device Service metadata and security metadata. -// options - ServicesClientUpdateOptions contains the optional parameters for the ServicesClient.Update method. +// - resourceGroupName - The name of the resource group that contains the Windows IoT Device Service. +// - deviceName - The name of the Windows IoT Device Service. +// - deviceService - The Windows IoT Device Service metadata and security metadata. +// - options - ServicesClientUpdateOptions contains the optional parameters for the ServicesClient.Update method. func (client *ServicesClient) Update(ctx context.Context, resourceGroupName string, deviceName string, deviceService DeviceService, options *ServicesClientUpdateOptions) (ServicesClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, deviceName, deviceService, options) if err != nil { return ServicesClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServicesClientUpdateResponse{}, err } @@ -440,7 +435,7 @@ func (client *ServicesClient) updateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter deviceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{deviceName}", url.PathEscape(deviceName)) - 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/windowsiot/armwindowsiot/services_client_example_test.go b/sdk/resourcemanager/windowsiot/armwindowsiot/services_client_example_test.go new file mode 100644 index 000000000000..e360da204118 --- /dev/null +++ b/sdk/resourcemanager/windowsiot/armwindowsiot/services_client_example_test.go @@ -0,0 +1,325 @@ +//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 armwindowsiot_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/windowsiot/armwindowsiot" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_GetProperties.json +func ExampleServicesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armwindowsiot.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServicesClient().Get(ctx, "res9407", "service8596", 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.DeviceService = armwindowsiot.DeviceService{ + // Name: to.Ptr("service8596"), + // Type: to.Ptr("Microsoft.WindowsIoT/Services"), + // ID: to.Ptr("/subscriptions/45b60d85-fd72-427a-a708-f994d26e593e/resourceGroups/res9407/providers/Microsoft.WindowsIoT/Services/service8596"), + // Location: to.Ptr("westus"), + // Properties: &armwindowsiot.DeviceServiceProperties{ + // AdminDomainName: to.Ptr("d.e.f"), + // BillingDomainName: to.Ptr("a.b.c"), + // Notes: to.Ptr("blah"), + // Quantity: to.Ptr[int64](1000000), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T12:00:00000Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_Create.json +func ExampleServicesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armwindowsiot.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServicesClient().CreateOrUpdate(ctx, "res9101", "service4445", armwindowsiot.DeviceService{ + Location: to.Ptr("East US"), + Properties: &armwindowsiot.DeviceServiceProperties{ + AdminDomainName: to.Ptr("d.e.f"), + BillingDomainName: to.Ptr("a.b.c"), + Notes: to.Ptr("blah"), + Quantity: to.Ptr[int64](1000000), + }, + }, &armwindowsiot.ServicesClientCreateOrUpdateOptions{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.DeviceService = armwindowsiot.DeviceService{ + // Type: to.Ptr("Microsoft.WindowsIoT/Services"), + // Location: to.Ptr("East US"), + // Properties: &armwindowsiot.DeviceServiceProperties{ + // AdminDomainName: to.Ptr("d.e.f"), + // BillingDomainName: to.Ptr("a.b.c"), + // Notes: to.Ptr("blah"), + // Quantity: to.Ptr[int64](1000000), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T12:00:00000Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_Update.json +func ExampleServicesClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armwindowsiot.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServicesClient().Update(ctx, "res9407", "service8596", armwindowsiot.DeviceService{ + Location: to.Ptr("East US"), + Properties: &armwindowsiot.DeviceServiceProperties{ + AdminDomainName: to.Ptr("d.e.f"), + BillingDomainName: to.Ptr("a.b.c"), + Notes: to.Ptr("blah"), + Quantity: to.Ptr[int64](1000000), + }, + }, &armwindowsiot.ServicesClientUpdateOptions{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.DeviceService = armwindowsiot.DeviceService{ + // Type: to.Ptr("Microsoft.WindowsIoT/Services"), + // Location: to.Ptr("East US"), + // Properties: &armwindowsiot.DeviceServiceProperties{ + // AdminDomainName: to.Ptr("d.e.f"), + // BillingDomainName: to.Ptr("a.b.c"), + // Notes: to.Ptr("blah"), + // Quantity: to.Ptr[int64](1000000), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T12:00:00000Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_Delete.json +func ExampleServicesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armwindowsiot.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServicesClient().Delete(ctx, "res4228", "service2434", 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.DeviceService = armwindowsiot.DeviceService{ + // Type: to.Ptr("Microsoft.WindowsIoT/Services"), + // Properties: &armwindowsiot.DeviceServiceProperties{ + // AdminDomainName: to.Ptr("d.e.f"), + // BillingDomainName: to.Ptr("a.b.c"), + // Notes: to.Ptr("blah"), + // Quantity: to.Ptr[int64](1000000), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T12:00:00000Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_ListByResourceGroup.json +func ExampleServicesClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armwindowsiot.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewServicesClient().NewListByResourceGroupPager("res6117", 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.DeviceServiceDescriptionListResult = armwindowsiot.DeviceServiceDescriptionListResult{ + // Value: []*armwindowsiot.DeviceService{ + // { + // Name: to.Ptr("service4036"), + // Type: to.Ptr("Microsoft.WindowsIoT/Services"), + // ID: to.Ptr("/subscriptions/27de630f-e1ee-42de-8849-90def4986454/resourceGroups/res6117/providers/Microsoft.WindowsIoT/Services/service4036"), + // Properties: &armwindowsiot.DeviceServiceProperties{ + // AdminDomainName: to.Ptr("d.e.f"), + // BillingDomainName: to.Ptr("a.b.c"), + // Notes: to.Ptr("blah"), + // Quantity: to.Ptr[int64](1000000), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T12:00:00000Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("service4452"), + // Type: to.Ptr("Microsoft.WindowsIoT/Services"), + // ID: to.Ptr("/subscriptions/27de630f-e1ee-42de-8849-90def4986454/resourceGroups/res6117/providers/Microsoft.WindowsIoT/Services/service4452"), + // Properties: &armwindowsiot.DeviceServiceProperties{ + // AdminDomainName: to.Ptr("d.e.f"), + // BillingDomainName: to.Ptr("a.b.c"), + // Notes: to.Ptr("blah"), + // Quantity: to.Ptr[int64](1000000), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T12:00:00000Z"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_List.json +func ExampleServicesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armwindowsiot.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewServicesClient().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.DeviceServiceDescriptionListResult = armwindowsiot.DeviceServiceDescriptionListResult{ + // Value: []*armwindowsiot.DeviceService{ + // { + // Name: to.Ptr("service1125"), + // Type: to.Ptr("Microsoft.WindowsIoT/Services"), + // ID: to.Ptr("/subscriptions/27de630f-e1ee-42de-8849-90def4986454/resourceGroups/res2627/providers/Microsoft.WindowsIoT/Services/service1125"), + // Properties: &armwindowsiot.DeviceServiceProperties{ + // AdminDomainName: to.Ptr("d.e.f"), + // BillingDomainName: to.Ptr("a.b.c"), + // Notes: to.Ptr("blah"), + // Quantity: to.Ptr[int64](1000000), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T12:00:00000Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("service3699"), + // Type: to.Ptr("Microsoft.WindowsIoT/Services"), + // ID: to.Ptr("/subscriptions/27de630f-e1ee-42de-8849-90def4986454/resourceGroups/testcmk3/providers/Microsoft.WindowsIoT/Services/service3699"), + // Properties: &armwindowsiot.DeviceServiceProperties{ + // AdminDomainName: to.Ptr("d.e.f"), + // BillingDomainName: to.Ptr("a.b.c"), + // Notes: to.Ptr("blah"), + // Quantity: to.Ptr[int64](1000000), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T12:00:00000Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("service6637"), + // Type: to.Ptr("Microsoft.WindowsIoT/Services"), + // ID: to.Ptr("/subscriptions/27de630f-e1ee-42de-8849-90def4986454/resourceGroups/testcmk3/providers/Microsoft.WindowsIoT/Services/service6637"), + // Properties: &armwindowsiot.DeviceServiceProperties{ + // AdminDomainName: to.Ptr("d.e.f"), + // BillingDomainName: to.Ptr("a.b.c"), + // Notes: to.Ptr("blah"), + // Quantity: to.Ptr[int64](1000000), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T12:00:00000Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("service834"), + // Type: to.Ptr("Microsoft.WindowsIoT/Services"), + // ID: to.Ptr("/subscriptions/27de630f-e1ee-42de-8849-90def4986454/resourceGroups/res8186/providers/Microsoft.WindowsIoT/Services/service834"), + // Properties: &armwindowsiot.DeviceServiceProperties{ + // AdminDomainName: to.Ptr("d.e.f"), + // BillingDomainName: to.Ptr("a.b.c"), + // Notes: to.Ptr("blah"), + // Quantity: to.Ptr[int64](1000000), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T12:00:00000Z"); return t}()), + // }, + // }, + // { + // Name: to.Ptr("service9174"), + // Type: to.Ptr("Microsoft.WindowsIoT/Services"), + // ID: to.Ptr("/subscriptions/27de630f-e1ee-42de-8849-90def4986454/resourceGroups/testcmk3/providers/Microsoft.WindowsIoT/Services/service9174"), + // Properties: &armwindowsiot.DeviceServiceProperties{ + // AdminDomainName: to.Ptr("d.e.f"), + // BillingDomainName: to.Ptr("a.b.c"), + // Notes: to.Ptr("blah"), + // Quantity: to.Ptr[int64](1000000), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T12:00:00000Z"); return t}()), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_CheckNameAvailability.json +func ExampleServicesClient_CheckDeviceServiceNameAvailability() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armwindowsiot.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServicesClient().CheckDeviceServiceNameAvailability(ctx, armwindowsiot.DeviceServiceCheckNameAvailabilityParameters{ + Name: to.Ptr("service3363"), + }, 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.DeviceServiceNameAvailabilityInfo = armwindowsiot.DeviceServiceNameAvailabilityInfo{ + // NameAvailable: to.Ptr(true), + // } +} diff --git a/sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_time_rfc3339.go b/sdk/resourcemanager/windowsiot/armwindowsiot/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/windowsiot/armwindowsiot/time_rfc3339.go index a96f4c71c8de..790e03c244c8 100644 --- a/sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/windowsiot/armwindowsiot/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 armwindowsiot @@ -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/windowsiot/armwindowsiot/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/windowsiot/armwindowsiot/ze_generated_example_operations_client_test.go deleted file mode 100644 index ab25aa919dae..000000000000 --- a/sdk/resourcemanager/windowsiot/armwindowsiot/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 armwindowsiot_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/windowsiot/armwindowsiot" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/OperationsList.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armwindowsiot.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/windowsiot/armwindowsiot/ze_generated_example_services_client_test.go b/sdk/resourcemanager/windowsiot/armwindowsiot/ze_generated_example_services_client_test.go deleted file mode 100644 index f8a65b00bf73..000000000000 --- a/sdk/resourcemanager/windowsiot/armwindowsiot/ze_generated_example_services_client_test.go +++ /dev/null @@ -1,196 +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 armwindowsiot_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/windowsiot/armwindowsiot" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_GetProperties.json -func ExampleServicesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armwindowsiot.NewServicesClient("45b60d85-fd72-427a-a708-f994d26e593e", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "res9407", - "service8596", - 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/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_Create.json -func ExampleServicesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armwindowsiot.NewServicesClient("27de630f-e1ee-42de-8849-90def4986454", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "res9101", - "service4445", - armwindowsiot.DeviceService{ - Location: to.Ptr("East US"), - Properties: &armwindowsiot.DeviceServiceProperties{ - AdminDomainName: to.Ptr("d.e.f"), - BillingDomainName: to.Ptr("a.b.c"), - Notes: to.Ptr("blah"), - Quantity: to.Ptr[int64](1000000), - }, - }, - &armwindowsiot.ServicesClientCreateOrUpdateOptions{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/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_Update.json -func ExampleServicesClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armwindowsiot.NewServicesClient("45b60d85-fd72-427a-a708-f994d26e593e", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "res9407", - "service8596", - armwindowsiot.DeviceService{ - Location: to.Ptr("East US"), - Properties: &armwindowsiot.DeviceServiceProperties{ - AdminDomainName: to.Ptr("d.e.f"), - BillingDomainName: to.Ptr("a.b.c"), - Notes: to.Ptr("blah"), - Quantity: to.Ptr[int64](1000000), - }, - }, - &armwindowsiot.ServicesClientUpdateOptions{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/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_Delete.json -func ExampleServicesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armwindowsiot.NewServicesClient("27de630f-e1ee-42de-8849-90def4986454", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Delete(ctx, - "res4228", - "service2434", - 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/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_ListByResourceGroup.json -func ExampleServicesClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armwindowsiot.NewServicesClient("27de630f-e1ee-42de-8849-90def4986454", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("res6117", - 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/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_List.json -func ExampleServicesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armwindowsiot.NewServicesClient("27de630f-e1ee-42de-8849-90def4986454", 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/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_CheckNameAvailability.json -func ExampleServicesClient_CheckDeviceServiceNameAvailability() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armwindowsiot.NewServicesClient("27de630f-e1ee-42de-8849-90def4986454", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CheckDeviceServiceNameAvailability(ctx, - armwindowsiot.DeviceServiceCheckNameAvailabilityParameters{ - Name: to.Ptr("service3363"), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_models_serde.go b/sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_models_serde.go deleted file mode 100644 index fccfb34bd91a..000000000000 --- a/sdk/resourcemanager/windowsiot/armwindowsiot/zz_generated_models_serde.go +++ /dev/null @@ -1,103 +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 armwindowsiot - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type DeviceService. -func (d DeviceService) 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, "tags", d.Tags) - populate(objectMap, "type", d.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type DeviceServiceProperties. -func (d DeviceServiceProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "adminDomainName", d.AdminDomainName) - populate(objectMap, "billingDomainName", d.BillingDomainName) - populate(objectMap, "notes", d.Notes) - populate(objectMap, "quantity", d.Quantity) - populateTimeRFC3339(objectMap, "startDate", d.StartDate) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceServiceProperties. -func (d *DeviceServiceProperties) UnmarshalJSON(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 "adminDomainName": - err = unpopulate(val, "AdminDomainName", &d.AdminDomainName) - delete(rawMsg, key) - case "billingDomainName": - err = unpopulate(val, "BillingDomainName", &d.BillingDomainName) - delete(rawMsg, key) - case "notes": - err = unpopulate(val, "Notes", &d.Notes) - delete(rawMsg, key) - case "quantity": - err = unpopulate(val, "Quantity", &d.Quantity) - delete(rawMsg, key) - case "startDate": - err = unpopulateTimeRFC3339(val, "StartDate", &d.StartDate) - 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 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 -}