diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/CHANGELOG.md b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/CHANGELOG.md index fb7c673dda43..ccda030b2829 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/CHANGELOG.md +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/CHANGELOG.md @@ -1,5 +1,31 @@ # Release History +## 3.0.0 (2023-03-27) +### Breaking Changes + +- Const `ArmServerKeyTypeSystemAssigned` from type alias `ArmServerKeyType` has been removed +- Const `ReplicationRoleGeoSyncReplica`, `ReplicationRoleSecondary`, `ReplicationRoleSyncReplica`, `ReplicationRoleWalReplica` from type alias `ReplicationRole` has been removed + +### Features Added + +- New value `ArmServerKeyTypeSystemManaged` added to enum type `ArmServerKeyType` +- New function `NewClientFactory(string, azcore.TokenCredential, *arm.ClientOptions) (*ClientFactory, error)` +- New function `*ClientFactory.NewAdministratorsClient() *AdministratorsClient` +- New function `*ClientFactory.NewBackupsClient() *BackupsClient` +- New function `*ClientFactory.NewCheckNameAvailabilityClient() *CheckNameAvailabilityClient` +- New function `*ClientFactory.NewCheckNameAvailabilityWithLocationClient() *CheckNameAvailabilityWithLocationClient` +- New function `*ClientFactory.NewConfigurationsClient() *ConfigurationsClient` +- New function `*ClientFactory.NewDatabasesClient() *DatabasesClient` +- New function `*ClientFactory.NewFirewallRulesClient() *FirewallRulesClient` +- New function `*ClientFactory.NewGetPrivateDNSZoneSuffixClient() *GetPrivateDNSZoneSuffixClient` +- New function `*ClientFactory.NewLocationBasedCapabilitiesClient() *LocationBasedCapabilitiesClient` +- New function `*ClientFactory.NewOperationsClient() *OperationsClient` +- New function `*ClientFactory.NewReplicasClient() *ReplicasClient` +- New function `*ClientFactory.NewServersClient() *ServersClient` +- New function `*ClientFactory.NewVirtualNetworkSubnetUsageClient() *VirtualNetworkSubnetUsageClient` +- New struct `ClientFactory` + + ## 2.0.0 (2023-01-27) ### Breaking Changes diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/administrators_client.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/administrators_client.go index dce6c77e9dc5..0e9faed4cd87 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/administrators_client.go +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/administrators_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,67 +24,60 @@ import ( // AdministratorsClient contains the methods for the Administrators group. // Don't use this type directly, use NewAdministratorsClient() instead. type AdministratorsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAdministratorsClient creates a new instance of AdministratorsClient 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 NewAdministratorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AdministratorsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AdministratorsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AdministratorsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Creates a new server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// objectID - Guid of the objectId for the administrator. -// parameters - The required parameters for adding an active directory administrator for a server. -// options - AdministratorsClientBeginCreateOptions contains the optional parameters for the AdministratorsClient.BeginCreate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - objectID - Guid of the objectId for the administrator. +// - parameters - The required parameters for adding an active directory administrator for a server. +// - options - AdministratorsClientBeginCreateOptions contains the optional parameters for the AdministratorsClient.BeginCreate +// method. func (client *AdministratorsClient) BeginCreate(ctx context.Context, resourceGroupName string, serverName string, objectID string, parameters ActiveDirectoryAdministratorAdd, options *AdministratorsClientBeginCreateOptions) (*runtime.Poller[AdministratorsClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, serverName, objectID, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AdministratorsClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AdministratorsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[AdministratorsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AdministratorsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Creates a new server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 func (client *AdministratorsClient) create(ctx context.Context, resourceGroupName string, serverName string, objectID string, parameters ActiveDirectoryAdministratorAdd, options *AdministratorsClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, serverName, objectID, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -115,7 +106,7 @@ func (client *AdministratorsClient) createCreateRequest(ctx context.Context, res return nil, errors.New("parameter objectID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{objectId}", url.PathEscape(objectID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -128,35 +119,37 @@ func (client *AdministratorsClient) createCreateRequest(ctx context.Context, res // BeginDelete - Deletes an Active Directory Administrator associated with the server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// objectID - Guid of the objectId for the administrator. -// options - AdministratorsClientBeginDeleteOptions contains the optional parameters for the AdministratorsClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - objectID - Guid of the objectId for the administrator. +// - options - AdministratorsClientBeginDeleteOptions contains the optional parameters for the AdministratorsClient.BeginDelete +// method. func (client *AdministratorsClient) BeginDelete(ctx context.Context, resourceGroupName string, serverName string, objectID string, options *AdministratorsClientBeginDeleteOptions) (*runtime.Poller[AdministratorsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, serverName, objectID, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AdministratorsClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AdministratorsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[AdministratorsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AdministratorsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes an Active Directory Administrator associated with the server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 func (client *AdministratorsClient) deleteOperation(ctx context.Context, resourceGroupName string, serverName string, objectID string, options *AdministratorsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, serverName, objectID, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -185,7 +178,7 @@ func (client *AdministratorsClient) deleteCreateRequest(ctx context.Context, res return nil, errors.New("parameter objectID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{objectId}", url.PathEscape(objectID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -198,17 +191,18 @@ func (client *AdministratorsClient) deleteCreateRequest(ctx context.Context, res // Get - Gets information about a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// objectID - Guid of the objectId for the administrator. -// options - AdministratorsClientGetOptions contains the optional parameters for the AdministratorsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - objectID - Guid of the objectId for the administrator. +// - options - AdministratorsClientGetOptions contains the optional parameters for the AdministratorsClient.Get method. func (client *AdministratorsClient) Get(ctx context.Context, resourceGroupName string, serverName string, objectID string, options *AdministratorsClientGetOptions) (AdministratorsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, objectID, options) if err != nil { return AdministratorsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AdministratorsClientGetResponse{}, err } @@ -237,7 +231,7 @@ func (client *AdministratorsClient) getCreateRequest(ctx context.Context, resour return nil, errors.New("parameter objectID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{objectId}", url.PathEscape(objectID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -258,11 +252,12 @@ func (client *AdministratorsClient) getHandleResponse(resp *http.Response) (Admi } // NewListByServerPager - List all the AAD administrators for a given server. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - AdministratorsClientListByServerOptions contains the optional parameters for the AdministratorsClient.ListByServer -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - AdministratorsClientListByServerOptions contains the optional parameters for the AdministratorsClient.NewListByServerPager +// method. func (client *AdministratorsClient) NewListByServerPager(resourceGroupName string, serverName string, options *AdministratorsClientListByServerOptions) *runtime.Pager[AdministratorsClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[AdministratorsClientListByServerResponse]{ More: func(page AdministratorsClientListByServerResponse) bool { @@ -279,7 +274,7 @@ func (client *AdministratorsClient) NewListByServerPager(resourceGroupName strin if err != nil { return AdministratorsClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AdministratorsClientListByServerResponse{}, err } @@ -306,7 +301,7 @@ func (client *AdministratorsClient) listByServerCreateRequest(ctx context.Contex return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/administrators_client_example_test.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/administrators_client_example_test.go deleted file mode 100644 index 09e1d65bbd07..000000000000 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/administrators_client_example_test.go +++ /dev/null @@ -1,111 +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 armpostgresqlflexibleservers_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/postgresql/armpostgresqlflexibleservers/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/AdministratorAdd.json -func ExampleAdministratorsClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewAdministratorsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, "testrg", "testserver", "oooooooo-oooo-oooo-oooo-oooooooooooo", armpostgresqlflexibleservers.ActiveDirectoryAdministratorAdd{ - Properties: &armpostgresqlflexibleservers.AdministratorPropertiesForAdd{ - PrincipalName: to.Ptr("testuser1@microsoft.com"), - PrincipalType: to.Ptr(armpostgresqlflexibleservers.PrincipalTypeUser), - TenantID: to.Ptr("tttttttt-tttt-tttt-tttt-tttttttttttt"), - }, - }, 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/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/AdministratorDelete.json -func ExampleAdministratorsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewAdministratorsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, "testrg", "testserver", "oooooooo-oooo-oooo-oooo-oooooooooooo", 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/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/AdministratorGet.json -func ExampleAdministratorsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewAdministratorsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "testrg", "pgtestsvc1", "oooooooo-oooo-oooo-oooo-oooooooooooo", 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/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/AdministratorsListByServer.json -func ExampleAdministratorsClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewAdministratorsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("testrg", "pgtestsvc1", 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/postgresql/armpostgresqlflexibleservers/autorest.md b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/autorest.md index b0e440731053..3bcf7d9bbe85 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/autorest.md +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/fce0b25dda01303f2c70de34031169b5d326998b/specification/postgresql/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/fce0b25dda01303f2c70de34031169b5d326998b/specification/postgresql/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/postgresql/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/postgresql/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 2.0.0 +module-version: 3.0.0 package-flexibleservers: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/backups_client.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/backups_client.go index 5cc29c366ba2..5e6a033e4014 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/backups_client.go +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/backups_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // BackupsClient contains the methods for the Backups group. // Don't use this type directly, use NewBackupsClient() instead. type BackupsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewBackupsClient creates a new instance of BackupsClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewBackupsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BackupsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".BackupsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &BackupsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get specific backup for a given server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// backupName - The name of the backup. -// options - BackupsClientGetOptions contains the optional parameters for the BackupsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - backupName - The name of the backup. +// - options - BackupsClientGetOptions contains the optional parameters for the BackupsClient.Get method. func (client *BackupsClient) Get(ctx context.Context, resourceGroupName string, serverName string, backupName string, options *BackupsClientGetOptions) (BackupsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, backupName, options) if err != nil { return BackupsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BackupsClientGetResponse{}, err } @@ -96,7 +86,7 @@ func (client *BackupsClient) getCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter backupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{backupName}", url.PathEscape(backupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -117,10 +107,12 @@ func (client *BackupsClient) getHandleResponse(resp *http.Response) (BackupsClie } // NewListByServerPager - List all the backups for a given server. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - BackupsClientListByServerOptions contains the optional parameters for the BackupsClient.ListByServer method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - BackupsClientListByServerOptions contains the optional parameters for the BackupsClient.NewListByServerPager +// method. func (client *BackupsClient) NewListByServerPager(resourceGroupName string, serverName string, options *BackupsClientListByServerOptions) *runtime.Pager[BackupsClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[BackupsClientListByServerResponse]{ More: func(page BackupsClientListByServerResponse) bool { @@ -137,7 +129,7 @@ func (client *BackupsClient) NewListByServerPager(resourceGroupName string, serv if err != nil { return BackupsClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return BackupsClientListByServerResponse{}, err } @@ -164,7 +156,7 @@ func (client *BackupsClient) listByServerCreateRequest(ctx context.Context, reso return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/backups_client_example_test.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/backups_client_example_test.go deleted file mode 100644 index 11981458d9a6..000000000000 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/backups_client_example_test.go +++ /dev/null @@ -1,60 +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 armpostgresqlflexibleservers_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/BackupGet.json -func ExampleBackupsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewBackupsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "TestGroup", "postgresqltestserver", "daily_20210615T160516", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/BackupListByServer.json -func ExampleBackupsClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewBackupsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("TestGroup", "postgresqltestserver", 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/postgresql/armpostgresqlflexibleservers/checknameavailability_client.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/checknameavailability_client.go index 64cf78397916..d02f02cb2783 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/checknameavailability_client.go +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/checknameavailability_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 ( // CheckNameAvailabilityClient contains the methods for the CheckNameAvailability group. // Don't use this type directly, use NewCheckNameAvailabilityClient() instead. type CheckNameAvailabilityClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCheckNameAvailabilityClient creates a new instance of CheckNameAvailabilityClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewCheckNameAvailabilityClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CheckNameAvailabilityClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".CheckNameAvailabilityClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CheckNameAvailabilityClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Execute - Check the availability of name for resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// nameAvailabilityRequest - The required parameters for checking if resource name is available. -// options - CheckNameAvailabilityClientExecuteOptions contains the optional parameters for the CheckNameAvailabilityClient.Execute -// method. +// - nameAvailabilityRequest - The required parameters for checking if resource name is available. +// - options - CheckNameAvailabilityClientExecuteOptions contains the optional parameters for the CheckNameAvailabilityClient.Execute +// method. func (client *CheckNameAvailabilityClient) Execute(ctx context.Context, nameAvailabilityRequest CheckNameAvailabilityRequest, options *CheckNameAvailabilityClientExecuteOptions) (CheckNameAvailabilityClientExecuteResponse, error) { req, err := client.executeCreateRequest(ctx, nameAvailabilityRequest, options) if err != nil { return CheckNameAvailabilityClientExecuteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CheckNameAvailabilityClientExecuteResponse{}, err } @@ -83,7 +73,7 @@ func (client *CheckNameAvailabilityClient) executeCreateRequest(ctx context.Cont return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/checknameavailability_client_example_test.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/checknameavailability_client_example_test.go deleted file mode 100644 index 6570c344eb94..000000000000 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/checknameavailability_client_example_test.go +++ /dev/null @@ -1,40 +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 armpostgresqlflexibleservers_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/postgresql/armpostgresqlflexibleservers/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/CheckNameAvailability.json -func ExampleCheckNameAvailabilityClient_Execute() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewCheckNameAvailabilityClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Execute(ctx, armpostgresqlflexibleservers.CheckNameAvailabilityRequest{ - Name: to.Ptr("name1"), - Type: to.Ptr("Microsoft.DBforPostgreSQL/flexibleServers"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/checknameavailabilitywithlocation_client.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/checknameavailabilitywithlocation_client.go index 790d11aeead9..19f88b552afe 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/checknameavailabilitywithlocation_client.go +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/checknameavailabilitywithlocation_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // CheckNameAvailabilityWithLocationClient contains the methods for the CheckNameAvailabilityWithLocation group. // Don't use this type directly, use NewCheckNameAvailabilityWithLocationClient() instead. type CheckNameAvailabilityWithLocationClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCheckNameAvailabilityWithLocationClient creates a new instance of CheckNameAvailabilityWithLocationClient 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 NewCheckNameAvailabilityWithLocationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CheckNameAvailabilityWithLocationClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".CheckNameAvailabilityWithLocationClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CheckNameAvailabilityWithLocationClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Execute - Check the availability of name for resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// locationName - The name of the location. -// nameAvailabilityRequest - The required parameters for checking if resource name is available. -// options - CheckNameAvailabilityWithLocationClientExecuteOptions contains the optional parameters for the CheckNameAvailabilityWithLocationClient.Execute -// method. +// - locationName - The name of the location. +// - nameAvailabilityRequest - The required parameters for checking if resource name is available. +// - options - CheckNameAvailabilityWithLocationClientExecuteOptions contains the optional parameters for the CheckNameAvailabilityWithLocationClient.Execute +// method. func (client *CheckNameAvailabilityWithLocationClient) Execute(ctx context.Context, locationName string, nameAvailabilityRequest CheckNameAvailabilityRequest, options *CheckNameAvailabilityWithLocationClientExecuteOptions) (CheckNameAvailabilityWithLocationClientExecuteResponse, error) { req, err := client.executeCreateRequest(ctx, locationName, nameAvailabilityRequest, options) if err != nil { return CheckNameAvailabilityWithLocationClientExecuteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CheckNameAvailabilityWithLocationClientExecuteResponse{}, err } @@ -88,7 +78,7 @@ func (client *CheckNameAvailabilityWithLocationClient) executeCreateRequest(ctx return nil, errors.New("parameter locationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/checknameavailabilitywithlocation_client_example_test.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/checknameavailabilitywithlocation_client_example_test.go deleted file mode 100644 index 47d5999c8ebb..000000000000 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/checknameavailabilitywithlocation_client_example_test.go +++ /dev/null @@ -1,40 +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 armpostgresqlflexibleservers_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/postgresql/armpostgresqlflexibleservers/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/CheckNameAvailabilityLocationBased.json -func ExampleCheckNameAvailabilityWithLocationClient_Execute() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewCheckNameAvailabilityWithLocationClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Execute(ctx, "westus", armpostgresqlflexibleservers.CheckNameAvailabilityRequest{ - Name: to.Ptr("name1"), - Type: to.Ptr("Microsoft.DBforPostgreSQL/flexibleServers"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/client_factory.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/client_factory.go new file mode 100644 index 000000000000..8c848758186f --- /dev/null +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/client_factory.go @@ -0,0 +1,104 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armpostgresqlflexibleservers + +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) NewAdministratorsClient() *AdministratorsClient { + subClient, _ := NewAdministratorsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewBackupsClient() *BackupsClient { + subClient, _ := NewBackupsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewLocationBasedCapabilitiesClient() *LocationBasedCapabilitiesClient { + subClient, _ := NewLocationBasedCapabilitiesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCheckNameAvailabilityClient() *CheckNameAvailabilityClient { + subClient, _ := NewCheckNameAvailabilityClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCheckNameAvailabilityWithLocationClient() *CheckNameAvailabilityWithLocationClient { + subClient, _ := NewCheckNameAvailabilityWithLocationClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewConfigurationsClient() *ConfigurationsClient { + subClient, _ := NewConfigurationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDatabasesClient() *DatabasesClient { + subClient, _ := NewDatabasesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewFirewallRulesClient() *FirewallRulesClient { + subClient, _ := NewFirewallRulesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewServersClient() *ServersClient { + subClient, _ := NewServersClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewGetPrivateDNSZoneSuffixClient() *GetPrivateDNSZoneSuffixClient { + subClient, _ := NewGetPrivateDNSZoneSuffixClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewReplicasClient() *ReplicasClient { + subClient, _ := NewReplicasClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVirtualNetworkSubnetUsageClient() *VirtualNetworkSubnetUsageClient { + subClient, _ := NewVirtualNetworkSubnetUsageClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/configurations_client.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/configurations_client.go index 1796b7b7a76a..fbd2d2f9974e 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/configurations_client.go +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/configurations_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // ConfigurationsClient contains the methods for the Configurations group. // Don't use this type directly, use NewConfigurationsClient() instead. type ConfigurationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewConfigurationsClient creates a new instance of ConfigurationsClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewConfigurationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ConfigurationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ConfigurationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ConfigurationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Gets information about a configuration of server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// configurationName - The name of the server configuration. -// options - ConfigurationsClientGetOptions contains the optional parameters for the ConfigurationsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - configurationName - The name of the server configuration. +// - options - ConfigurationsClientGetOptions contains the optional parameters for the ConfigurationsClient.Get method. func (client *ConfigurationsClient) Get(ctx context.Context, resourceGroupName string, serverName string, configurationName string, options *ConfigurationsClientGetOptions) (ConfigurationsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, configurationName, options) if err != nil { return ConfigurationsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ConfigurationsClientGetResponse{}, err } @@ -96,7 +86,7 @@ func (client *ConfigurationsClient) getCreateRequest(ctx context.Context, resour return nil, errors.New("parameter configurationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{configurationName}", url.PathEscape(configurationName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -117,11 +107,12 @@ func (client *ConfigurationsClient) getHandleResponse(resp *http.Response) (Conf } // NewListByServerPager - List all the configurations in a given server. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ConfigurationsClientListByServerOptions contains the optional parameters for the ConfigurationsClient.ListByServer -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ConfigurationsClientListByServerOptions contains the optional parameters for the ConfigurationsClient.NewListByServerPager +// method. func (client *ConfigurationsClient) NewListByServerPager(resourceGroupName string, serverName string, options *ConfigurationsClientListByServerOptions) *runtime.Pager[ConfigurationsClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[ConfigurationsClientListByServerResponse]{ More: func(page ConfigurationsClientListByServerResponse) bool { @@ -138,7 +129,7 @@ func (client *ConfigurationsClient) NewListByServerPager(resourceGroupName strin if err != nil { return ConfigurationsClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ConfigurationsClientListByServerResponse{}, err } @@ -165,7 +156,7 @@ func (client *ConfigurationsClient) listByServerCreateRequest(ctx context.Contex return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -187,35 +178,37 @@ func (client *ConfigurationsClient) listByServerHandleResponse(resp *http.Respon // BeginPut - Updates a configuration of a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// configurationName - The name of the server configuration. -// parameters - The required parameters for updating a server configuration. -// options - ConfigurationsClientBeginPutOptions contains the optional parameters for the ConfigurationsClient.BeginPut method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - configurationName - The name of the server configuration. +// - parameters - The required parameters for updating a server configuration. +// - options - ConfigurationsClientBeginPutOptions contains the optional parameters for the ConfigurationsClient.BeginPut method. func (client *ConfigurationsClient) BeginPut(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration, options *ConfigurationsClientBeginPutOptions) (*runtime.Poller[ConfigurationsClientPutResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.put(ctx, resourceGroupName, serverName, configurationName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ConfigurationsClientPutResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ConfigurationsClientPutResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[ConfigurationsClientPutResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ConfigurationsClientPutResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Put - Updates a configuration of a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 func (client *ConfigurationsClient) put(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration, options *ConfigurationsClientBeginPutOptions) (*http.Response, error) { req, err := client.putCreateRequest(ctx, resourceGroupName, serverName, configurationName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -244,7 +237,7 @@ func (client *ConfigurationsClient) putCreateRequest(ctx context.Context, resour return nil, errors.New("parameter configurationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{configurationName}", url.PathEscape(configurationName)) - req, err := runtime.NewRequest(ctx, http.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 } @@ -257,36 +250,38 @@ func (client *ConfigurationsClient) putCreateRequest(ctx context.Context, resour // BeginUpdate - Updates a configuration of a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// configurationName - The name of the server configuration. -// parameters - The required parameters for updating a server configuration. -// options - ConfigurationsClientBeginUpdateOptions contains the optional parameters for the ConfigurationsClient.BeginUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - configurationName - The name of the server configuration. +// - parameters - The required parameters for updating a server configuration. +// - options - ConfigurationsClientBeginUpdateOptions contains the optional parameters for the ConfigurationsClient.BeginUpdate +// method. func (client *ConfigurationsClient) BeginUpdate(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters ConfigurationForUpdate, options *ConfigurationsClientBeginUpdateOptions) (*runtime.Poller[ConfigurationsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, serverName, configurationName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ConfigurationsClientUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ConfigurationsClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[ConfigurationsClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ConfigurationsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates a configuration of a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 func (client *ConfigurationsClient) update(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters ConfigurationForUpdate, options *ConfigurationsClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, serverName, configurationName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -315,7 +310,7 @@ func (client *ConfigurationsClient) updateCreateRequest(ctx context.Context, res return nil, errors.New("parameter configurationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{configurationName}", url.PathEscape(configurationName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/configurations_client_example_test.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/configurations_client_example_test.go deleted file mode 100644 index e0e65b4dfcfb..000000000000 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/configurations_client_example_test.go +++ /dev/null @@ -1,89 +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 armpostgresqlflexibleservers_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/postgresql/armpostgresqlflexibleservers/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ConfigurationListByServer.json -func ExampleConfigurationsClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewConfigurationsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("testrg", "testserver", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ConfigurationGet.json -func ExampleConfigurationsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewConfigurationsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "testrg", "testserver", "array_nulls", 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/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ConfigurationUpdate.json -func ExampleConfigurationsClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewConfigurationsClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, "testrg", "testserver", "event_scheduler", armpostgresqlflexibleservers.ConfigurationForUpdate{ - Properties: &armpostgresqlflexibleservers.ConfigurationProperties{ - Source: to.Ptr("user-override"), - Value: to.Ptr("on"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/constants.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/constants.go index c55cf7557e74..ca5375f8494a 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/constants.go +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/constants.go @@ -11,7 +11,7 @@ package armpostgresqlflexibleservers const ( moduleName = "armpostgresqlflexibleservers" - moduleVersion = "v2.0.0" + moduleVersion = "v3.0.0" ) // ActiveDirectoryAuthEnum - If Enabled, Azure Active Directory authentication is enabled. @@ -30,19 +30,19 @@ func PossibleActiveDirectoryAuthEnumValues() []ActiveDirectoryAuthEnum { } } -// ArmServerKeyType - Data encryption type to depict if it is System assigned vs Azure Key vault. +// ArmServerKeyType - Data encryption type to depict if it is System Managed vs Azure Key vault. type ArmServerKeyType string const ( - ArmServerKeyTypeAzureKeyVault ArmServerKeyType = "AzureKeyVault" - ArmServerKeyTypeSystemAssigned ArmServerKeyType = "SystemAssigned" + ArmServerKeyTypeAzureKeyVault ArmServerKeyType = "AzureKeyVault" + ArmServerKeyTypeSystemManaged ArmServerKeyType = "SystemManaged" ) // PossibleArmServerKeyTypeValues returns the possible values for the ArmServerKeyType const type. func PossibleArmServerKeyTypeValues() []ArmServerKeyType { return []ArmServerKeyType{ ArmServerKeyTypeAzureKeyVault, - ArmServerKeyTypeSystemAssigned, + ArmServerKeyTypeSystemManaged, } } @@ -288,12 +288,8 @@ type ReplicationRole string const ( ReplicationRoleAsyncReplica ReplicationRole = "AsyncReplica" ReplicationRoleGeoAsyncReplica ReplicationRole = "GeoAsyncReplica" - ReplicationRoleGeoSyncReplica ReplicationRole = "GeoSyncReplica" ReplicationRoleNone ReplicationRole = "None" ReplicationRolePrimary ReplicationRole = "Primary" - ReplicationRoleSecondary ReplicationRole = "Secondary" - ReplicationRoleSyncReplica ReplicationRole = "SyncReplica" - ReplicationRoleWalReplica ReplicationRole = "WalReplica" ) // PossibleReplicationRoleValues returns the possible values for the ReplicationRole const type. @@ -301,12 +297,8 @@ func PossibleReplicationRoleValues() []ReplicationRole { return []ReplicationRole{ ReplicationRoleAsyncReplica, ReplicationRoleGeoAsyncReplica, - ReplicationRoleGeoSyncReplica, ReplicationRoleNone, ReplicationRolePrimary, - ReplicationRoleSecondary, - ReplicationRoleSyncReplica, - ReplicationRoleWalReplica, } } diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/databases_client.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/databases_client.go index dc63eed679a9..caaffd071e88 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/databases_client.go +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/databases_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,66 +24,59 @@ import ( // DatabasesClient contains the methods for the Databases group. // Don't use this type directly, use NewDatabasesClient() instead. type DatabasesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDatabasesClient creates a new instance of DatabasesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewDatabasesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DatabasesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".DatabasesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DatabasesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Creates a new database or updates an existing database. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// databaseName - The name of the database. -// parameters - The required parameters for creating or updating a database. -// options - DatabasesClientBeginCreateOptions contains the optional parameters for the DatabasesClient.BeginCreate method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - databaseName - The name of the database. +// - parameters - The required parameters for creating or updating a database. +// - options - DatabasesClientBeginCreateOptions contains the optional parameters for the DatabasesClient.BeginCreate method. func (client *DatabasesClient) BeginCreate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database, options *DatabasesClientBeginCreateOptions) (*runtime.Poller[DatabasesClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, serverName, databaseName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[DatabasesClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DatabasesClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[DatabasesClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DatabasesClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Creates a new database or updates an existing database. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 func (client *DatabasesClient) create(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database, options *DatabasesClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, serverName, databaseName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -114,7 +105,7 @@ func (client *DatabasesClient) createCreateRequest(ctx context.Context, resource return nil, errors.New("parameter databaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -127,34 +118,36 @@ func (client *DatabasesClient) createCreateRequest(ctx context.Context, resource // BeginDelete - Deletes a database. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// databaseName - The name of the database. -// options - DatabasesClientBeginDeleteOptions contains the optional parameters for the DatabasesClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - databaseName - The name of the database. +// - options - DatabasesClientBeginDeleteOptions contains the optional parameters for the DatabasesClient.BeginDelete method. func (client *DatabasesClient) BeginDelete(ctx context.Context, resourceGroupName string, serverName string, databaseName string, options *DatabasesClientBeginDeleteOptions) (*runtime.Poller[DatabasesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, serverName, databaseName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[DatabasesClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DatabasesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[DatabasesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DatabasesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a database. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 func (client *DatabasesClient) deleteOperation(ctx context.Context, resourceGroupName string, serverName string, databaseName string, options *DatabasesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, serverName, databaseName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -183,7 +176,7 @@ func (client *DatabasesClient) deleteCreateRequest(ctx context.Context, resource return nil, errors.New("parameter databaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -196,17 +189,18 @@ func (client *DatabasesClient) deleteCreateRequest(ctx context.Context, resource // Get - Gets information about a database. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// databaseName - The name of the database. -// options - DatabasesClientGetOptions contains the optional parameters for the DatabasesClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - databaseName - The name of the database. +// - options - DatabasesClientGetOptions contains the optional parameters for the DatabasesClient.Get method. func (client *DatabasesClient) Get(ctx context.Context, resourceGroupName string, serverName string, databaseName string, options *DatabasesClientGetOptions) (DatabasesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, databaseName, options) if err != nil { return DatabasesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DatabasesClientGetResponse{}, err } @@ -235,7 +229,7 @@ func (client *DatabasesClient) getCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter databaseName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{databaseName}", url.PathEscape(databaseName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -256,10 +250,12 @@ func (client *DatabasesClient) getHandleResponse(resp *http.Response) (Databases } // NewListByServerPager - List all the databases in a given server. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - DatabasesClientListByServerOptions contains the optional parameters for the DatabasesClient.ListByServer method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - DatabasesClientListByServerOptions contains the optional parameters for the DatabasesClient.NewListByServerPager +// method. func (client *DatabasesClient) NewListByServerPager(resourceGroupName string, serverName string, options *DatabasesClientListByServerOptions) *runtime.Pager[DatabasesClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[DatabasesClientListByServerResponse]{ More: func(page DatabasesClientListByServerResponse) bool { @@ -276,7 +272,7 @@ func (client *DatabasesClient) NewListByServerPager(resourceGroupName string, se if err != nil { return DatabasesClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DatabasesClientListByServerResponse{}, err } @@ -303,7 +299,7 @@ func (client *DatabasesClient) listByServerCreateRequest(ctx context.Context, re return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/databases_client_example_test.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/databases_client_example_test.go deleted file mode 100644 index 5610cbddd8a2..000000000000 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/databases_client_example_test.go +++ /dev/null @@ -1,110 +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 armpostgresqlflexibleservers_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/postgresql/armpostgresqlflexibleservers/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/DatabaseCreate.json -func ExampleDatabasesClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewDatabasesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, "TestGroup", "testserver", "db1", armpostgresqlflexibleservers.Database{ - Properties: &armpostgresqlflexibleservers.DatabaseProperties{ - Charset: to.Ptr("utf8"), - Collation: to.Ptr("en_US.utf8"), - }, - }, 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/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/DatabaseDelete.json -func ExampleDatabasesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewDatabasesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, "TestGroup", "testserver", "db1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/DatabaseGet.json -func ExampleDatabasesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewDatabasesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "TestGroup", "testserver", "db1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/DatabasesListByServer.json -func ExampleDatabasesClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewDatabasesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("TestGroup", "testserver", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/firewallrules_client.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/firewallrules_client.go index 229690aa0f10..1812835776d2 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/firewallrules_client.go +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/firewallrules_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,67 +24,60 @@ import ( // FirewallRulesClient contains the methods for the FirewallRules group. // Don't use this type directly, use NewFirewallRulesClient() instead. type FirewallRulesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewFirewallRulesClient creates a new instance of FirewallRulesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewFirewallRulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FirewallRulesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".FirewallRulesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &FirewallRulesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates a new firewall rule or updates an existing firewall rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// firewallRuleName - The name of the server firewall rule. -// parameters - The required parameters for creating or updating a firewall rule. -// options - FirewallRulesClientBeginCreateOrUpdateOptions contains the optional parameters for the FirewallRulesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - firewallRuleName - The name of the server firewall rule. +// - parameters - The required parameters for creating or updating a firewall rule. +// - options - FirewallRulesClientBeginCreateOrUpdateOptions contains the optional parameters for the FirewallRulesClient.BeginCreateOrUpdate +// method. func (client *FirewallRulesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule, options *FirewallRulesClientBeginCreateOrUpdateOptions) (*runtime.Poller[FirewallRulesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, serverName, firewallRuleName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[FirewallRulesClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FirewallRulesClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[FirewallRulesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[FirewallRulesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates a new firewall rule or updates an existing firewall rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 func (client *FirewallRulesClient) createOrUpdate(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, parameters FirewallRule, options *FirewallRulesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serverName, firewallRuleName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -115,7 +106,7 @@ func (client *FirewallRulesClient) createOrUpdateCreateRequest(ctx context.Conte return nil, errors.New("parameter firewallRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{firewallRuleName}", url.PathEscape(firewallRuleName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -128,35 +119,37 @@ func (client *FirewallRulesClient) createOrUpdateCreateRequest(ctx context.Conte // BeginDelete - Deletes a PostgreSQL server firewall rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// firewallRuleName - The name of the server firewall rule. -// options - FirewallRulesClientBeginDeleteOptions contains the optional parameters for the FirewallRulesClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - firewallRuleName - The name of the server firewall rule. +// - options - FirewallRulesClientBeginDeleteOptions contains the optional parameters for the FirewallRulesClient.BeginDelete +// method. func (client *FirewallRulesClient) BeginDelete(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, options *FirewallRulesClientBeginDeleteOptions) (*runtime.Poller[FirewallRulesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, serverName, firewallRuleName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[FirewallRulesClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FirewallRulesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[FirewallRulesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[FirewallRulesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a PostgreSQL server firewall rule. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 func (client *FirewallRulesClient) deleteOperation(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, options *FirewallRulesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, serverName, firewallRuleName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -185,7 +178,7 @@ func (client *FirewallRulesClient) deleteCreateRequest(ctx context.Context, reso return nil, errors.New("parameter firewallRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{firewallRuleName}", url.PathEscape(firewallRuleName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -198,17 +191,18 @@ func (client *FirewallRulesClient) deleteCreateRequest(ctx context.Context, reso // Get - List all the firewall rules in a given server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// firewallRuleName - The name of the server firewall rule. -// options - FirewallRulesClientGetOptions contains the optional parameters for the FirewallRulesClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - firewallRuleName - The name of the server firewall rule. +// - options - FirewallRulesClientGetOptions contains the optional parameters for the FirewallRulesClient.Get method. func (client *FirewallRulesClient) Get(ctx context.Context, resourceGroupName string, serverName string, firewallRuleName string, options *FirewallRulesClientGetOptions) (FirewallRulesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, firewallRuleName, options) if err != nil { return FirewallRulesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FirewallRulesClientGetResponse{}, err } @@ -237,7 +231,7 @@ func (client *FirewallRulesClient) getCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter firewallRuleName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{firewallRuleName}", url.PathEscape(firewallRuleName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -258,11 +252,12 @@ func (client *FirewallRulesClient) getHandleResponse(resp *http.Response) (Firew } // NewListByServerPager - List all the firewall rules in a given PostgreSQL server. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - FirewallRulesClientListByServerOptions contains the optional parameters for the FirewallRulesClient.ListByServer -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - FirewallRulesClientListByServerOptions contains the optional parameters for the FirewallRulesClient.NewListByServerPager +// method. func (client *FirewallRulesClient) NewListByServerPager(resourceGroupName string, serverName string, options *FirewallRulesClientListByServerOptions) *runtime.Pager[FirewallRulesClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[FirewallRulesClientListByServerResponse]{ More: func(page FirewallRulesClientListByServerResponse) bool { @@ -279,7 +274,7 @@ func (client *FirewallRulesClient) NewListByServerPager(resourceGroupName string if err != nil { return FirewallRulesClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FirewallRulesClientListByServerResponse{}, err } @@ -306,7 +301,7 @@ func (client *FirewallRulesClient) listByServerCreateRequest(ctx context.Context return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/firewallrules_client_example_test.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/firewallrules_client_example_test.go deleted file mode 100644 index 6e3ebc7c0a98..000000000000 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/firewallrules_client_example_test.go +++ /dev/null @@ -1,110 +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 armpostgresqlflexibleservers_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/postgresql/armpostgresqlflexibleservers/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/FirewallRuleCreate.json -func ExampleFirewallRulesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewFirewallRulesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, "testrg", "testserver", "rule1", armpostgresqlflexibleservers.FirewallRule{ - Properties: &armpostgresqlflexibleservers.FirewallRuleProperties{ - EndIPAddress: to.Ptr("255.255.255.255"), - StartIPAddress: to.Ptr("0.0.0.0"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/FirewallRuleDelete.json -func ExampleFirewallRulesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewFirewallRulesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, "testrg", "testserver", "rule1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/FirewallRuleGet.json -func ExampleFirewallRulesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewFirewallRulesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "testrg", "testserver", "rule1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/FirewallRuleListByServer.json -func ExampleFirewallRulesClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewFirewallRulesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("testrg", "testserver", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/getprivatednszonesuffix_client.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/getprivatednszonesuffix_client.go index f813798a7e07..57fe469d7d7d 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/getprivatednszonesuffix_client.go +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/getprivatednszonesuffix_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 ( // GetPrivateDNSZoneSuffixClient contains the methods for the GetPrivateDNSZoneSuffix group. // Don't use this type directly, use NewGetPrivateDNSZoneSuffixClient() instead. type GetPrivateDNSZoneSuffixClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewGetPrivateDNSZoneSuffixClient creates a new instance of GetPrivateDNSZoneSuffixClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewGetPrivateDNSZoneSuffixClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*GetPrivateDNSZoneSuffixClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".GetPrivateDNSZoneSuffixClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &GetPrivateDNSZoneSuffixClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // Execute - Get private DNS zone suffix in the cloud // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// options - GetPrivateDNSZoneSuffixClientExecuteOptions contains the optional parameters for the GetPrivateDNSZoneSuffixClient.Execute -// method. +// - options - GetPrivateDNSZoneSuffixClientExecuteOptions contains the optional parameters for the GetPrivateDNSZoneSuffixClient.Execute +// method. func (client *GetPrivateDNSZoneSuffixClient) Execute(ctx context.Context, options *GetPrivateDNSZoneSuffixClientExecuteOptions) (GetPrivateDNSZoneSuffixClientExecuteResponse, error) { req, err := client.executeCreateRequest(ctx, options) if err != nil { return GetPrivateDNSZoneSuffixClientExecuteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GetPrivateDNSZoneSuffixClientExecuteResponse{}, err } @@ -72,7 +62,7 @@ func (client *GetPrivateDNSZoneSuffixClient) Execute(ctx context.Context, option // executeCreateRequest creates the Execute request. func (client *GetPrivateDNSZoneSuffixClient) executeCreateRequest(ctx context.Context, options *GetPrivateDNSZoneSuffixClientExecuteOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.DBforPostgreSQL/getPrivateDnsZoneSuffix" - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/getprivatednszonesuffix_client_example_test.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/getprivatednszonesuffix_client_example_test.go deleted file mode 100644 index 0ef7aa98f5e0..000000000000 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/getprivatednszonesuffix_client_example_test.go +++ /dev/null @@ -1,36 +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 armpostgresqlflexibleservers_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/GetPrivateDnsZoneSuffix.json -func ExampleGetPrivateDNSZoneSuffixClient_Execute() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewGetPrivateDNSZoneSuffixClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Execute(ctx, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/go.mod b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/go.mod index 22e4fafe7602..98a0a86941cd 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/go.mod +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/go.mod @@ -1,21 +1,13 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v2 +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v3 go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 // indirect - github.com/golang-jwt/jwt/v4 v4.4.2 // indirect - github.com/google/uuid v1.1.1 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/text v0.7.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/go.sum b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/go.sum index 8c0539b73123..f54c298864a1 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/go.sum +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/go.sum @@ -1,30 +1,15 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 h1:t/W5MYAuQy81cvM8VUNfRLzhtKpXhVUAN7Cd7KVbTyc= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0/go.mod h1:NBanQUfSWiWn3QEpWDTCU0IjBECKOYvl2R8xdRtMtiM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 h1:VgSJlZH5u0k2qxSpqyghcFQKmvYckj46uymKK5XzkBM= -github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0/go.mod h1:BDJ5qMFKx9DugEg3+uQSDCdbYPr5s9vBTrL9P8TpqOU= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 h1:+5VZ72z0Qan5Bog5C+ZkgSqUbeVUd9wgtHOrIKuc5b8= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt/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/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/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/locationbasedcapabilities_client.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/locationbasedcapabilities_client.go index 0fbc5860196c..c77a4bae4411 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/locationbasedcapabilities_client.go +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/locationbasedcapabilities_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,40 +24,32 @@ import ( // LocationBasedCapabilitiesClient contains the methods for the LocationBasedCapabilities group. // Don't use this type directly, use NewLocationBasedCapabilitiesClient() instead. type LocationBasedCapabilitiesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewLocationBasedCapabilitiesClient creates a new instance of LocationBasedCapabilitiesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewLocationBasedCapabilitiesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LocationBasedCapabilitiesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".LocationBasedCapabilitiesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &LocationBasedCapabilitiesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewExecutePager - Get capabilities at specified location in a given subscription. +// // Generated from API version 2022-12-01 -// locationName - The name of the location. -// options - LocationBasedCapabilitiesClientExecuteOptions contains the optional parameters for the LocationBasedCapabilitiesClient.Execute -// method. +// - locationName - The name of the location. +// - options - LocationBasedCapabilitiesClientExecuteOptions contains the optional parameters for the LocationBasedCapabilitiesClient.NewExecutePager +// method. func (client *LocationBasedCapabilitiesClient) NewExecutePager(locationName string, options *LocationBasedCapabilitiesClientExecuteOptions) *runtime.Pager[LocationBasedCapabilitiesClientExecuteResponse] { return runtime.NewPager(runtime.PagingHandler[LocationBasedCapabilitiesClientExecuteResponse]{ More: func(page LocationBasedCapabilitiesClientExecuteResponse) bool { @@ -76,7 +66,7 @@ func (client *LocationBasedCapabilitiesClient) NewExecutePager(locationName stri if err != nil { return LocationBasedCapabilitiesClientExecuteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LocationBasedCapabilitiesClientExecuteResponse{}, err } @@ -99,7 +89,7 @@ func (client *LocationBasedCapabilitiesClient) executeCreateRequest(ctx context. return nil, errors.New("parameter locationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/locationbasedcapabilities_client_example_test.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/locationbasedcapabilities_client_example_test.go deleted file mode 100644 index f0277d0c8419..000000000000 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/locationbasedcapabilities_client_example_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 armpostgresqlflexibleservers_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/CapabilitiesByLocation.json -func ExampleLocationBasedCapabilitiesClient_NewExecutePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewLocationBasedCapabilitiesClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewExecutePager("westus", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/models.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/models.go index 7859704b47b4..b31cec7e814b 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/models.go +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/models.go @@ -88,7 +88,8 @@ type AdministratorsClientGetOptions struct { // placeholder for future optional parameters } -// AdministratorsClientListByServerOptions contains the optional parameters for the AdministratorsClient.ListByServer method. +// AdministratorsClientListByServerOptions contains the optional parameters for the AdministratorsClient.NewListByServerPager +// method. type AdministratorsClientListByServerOptions struct { // placeholder for future optional parameters } @@ -122,7 +123,7 @@ type BackupsClientGetOptions struct { // placeholder for future optional parameters } -// BackupsClientListByServerOptions contains the optional parameters for the BackupsClient.ListByServer method. +// BackupsClientListByServerOptions contains the optional parameters for the BackupsClient.NewListByServerPager method. type BackupsClientListByServerOptions struct { // placeholder for future optional parameters } @@ -276,7 +277,8 @@ type ConfigurationsClientGetOptions struct { // placeholder for future optional parameters } -// ConfigurationsClientListByServerOptions contains the optional parameters for the ConfigurationsClient.ListByServer method. +// ConfigurationsClientListByServerOptions contains the optional parameters for the ConfigurationsClient.NewListByServerPager +// method. type ConfigurationsClientListByServerOptions struct { // placeholder for future optional parameters } @@ -289,7 +291,7 @@ type DataEncryption struct { // Resource Id for the User assigned identity to be used for data encryption for primary server. PrimaryUserAssignedIdentityID *string `json:"primaryUserAssignedIdentityId,omitempty"` - // Data encryption type to depict if it is System assigned vs Azure Key vault. + // Data encryption type to depict if it is System Managed vs Azure Key vault. Type *ArmServerKeyType `json:"type,omitempty"` } @@ -346,7 +348,7 @@ type DatabasesClientGetOptions struct { // placeholder for future optional parameters } -// DatabasesClientListByServerOptions contains the optional parameters for the DatabasesClient.ListByServer method. +// DatabasesClientListByServerOptions contains the optional parameters for the DatabasesClient.NewListByServerPager method. type DatabasesClientListByServerOptions struct { // placeholder for future optional parameters } @@ -425,7 +427,8 @@ type FirewallRulesClientGetOptions struct { // placeholder for future optional parameters } -// FirewallRulesClientListByServerOptions contains the optional parameters for the FirewallRulesClient.ListByServer method. +// FirewallRulesClientListByServerOptions contains the optional parameters for the FirewallRulesClient.NewListByServerPager +// method. type FirewallRulesClientListByServerOptions struct { // placeholder for future optional parameters } @@ -481,7 +484,7 @@ type HyperscaleNodeEditionCapability struct { SupportedStorageEditions []*StorageEditionCapability `json:"supportedStorageEditions,omitempty" azure:"ro"` } -// LocationBasedCapabilitiesClientExecuteOptions contains the optional parameters for the LocationBasedCapabilitiesClient.Execute +// LocationBasedCapabilitiesClientExecuteOptions contains the optional parameters for the LocationBasedCapabilitiesClient.NewExecutePager // method. type LocationBasedCapabilitiesClientExecuteOptions struct { // placeholder for future optional parameters @@ -559,7 +562,7 @@ type Operation struct { Origin *OperationOrigin `json:"origin,omitempty" azure:"ro"` // READ-ONLY; Additional descriptions for the operation. - Properties map[string]interface{} `json:"properties,omitempty" azure:"ro"` + Properties map[string]any `json:"properties,omitempty" azure:"ro"` } // OperationDisplay - Display metadata associated with the operation. @@ -591,7 +594,7 @@ type OperationsClientListOptions struct { // placeholder for future optional parameters } -// ReplicasClientListByServerOptions contains the optional parameters for the ReplicasClient.ListByServer method. +// ReplicasClientListByServerOptions contains the optional parameters for the ReplicasClient.NewListByServerPager method. type ReplicasClientListByServerOptions struct { // placeholder for future optional parameters } @@ -860,12 +863,13 @@ type ServersClientGetOptions struct { // placeholder for future optional parameters } -// ServersClientListByResourceGroupOptions contains the optional parameters for the ServersClient.ListByResourceGroup method. +// ServersClientListByResourceGroupOptions contains the optional parameters for the ServersClient.NewListByResourceGroupPager +// method. type ServersClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// ServersClientListOptions contains the optional parameters for the ServersClient.List method. +// ServersClientListOptions contains the optional parameters for the ServersClient.NewListPager method. type ServersClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/models_serde.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/models_serde.go index 19d78ffc9ce2..e36c2722adf7 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/models_serde.go +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/models_serde.go @@ -18,7 +18,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type ActiveDirectoryAdministrator. func (a ActiveDirectoryAdministrator) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) @@ -61,7 +61,7 @@ func (a *ActiveDirectoryAdministrator) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ActiveDirectoryAdministratorAdd. func (a ActiveDirectoryAdministratorAdd) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "properties", a.Properties) return json.Marshal(objectMap) } @@ -88,7 +88,7 @@ func (a *ActiveDirectoryAdministratorAdd) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AdministratorListResult. func (a AdministratorListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", a.NextLink) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -119,7 +119,7 @@ func (a *AdministratorListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AdministratorProperties. func (a AdministratorProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "objectId", a.ObjectID) populate(objectMap, "principalName", a.PrincipalName) populate(objectMap, "principalType", a.PrincipalType) @@ -158,7 +158,7 @@ func (a *AdministratorProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AdministratorPropertiesForAdd. func (a AdministratorPropertiesForAdd) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "principalName", a.PrincipalName) populate(objectMap, "principalType", a.PrincipalType) populate(objectMap, "tenantId", a.TenantID) @@ -193,7 +193,7 @@ func (a *AdministratorPropertiesForAdd) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AuthConfig. func (a AuthConfig) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "activeDirectoryAuth", a.ActiveDirectoryAuth) populate(objectMap, "passwordAuth", a.PasswordAuth) populate(objectMap, "tenantId", a.TenantID) @@ -228,7 +228,7 @@ func (a *AuthConfig) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Backup. func (b Backup) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "backupRetentionDays", b.BackupRetentionDays) populateTimeRFC3339(objectMap, "earliestRestoreDate", b.EarliestRestoreDate) populate(objectMap, "geoRedundantBackup", b.GeoRedundantBackup) @@ -263,7 +263,7 @@ func (b *Backup) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CapabilitiesListResult. func (c CapabilitiesListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -294,7 +294,7 @@ func (c *CapabilitiesListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CapabilityProperties. func (c CapabilityProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "fastProvisioningSupported", c.FastProvisioningSupported) populate(objectMap, "geoBackupSupported", c.GeoBackupSupported) populate(objectMap, "status", c.Status) @@ -357,7 +357,7 @@ func (c *CapabilityProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityRequest. func (c CheckNameAvailabilityRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", c.Name) populate(objectMap, "type", c.Type) return json.Marshal(objectMap) @@ -388,7 +388,7 @@ func (c *CheckNameAvailabilityRequest) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Configuration. func (c Configuration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", c.ID) populate(objectMap, "name", c.Name) populate(objectMap, "properties", c.Properties) @@ -431,7 +431,7 @@ func (c *Configuration) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConfigurationForUpdate. func (c ConfigurationForUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "properties", c.Properties) return json.Marshal(objectMap) } @@ -458,7 +458,7 @@ func (c *ConfigurationForUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConfigurationListResult. func (c ConfigurationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -489,7 +489,7 @@ func (c *ConfigurationListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ConfigurationProperties. func (c ConfigurationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allowedValues", c.AllowedValues) populate(objectMap, "dataType", c.DataType) populate(objectMap, "defaultValue", c.DefaultValue) @@ -556,7 +556,7 @@ func (c *ConfigurationProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DataEncryption. func (d DataEncryption) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "primaryKeyURI", d.PrimaryKeyURI) populate(objectMap, "primaryUserAssignedIdentityId", d.PrimaryUserAssignedIdentityID) populate(objectMap, "type", d.Type) @@ -591,7 +591,7 @@ func (d *DataEncryption) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Database. func (d Database) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", d.ID) populate(objectMap, "name", d.Name) populate(objectMap, "properties", d.Properties) @@ -634,7 +634,7 @@ func (d *Database) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DatabaseListResult. func (d DatabaseListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", d.NextLink) populate(objectMap, "value", d.Value) return json.Marshal(objectMap) @@ -665,7 +665,7 @@ func (d *DatabaseListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DatabaseProperties. func (d DatabaseProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "charset", d.Charset) populate(objectMap, "collation", d.Collation) return json.Marshal(objectMap) @@ -696,7 +696,7 @@ func (d *DatabaseProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DelegatedSubnetUsage. func (d DelegatedSubnetUsage) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "subnetName", d.SubnetName) populate(objectMap, "usage", d.Usage) return json.Marshal(objectMap) @@ -727,7 +727,7 @@ func (d *DelegatedSubnetUsage) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FastProvisioningEditionCapability. func (f FastProvisioningEditionCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "supportedSku", f.SupportedSKU) populate(objectMap, "supportedServerVersions", f.SupportedServerVersions) populate(objectMap, "supportedStorageGb", f.SupportedStorageGb) @@ -762,7 +762,7 @@ func (f *FastProvisioningEditionCapability) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FirewallRule. func (f FirewallRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", f.ID) populate(objectMap, "name", f.Name) populate(objectMap, "properties", f.Properties) @@ -805,7 +805,7 @@ func (f *FirewallRule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FirewallRuleListResult. func (f FirewallRuleListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", f.NextLink) populate(objectMap, "value", f.Value) return json.Marshal(objectMap) @@ -836,7 +836,7 @@ func (f *FirewallRuleListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FirewallRuleProperties. func (f FirewallRuleProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "endIpAddress", f.EndIPAddress) populate(objectMap, "startIpAddress", f.StartIPAddress) return json.Marshal(objectMap) @@ -867,7 +867,7 @@ func (f *FirewallRuleProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FlexibleServerEditionCapability. func (f FlexibleServerEditionCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", f.Name) populate(objectMap, "status", f.Status) populate(objectMap, "supportedServerVersions", f.SupportedServerVersions) @@ -906,7 +906,7 @@ func (f *FlexibleServerEditionCapability) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HighAvailability. func (h HighAvailability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "mode", h.Mode) populate(objectMap, "standbyAvailabilityZone", h.StandbyAvailabilityZone) populate(objectMap, "state", h.State) @@ -941,7 +941,7 @@ func (h *HighAvailability) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HyperscaleNodeEditionCapability. func (h HyperscaleNodeEditionCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", h.Name) populate(objectMap, "status", h.Status) populate(objectMap, "supportedNodeTypes", h.SupportedNodeTypes) @@ -984,7 +984,7 @@ func (h *HyperscaleNodeEditionCapability) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MaintenanceWindow. func (m MaintenanceWindow) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "customWindow", m.CustomWindow) populate(objectMap, "dayOfWeek", m.DayOfWeek) populate(objectMap, "startHour", m.StartHour) @@ -1023,7 +1023,7 @@ func (m *MaintenanceWindow) UnmarshalJSON(data []byte) error { // 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) @@ -1066,7 +1066,7 @@ func (n *NameAvailability) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Network. func (n Network) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "delegatedSubnetResourceId", n.DelegatedSubnetResourceID) populate(objectMap, "privateDnsZoneArmResourceId", n.PrivateDNSZoneArmResourceID) populate(objectMap, "publicNetworkAccess", n.PublicNetworkAccess) @@ -1101,7 +1101,7 @@ func (n *Network) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type NodeTypeCapability. func (n NodeTypeCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", n.Name) populate(objectMap, "nodeType", n.NodeType) populate(objectMap, "status", n.Status) @@ -1136,7 +1136,7 @@ func (n *NodeTypeCapability) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Operation. func (o Operation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "display", o.Display) populate(objectMap, "isDataAction", o.IsDataAction) populate(objectMap, "name", o.Name) @@ -1179,7 +1179,7 @@ func (o *Operation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationDisplay. func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", o.Description) populate(objectMap, "operation", o.Operation) populate(objectMap, "provider", o.Provider) @@ -1218,7 +1218,7 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationListResult. func (o OperationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", o.NextLink) populate(objectMap, "value", o.Value) return json.Marshal(objectMap) @@ -1249,7 +1249,7 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RestartParameter. func (r RestartParameter) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "failoverMode", r.FailoverMode) populate(objectMap, "restartWithFailover", r.RestartWithFailover) return json.Marshal(objectMap) @@ -1280,7 +1280,7 @@ func (r *RestartParameter) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SKU. func (s SKU) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", s.Name) populate(objectMap, "tier", s.Tier) return json.Marshal(objectMap) @@ -1311,7 +1311,7 @@ func (s *SKU) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Server. func (s Server) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "identity", s.Identity) populate(objectMap, "location", s.Location) @@ -1370,7 +1370,7 @@ func (s *Server) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServerBackup. func (s ServerBackup) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) @@ -1413,7 +1413,7 @@ func (s *ServerBackup) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServerBackupListResult. func (s ServerBackupListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -1444,7 +1444,7 @@ func (s *ServerBackupListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServerBackupProperties. func (s ServerBackupProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "backupType", s.BackupType) populateTimeRFC3339(objectMap, "completedTime", s.CompletedTime) populate(objectMap, "source", s.Source) @@ -1479,7 +1479,7 @@ func (s *ServerBackupProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServerForUpdate. func (s ServerForUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "identity", s.Identity) populate(objectMap, "properties", s.Properties) populate(objectMap, "sku", s.SKU) @@ -1518,7 +1518,7 @@ func (s *ServerForUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServerListResult. func (s ServerListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -1549,7 +1549,7 @@ func (s *ServerListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServerProperties. func (s ServerProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "administratorLogin", s.AdministratorLogin) populate(objectMap, "administratorLoginPassword", s.AdministratorLoginPassword) populate(objectMap, "authConfig", s.AuthConfig) @@ -1648,7 +1648,7 @@ func (s *ServerProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServerPropertiesForUpdate. func (s ServerPropertiesForUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "administratorLoginPassword", s.AdministratorLoginPassword) populate(objectMap, "authConfig", s.AuthConfig) populate(objectMap, "backup", s.Backup) @@ -1711,7 +1711,7 @@ func (s *ServerPropertiesForUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServerVersionCapability. func (s ServerVersionCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", s.Name) populate(objectMap, "status", s.Status) populate(objectMap, "supportedVcores", s.SupportedVcores) @@ -1750,7 +1750,7 @@ func (s *ServerVersionCapability) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Storage. func (s Storage) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "storageSizeGB", s.StorageSizeGB) return json.Marshal(objectMap) } @@ -1777,7 +1777,7 @@ func (s *Storage) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StorageEditionCapability. func (s StorageEditionCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", s.Name) populate(objectMap, "status", s.Status) populate(objectMap, "supportedStorageMB", s.SupportedStorageMB) @@ -1812,7 +1812,7 @@ func (s *StorageEditionCapability) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StorageMBCapability. func (s StorageMBCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", s.Name) populate(objectMap, "status", s.Status) populate(objectMap, "storageSizeMB", s.StorageSizeMB) @@ -1855,7 +1855,7 @@ func (s *StorageMBCapability) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StorageTierCapability. func (s StorageTierCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "iops", s.Iops) populate(objectMap, "isBaseline", s.IsBaseline) populate(objectMap, "name", s.Name) @@ -1898,7 +1898,7 @@ func (s *StorageTierCapability) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) @@ -1945,7 +1945,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentity. func (u UserAssignedIdentity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "type", u.Type) populate(objectMap, "userAssignedIdentities", u.UserAssignedIdentities) return json.Marshal(objectMap) @@ -1976,7 +1976,7 @@ func (u *UserAssignedIdentity) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UserIdentity. func (u UserIdentity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "clientId", u.ClientID) populate(objectMap, "principalId", u.PrincipalID) return json.Marshal(objectMap) @@ -2007,7 +2007,7 @@ func (u *UserIdentity) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VcoreCapability. func (v VcoreCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", v.Name) populate(objectMap, "status", v.Status) populate(objectMap, "supportedIops", v.SupportedIops) @@ -2050,7 +2050,7 @@ func (v *VcoreCapability) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualNetworkSubnetUsageParameter. func (v VirtualNetworkSubnetUsageParameter) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "virtualNetworkArmResourceId", v.VirtualNetworkArmResourceID) return json.Marshal(objectMap) } @@ -2077,7 +2077,7 @@ func (v *VirtualNetworkSubnetUsageParameter) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualNetworkSubnetUsageResult. func (v VirtualNetworkSubnetUsageResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "delegatedSubnetsUsage", v.DelegatedSubnetsUsage) populate(objectMap, "location", v.Location) populate(objectMap, "subscriptionId", v.SubscriptionID) @@ -2110,7 +2110,7 @@ func (v *VirtualNetworkSubnetUsageResult) 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) { @@ -2120,7 +2120,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/postgresql/armpostgresqlflexibleservers/operations_client.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/operations_client.go index 67b1b17c2403..811a46807c91 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/operations_client.go +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/operations_client.go @@ -13,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -23,42 +21,34 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // List - Lists all of the available REST API operations. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. func (client *OperationsClient) List(ctx context.Context, options *OperationsClientListOptions) (OperationsClientListResponse, error) { req, err := client.listCreateRequest(ctx, options) if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -71,7 +61,7 @@ func (client *OperationsClient) List(ctx context.Context, options *OperationsCli // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.DBforPostgreSQL/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/postgresql/armpostgresqlflexibleservers/operations_client_example_test.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/operations_client_example_test.go deleted file mode 100644 index 0142454d2f58..000000000000 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/operations_client_example_test.go +++ /dev/null @@ -1,36 +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 armpostgresqlflexibleservers_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/OperationList.json -func ExampleOperationsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.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/postgresql/armpostgresqlflexibleservers/replicas_client.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/replicas_client.go index e31bd22cc134..4cc82cd21eb4 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/replicas_client.go +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/replicas_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,40 +24,33 @@ import ( // ReplicasClient contains the methods for the Replicas group. // Don't use this type directly, use NewReplicasClient() instead. type ReplicasClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewReplicasClient creates a new instance of ReplicasClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewReplicasClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ReplicasClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ReplicasClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ReplicasClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListByServerPager - List all the replicas for a given server. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ReplicasClientListByServerOptions contains the optional parameters for the ReplicasClient.ListByServer method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ReplicasClientListByServerOptions contains the optional parameters for the ReplicasClient.NewListByServerPager +// method. func (client *ReplicasClient) NewListByServerPager(resourceGroupName string, serverName string, options *ReplicasClientListByServerOptions) *runtime.Pager[ReplicasClientListByServerResponse] { return runtime.NewPager(runtime.PagingHandler[ReplicasClientListByServerResponse]{ More: func(page ReplicasClientListByServerResponse) bool { @@ -70,7 +61,7 @@ func (client *ReplicasClient) NewListByServerPager(resourceGroupName string, ser if err != nil { return ReplicasClientListByServerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ReplicasClientListByServerResponse{}, err } @@ -97,7 +88,7 @@ func (client *ReplicasClient) listByServerCreateRequest(ctx context.Context, res return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/replicas_client_example_test.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/replicas_client_example_test.go deleted file mode 100644 index 1fcef7057aba..000000000000 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/replicas_client_example_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 armpostgresqlflexibleservers_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ReplicasListByServer.json -func ExampleReplicasClient_NewListByServerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewReplicasClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByServerPager("testrg", "sourcepgservername", 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/postgresql/armpostgresqlflexibleservers/response_types.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/response_types.go index 06f781d6d9c0..edfa2bd4886d 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/response_types.go +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/response_types.go @@ -9,12 +9,12 @@ package armpostgresqlflexibleservers -// AdministratorsClientCreateResponse contains the response from method AdministratorsClient.Create. +// AdministratorsClientCreateResponse contains the response from method AdministratorsClient.BeginCreate. type AdministratorsClientCreateResponse struct { ActiveDirectoryAdministrator } -// AdministratorsClientDeleteResponse contains the response from method AdministratorsClient.Delete. +// AdministratorsClientDeleteResponse contains the response from method AdministratorsClient.BeginDelete. type AdministratorsClientDeleteResponse struct { // placeholder for future response values } @@ -24,7 +24,7 @@ type AdministratorsClientGetResponse struct { ActiveDirectoryAdministrator } -// AdministratorsClientListByServerResponse contains the response from method AdministratorsClient.ListByServer. +// AdministratorsClientListByServerResponse contains the response from method AdministratorsClient.NewListByServerPager. type AdministratorsClientListByServerResponse struct { AdministratorListResult } @@ -34,7 +34,7 @@ type BackupsClientGetResponse struct { ServerBackup } -// BackupsClientListByServerResponse contains the response from method BackupsClient.ListByServer. +// BackupsClientListByServerResponse contains the response from method BackupsClient.NewListByServerPager. type BackupsClientListByServerResponse struct { ServerBackupListResult } @@ -54,27 +54,27 @@ type ConfigurationsClientGetResponse struct { Configuration } -// ConfigurationsClientListByServerResponse contains the response from method ConfigurationsClient.ListByServer. +// ConfigurationsClientListByServerResponse contains the response from method ConfigurationsClient.NewListByServerPager. type ConfigurationsClientListByServerResponse struct { ConfigurationListResult } -// ConfigurationsClientPutResponse contains the response from method ConfigurationsClient.Put. +// ConfigurationsClientPutResponse contains the response from method ConfigurationsClient.BeginPut. type ConfigurationsClientPutResponse struct { Configuration } -// ConfigurationsClientUpdateResponse contains the response from method ConfigurationsClient.Update. +// ConfigurationsClientUpdateResponse contains the response from method ConfigurationsClient.BeginUpdate. type ConfigurationsClientUpdateResponse struct { Configuration } -// DatabasesClientCreateResponse contains the response from method DatabasesClient.Create. +// DatabasesClientCreateResponse contains the response from method DatabasesClient.BeginCreate. type DatabasesClientCreateResponse struct { Database } -// DatabasesClientDeleteResponse contains the response from method DatabasesClient.Delete. +// DatabasesClientDeleteResponse contains the response from method DatabasesClient.BeginDelete. type DatabasesClientDeleteResponse struct { // placeholder for future response values } @@ -84,17 +84,17 @@ type DatabasesClientGetResponse struct { Database } -// DatabasesClientListByServerResponse contains the response from method DatabasesClient.ListByServer. +// DatabasesClientListByServerResponse contains the response from method DatabasesClient.NewListByServerPager. type DatabasesClientListByServerResponse struct { DatabaseListResult } -// FirewallRulesClientCreateOrUpdateResponse contains the response from method FirewallRulesClient.CreateOrUpdate. +// FirewallRulesClientCreateOrUpdateResponse contains the response from method FirewallRulesClient.BeginCreateOrUpdate. type FirewallRulesClientCreateOrUpdateResponse struct { FirewallRule } -// FirewallRulesClientDeleteResponse contains the response from method FirewallRulesClient.Delete. +// FirewallRulesClientDeleteResponse contains the response from method FirewallRulesClient.BeginDelete. type FirewallRulesClientDeleteResponse struct { // placeholder for future response values } @@ -104,7 +104,7 @@ type FirewallRulesClientGetResponse struct { FirewallRule } -// FirewallRulesClientListByServerResponse contains the response from method FirewallRulesClient.ListByServer. +// FirewallRulesClientListByServerResponse contains the response from method FirewallRulesClient.NewListByServerPager. type FirewallRulesClientListByServerResponse struct { FirewallRuleListResult } @@ -115,7 +115,7 @@ type GetPrivateDNSZoneSuffixClientExecuteResponse struct { Value *string } -// LocationBasedCapabilitiesClientExecuteResponse contains the response from method LocationBasedCapabilitiesClient.Execute. +// LocationBasedCapabilitiesClientExecuteResponse contains the response from method LocationBasedCapabilitiesClient.NewExecutePager. type LocationBasedCapabilitiesClientExecuteResponse struct { CapabilitiesListResult } @@ -125,17 +125,17 @@ type OperationsClientListResponse struct { OperationListResult } -// ReplicasClientListByServerResponse contains the response from method ReplicasClient.ListByServer. +// ReplicasClientListByServerResponse contains the response from method ReplicasClient.NewListByServerPager. type ReplicasClientListByServerResponse struct { ServerListResult } -// ServersClientCreateResponse contains the response from method ServersClient.Create. +// ServersClientCreateResponse contains the response from method ServersClient.BeginCreate. type ServersClientCreateResponse struct { Server } -// ServersClientDeleteResponse contains the response from method ServersClient.Delete. +// ServersClientDeleteResponse contains the response from method ServersClient.BeginDelete. type ServersClientDeleteResponse struct { // placeholder for future response values } @@ -145,32 +145,32 @@ type ServersClientGetResponse struct { Server } -// ServersClientListByResourceGroupResponse contains the response from method ServersClient.ListByResourceGroup. +// ServersClientListByResourceGroupResponse contains the response from method ServersClient.NewListByResourceGroupPager. type ServersClientListByResourceGroupResponse struct { ServerListResult } -// ServersClientListResponse contains the response from method ServersClient.List. +// ServersClientListResponse contains the response from method ServersClient.NewListPager. type ServersClientListResponse struct { ServerListResult } -// ServersClientRestartResponse contains the response from method ServersClient.Restart. +// ServersClientRestartResponse contains the response from method ServersClient.BeginRestart. type ServersClientRestartResponse struct { // placeholder for future response values } -// ServersClientStartResponse contains the response from method ServersClient.Start. +// ServersClientStartResponse contains the response from method ServersClient.BeginStart. type ServersClientStartResponse struct { // placeholder for future response values } -// ServersClientStopResponse contains the response from method ServersClient.Stop. +// ServersClientStopResponse contains the response from method ServersClient.BeginStop. type ServersClientStopResponse struct { // placeholder for future response values } -// ServersClientUpdateResponse contains the response from method ServersClient.Update. +// ServersClientUpdateResponse contains the response from method ServersClient.BeginUpdate. type ServersClientUpdateResponse struct { Server } diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/servers_client.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/servers_client.go index bc1f1267467c..10cebbf5eebe 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/servers_client.go +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/servers_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,65 +24,58 @@ import ( // ServersClient contains the methods for the Servers group. // Don't use this type directly, use NewServersClient() instead. type ServersClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewServersClient creates a new instance of ServersClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewServersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServersClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ServersClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ServersClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Creates a new server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// parameters - The required parameters for creating or updating a server. -// options - ServersClientBeginCreateOptions contains the optional parameters for the ServersClient.BeginCreate method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - parameters - The required parameters for creating or updating a server. +// - options - ServersClientBeginCreateOptions contains the optional parameters for the ServersClient.BeginCreate method. func (client *ServersClient) BeginCreate(ctx context.Context, resourceGroupName string, serverName string, parameters Server, options *ServersClientBeginCreateOptions) (*runtime.Poller[ServersClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, serverName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ServersClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ServersClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[ServersClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Creates a new server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 func (client *ServersClient) create(ctx context.Context, resourceGroupName string, serverName string, parameters Server, options *ServersClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, serverName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -109,7 +100,7 @@ func (client *ServersClient) createCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -122,33 +113,35 @@ func (client *ServersClient) createCreateRequest(ctx context.Context, resourceGr // BeginDelete - Deletes a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServersClientBeginDeleteOptions contains the optional parameters for the ServersClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServersClientBeginDeleteOptions contains the optional parameters for the ServersClient.BeginDelete method. func (client *ServersClient) BeginDelete(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginDeleteOptions) (*runtime.Poller[ServersClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ServersClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ServersClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[ServersClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 func (client *ServersClient) deleteOperation(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -173,7 +166,7 @@ func (client *ServersClient) deleteCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -186,16 +179,17 @@ func (client *ServersClient) deleteCreateRequest(ctx context.Context, resourceGr // Get - Gets information about a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServersClientGetOptions contains the optional parameters for the ServersClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServersClientGetOptions contains the optional parameters for the ServersClient.Get method. func (client *ServersClient) Get(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientGetOptions) (ServersClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { return ServersClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServersClientGetResponse{}, err } @@ -220,7 +214,7 @@ func (client *ServersClient) getCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -241,8 +235,9 @@ func (client *ServersClient) getHandleResponse(resp *http.Response) (ServersClie } // NewListPager - List all the servers in a given subscription. +// // Generated from API version 2022-12-01 -// options - ServersClientListOptions contains the optional parameters for the ServersClient.List method. +// - options - ServersClientListOptions contains the optional parameters for the ServersClient.NewListPager method. func (client *ServersClient) NewListPager(options *ServersClientListOptions) *runtime.Pager[ServersClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ServersClientListResponse]{ More: func(page ServersClientListResponse) bool { @@ -259,7 +254,7 @@ func (client *ServersClient) NewListPager(options *ServersClientListOptions) *ru if err != nil { return ServersClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServersClientListResponse{}, err } @@ -278,7 +273,7 @@ func (client *ServersClient) listCreateRequest(ctx context.Context, options *Ser return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -299,10 +294,11 @@ func (client *ServersClient) listHandleResponse(resp *http.Response) (ServersCli } // NewListByResourceGroupPager - List all the servers in a given resource group. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - ServersClientListByResourceGroupOptions contains the optional parameters for the ServersClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ServersClientListByResourceGroupOptions contains the optional parameters for the ServersClient.NewListByResourceGroupPager +// method. func (client *ServersClient) NewListByResourceGroupPager(resourceGroupName string, options *ServersClientListByResourceGroupOptions) *runtime.Pager[ServersClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[ServersClientListByResourceGroupResponse]{ More: func(page ServersClientListByResourceGroupResponse) bool { @@ -319,7 +315,7 @@ func (client *ServersClient) NewListByResourceGroupPager(resourceGroupName strin if err != nil { return ServersClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServersClientListByResourceGroupResponse{}, err } @@ -342,7 +338,7 @@ func (client *ServersClient) listByResourceGroupCreateRequest(ctx context.Contex return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -364,33 +360,35 @@ func (client *ServersClient) listByResourceGroupHandleResponse(resp *http.Respon // BeginRestart - Restarts a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServersClientBeginRestartOptions contains the optional parameters for the ServersClient.BeginRestart method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServersClientBeginRestartOptions contains the optional parameters for the ServersClient.BeginRestart method. func (client *ServersClient) BeginRestart(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginRestartOptions) (*runtime.Poller[ServersClientRestartResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.restart(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ServersClientRestartResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ServersClientRestartResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[ServersClientRestartResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientRestartResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Restart - Restarts a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 func (client *ServersClient) restart(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginRestartOptions) (*http.Response, error) { req, err := client.restartCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -415,7 +413,7 @@ func (client *ServersClient) restartCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -431,33 +429,35 @@ func (client *ServersClient) restartCreateRequest(ctx context.Context, resourceG // BeginStart - Starts a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServersClientBeginStartOptions contains the optional parameters for the ServersClient.BeginStart method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServersClientBeginStartOptions contains the optional parameters for the ServersClient.BeginStart method. func (client *ServersClient) BeginStart(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginStartOptions) (*runtime.Poller[ServersClientStartResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.start(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ServersClientStartResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ServersClientStartResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[ServersClientStartResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientStartResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Start - Starts a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 func (client *ServersClient) start(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginStartOptions) (*http.Response, error) { req, err := client.startCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -482,7 +482,7 @@ func (client *ServersClient) startCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -495,33 +495,35 @@ func (client *ServersClient) startCreateRequest(ctx context.Context, resourceGro // BeginStop - Stops a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// options - ServersClientBeginStopOptions contains the optional parameters for the ServersClient.BeginStop method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - ServersClientBeginStopOptions contains the optional parameters for the ServersClient.BeginStop method. func (client *ServersClient) BeginStop(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginStopOptions) (*runtime.Poller[ServersClientStopResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.stop(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ServersClientStopResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ServersClientStopResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) } else { - return runtime.NewPollerFromResumeToken[ServersClientStopResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientStopResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Stop - Stops a server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 func (client *ServersClient) stop(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginStopOptions) (*http.Response, error) { req, err := client.stopCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -546,7 +548,7 @@ func (client *ServersClient) stopCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -560,35 +562,37 @@ func (client *ServersClient) stopCreateRequest(ctx context.Context, resourceGrou // BeginUpdate - Updates an existing server. The request body can contain one to many of the properties present in the normal // server definition. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// resourceGroupName - The name of the resource group. The name is case insensitive. -// serverName - The name of the server. -// parameters - The required parameters for updating a server. -// options - ServersClientBeginUpdateOptions contains the optional parameters for the ServersClient.BeginUpdate method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - parameters - The required parameters for updating a server. +// - options - ServersClientBeginUpdateOptions contains the optional parameters for the ServersClient.BeginUpdate method. func (client *ServersClient) BeginUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ServerForUpdate, options *ServersClientBeginUpdateOptions) (*runtime.Poller[ServersClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, serverName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ServersClientUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ServersClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[ServersClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ServersClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates an existing server. The request body can contain one to many of the properties present in the normal server // definition. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 func (client *ServersClient) update(ctx context.Context, resourceGroupName string, serverName string, parameters ServerForUpdate, options *ServersClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, serverName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -613,7 +617,7 @@ func (client *ServersClient) updateCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter serverName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/servers_client_example_test.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/servers_client_example_test.go deleted file mode 100644 index 0bd2e76256f5..000000000000 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/servers_client_example_test.go +++ /dev/null @@ -1,674 +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 armpostgresqlflexibleservers_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerCreateGeoRestore.json -func ExampleServersClient_BeginCreate_createADatabaseAsAGeoRestoreInGeoPairedLocation() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, "testrg", "pgtestsvc5geo", armpostgresqlflexibleservers.Server{ - Location: to.Ptr("eastus"), - Properties: &armpostgresqlflexibleservers.ServerProperties{ - CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeGeoRestore), - PointInTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-27T00:04:59.4078005+00:00"); return t }()), - SourceServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/sourcepgservername"), - }, - }, 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/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerCreatePointInTimeRestore.json -func ExampleServersClient_BeginCreate_createADatabaseAsAPointInTimeRestore() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, "testrg", "pgtestsvc5", armpostgresqlflexibleservers.Server{ - Location: to.Ptr("westus"), - Properties: &armpostgresqlflexibleservers.ServerProperties{ - CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModePointInTimeRestore), - PointInTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-27T00:04:59.4078005+00:00"); return t }()), - SourceServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/sourcepgservername"), - }, - }, 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/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerCreate.json -func ExampleServersClient_BeginCreate_createANewServer() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, "testrg", "pgtestsvc4", armpostgresqlflexibleservers.Server{ - Location: to.Ptr("westus"), - Tags: map[string]*string{ - "ElasticServer": to.Ptr("1"), - }, - Properties: &armpostgresqlflexibleservers.ServerProperties{ - AdministratorLogin: to.Ptr("cloudsa"), - AdministratorLoginPassword: to.Ptr("password"), - AvailabilityZone: to.Ptr("1"), - Backup: &armpostgresqlflexibleservers.Backup{ - BackupRetentionDays: to.Ptr[int32](7), - GeoRedundantBackup: to.Ptr(armpostgresqlflexibleservers.GeoRedundantBackupEnumDisabled), - }, - CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeCreate), - HighAvailability: &armpostgresqlflexibleservers.HighAvailability{ - Mode: to.Ptr(armpostgresqlflexibleservers.HighAvailabilityModeZoneRedundant), - }, - Network: &armpostgresqlflexibleservers.Network{ - DelegatedSubnetResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-vnet-subnet"), - PrivateDNSZoneArmResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/testrg/providers/Microsoft.Network/privateDnsZones/test-private-dns-zone.postgres.database.azure.com"), - }, - Storage: &armpostgresqlflexibleservers.Storage{ - StorageSizeGB: to.Ptr[int32](512), - }, - Version: to.Ptr(armpostgresqlflexibleservers.ServerVersionTwelve), - }, - SKU: &armpostgresqlflexibleservers.SKU{ - Name: to.Ptr("Standard_D4s_v3"), - Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerCreateWithAadAuthEnabled.json -func ExampleServersClient_BeginCreate_createANewServerWithActiveDirectoryAuthenticationEnabled() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, "testrg", "pgtestsvc4", armpostgresqlflexibleservers.Server{ - Location: to.Ptr("westus"), - Tags: map[string]*string{ - "ElasticServer": to.Ptr("1"), - }, - Properties: &armpostgresqlflexibleservers.ServerProperties{ - AdministratorLogin: to.Ptr("cloudsa"), - AdministratorLoginPassword: to.Ptr("password"), - AuthConfig: &armpostgresqlflexibleservers.AuthConfig{ - ActiveDirectoryAuth: to.Ptr(armpostgresqlflexibleservers.ActiveDirectoryAuthEnumEnabled), - PasswordAuth: to.Ptr(armpostgresqlflexibleservers.PasswordAuthEnumEnabled), - TenantID: to.Ptr("tttttt-tttt-tttt-tttt-tttttttttttt"), - }, - AvailabilityZone: to.Ptr("1"), - Backup: &armpostgresqlflexibleservers.Backup{ - BackupRetentionDays: to.Ptr[int32](7), - GeoRedundantBackup: to.Ptr(armpostgresqlflexibleservers.GeoRedundantBackupEnumDisabled), - }, - CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeCreate), - DataEncryption: &armpostgresqlflexibleservers.DataEncryption{ - Type: to.Ptr(armpostgresqlflexibleservers.ArmServerKeyType("SystemManaged")), - }, - HighAvailability: &armpostgresqlflexibleservers.HighAvailability{ - Mode: to.Ptr(armpostgresqlflexibleservers.HighAvailabilityModeZoneRedundant), - }, - Network: &armpostgresqlflexibleservers.Network{ - DelegatedSubnetResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-vnet-subnet"), - PrivateDNSZoneArmResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/testrg/providers/Microsoft.Network/privateDnsZones/test-private-dns-zone.postgres.database.azure.com"), - }, - Storage: &armpostgresqlflexibleservers.Storage{ - StorageSizeGB: to.Ptr[int32](512), - }, - Version: to.Ptr(armpostgresqlflexibleservers.ServerVersionTwelve), - }, - SKU: &armpostgresqlflexibleservers.SKU{ - Name: to.Ptr("Standard_D4s_v3"), - Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerCreateReplica.json -func ExampleServersClient_BeginCreate_serverCreateReplica() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, "testrg", "pgtestsvc5rep", armpostgresqlflexibleservers.Server{ - Location: to.Ptr("westus"), - Properties: &armpostgresqlflexibleservers.ServerProperties{ - CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeReplica), - PointInTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-27T00:04:59.4078005+00:00"); return t }()), - SourceServerResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforPostgreSQL/flexibleServers/sourcepgservername"), - }, - }, 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/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerCreateWithDataEncryptionEnabled.json -func ExampleServersClient_BeginCreate_serverCreateWithDataEncryptionEnabled() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, "testrg", "pgtestsvc4", armpostgresqlflexibleservers.Server{ - Location: to.Ptr("westus"), - Tags: map[string]*string{ - "ElasticServer": to.Ptr("1"), - }, - Identity: &armpostgresqlflexibleservers.UserAssignedIdentity{ - Type: to.Ptr(armpostgresqlflexibleservers.IdentityTypeUserAssigned), - UserAssignedIdentities: map[string]*armpostgresqlflexibleservers.UserIdentity{ - "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity": {}, - }, - }, - Properties: &armpostgresqlflexibleservers.ServerProperties{ - AdministratorLogin: to.Ptr("cloudsa"), - AdministratorLoginPassword: to.Ptr("password"), - AvailabilityZone: to.Ptr("1"), - Backup: &armpostgresqlflexibleservers.Backup{ - BackupRetentionDays: to.Ptr[int32](7), - GeoRedundantBackup: to.Ptr(armpostgresqlflexibleservers.GeoRedundantBackupEnumDisabled), - }, - CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeCreate), - DataEncryption: &armpostgresqlflexibleservers.DataEncryption{ - Type: to.Ptr(armpostgresqlflexibleservers.ArmServerKeyTypeAzureKeyVault), - PrimaryKeyURI: to.Ptr("https://test-kv.vault.azure.net/keys/test-key1/77f57315bab34b0189daa113fbc78787"), - PrimaryUserAssignedIdentityID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"), - }, - HighAvailability: &armpostgresqlflexibleservers.HighAvailability{ - Mode: to.Ptr(armpostgresqlflexibleservers.HighAvailabilityModeZoneRedundant), - }, - Network: &armpostgresqlflexibleservers.Network{ - DelegatedSubnetResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-vnet-subnet"), - PrivateDNSZoneArmResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/testrg/providers/Microsoft.Network/privateDnsZones/test-private-dns-zone.postgres.database.azure.com"), - }, - Storage: &armpostgresqlflexibleservers.Storage{ - StorageSizeGB: to.Ptr[int32](512), - }, - Version: to.Ptr(armpostgresqlflexibleservers.ServerVersionTwelve), - }, - SKU: &armpostgresqlflexibleservers.SKU{ - Name: to.Ptr("Standard_D4s_v3"), - Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerUpdate.json -func ExampleServersClient_BeginUpdate_serverUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, "TestGroup", "pgtestsvc4", armpostgresqlflexibleservers.ServerForUpdate{ - Properties: &armpostgresqlflexibleservers.ServerPropertiesForUpdate{ - AdministratorLoginPassword: to.Ptr("newpassword"), - Backup: &armpostgresqlflexibleservers.Backup{ - BackupRetentionDays: to.Ptr[int32](20), - }, - CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeForUpdateUpdate), - Storage: &armpostgresqlflexibleservers.Storage{ - StorageSizeGB: to.Ptr[int32](1024), - }, - }, - SKU: &armpostgresqlflexibleservers.SKU{ - Name: to.Ptr("Standard_D8s_v3"), - Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerUpdateWithAadAuthEnabled.json -func ExampleServersClient_BeginUpdate_serverUpdateWithAadAuthEnabled() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, "TestGroup", "pgtestsvc4", armpostgresqlflexibleservers.ServerForUpdate{ - Properties: &armpostgresqlflexibleservers.ServerPropertiesForUpdate{ - AdministratorLoginPassword: to.Ptr("newpassword"), - AuthConfig: &armpostgresqlflexibleservers.AuthConfig{ - ActiveDirectoryAuth: to.Ptr(armpostgresqlflexibleservers.ActiveDirectoryAuthEnumEnabled), - PasswordAuth: to.Ptr(armpostgresqlflexibleservers.PasswordAuthEnumEnabled), - TenantID: to.Ptr("tttttt-tttt-tttt-tttt-tttttttttttt"), - }, - Backup: &armpostgresqlflexibleservers.Backup{ - BackupRetentionDays: to.Ptr[int32](20), - }, - CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeForUpdateUpdate), - Storage: &armpostgresqlflexibleservers.Storage{ - StorageSizeGB: to.Ptr[int32](1024), - }, - }, - SKU: &armpostgresqlflexibleservers.SKU{ - Name: to.Ptr("Standard_D8s_v3"), - Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerUpdateWithCustomerMaintenanceWindow.json -func ExampleServersClient_BeginUpdate_serverUpdateWithCustomerMaintenanceWindow() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, "testrg", "pgtestsvc4", armpostgresqlflexibleservers.ServerForUpdate{ - Properties: &armpostgresqlflexibleservers.ServerPropertiesForUpdate{ - CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeForUpdateUpdate), - MaintenanceWindow: &armpostgresqlflexibleservers.MaintenanceWindow{ - CustomWindow: to.Ptr("Enabled"), - DayOfWeek: to.Ptr[int32](0), - StartHour: to.Ptr[int32](8), - StartMinute: to.Ptr[int32](0), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerUpdateWithDataEncryptionEnabled.json -func ExampleServersClient_BeginUpdate_serverUpdateWithDataEncryptionEnabled() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, "TestGroup", "pgtestsvc4", armpostgresqlflexibleservers.ServerForUpdate{ - Identity: &armpostgresqlflexibleservers.UserAssignedIdentity{ - Type: to.Ptr(armpostgresqlflexibleservers.IdentityTypeUserAssigned), - UserAssignedIdentities: map[string]*armpostgresqlflexibleservers.UserIdentity{ - "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity": {}, - }, - }, - Properties: &armpostgresqlflexibleservers.ServerPropertiesForUpdate{ - AdministratorLoginPassword: to.Ptr("newpassword"), - Backup: &armpostgresqlflexibleservers.Backup{ - BackupRetentionDays: to.Ptr[int32](20), - }, - CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeForUpdateUpdate), - DataEncryption: &armpostgresqlflexibleservers.DataEncryption{ - Type: to.Ptr(armpostgresqlflexibleservers.ArmServerKeyTypeAzureKeyVault), - PrimaryKeyURI: to.Ptr("https://test-kv.vault.azure.net/keys/test-key1/77f57315bab34b0189daa113fbc78787"), - PrimaryUserAssignedIdentityID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"), - }, - Storage: &armpostgresqlflexibleservers.Storage{ - StorageSizeGB: to.Ptr[int32](1024), - }, - }, - SKU: &armpostgresqlflexibleservers.SKU{ - Name: to.Ptr("Standard_D8s_v3"), - Tier: to.Ptr(armpostgresqlflexibleservers.SKUTierGeneralPurpose), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerUpdateWithMajorVersionUpgrade.json -func ExampleServersClient_BeginUpdate_serverUpdateWithMajorVersionUpgrade() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, "testrg", "pgtestsvc4", armpostgresqlflexibleservers.ServerForUpdate{ - Properties: &armpostgresqlflexibleservers.ServerPropertiesForUpdate{ - CreateMode: to.Ptr(armpostgresqlflexibleservers.CreateModeForUpdateUpdate), - Version: to.Ptr(armpostgresqlflexibleservers.ServerVersionFourteen), - }, - }, 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/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerDelete.json -func ExampleServersClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, "testrg", "testserver", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerGet.json -func ExampleServersClient_Get_serverGet() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "testrg", "pgtestsvc1", 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/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerGetWithVnet.json -func ExampleServersClient_Get_serverGetWithVnet() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "testrg", "pgtestsvc4", 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/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerListByResourceGroup.json -func ExampleServersClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("testrg", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerList.json -func ExampleServersClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerRestart.json -func ExampleServersClient_BeginRestart_serverRestart() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginRestart(ctx, "testrg", "testserver", &armpostgresqlflexibleservers.ServersClientBeginRestartOptions{Parameters: 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/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerRestartWithFailover.json -func ExampleServersClient_BeginRestart_serverRestartWithFailover() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginRestart(ctx, "testrg", "testserver", &armpostgresqlflexibleservers.ServersClientBeginRestartOptions{Parameters: &armpostgresqlflexibleservers.RestartParameter{ - FailoverMode: to.Ptr(armpostgresqlflexibleservers.FailoverModeForcedFailover), - RestartWithFailover: to.Ptr(true), - }, - }) - 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/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerStart.json -func ExampleServersClient_BeginStart() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginStart(ctx, "testrg", "testserver", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/ServerStop.json -func ExampleServersClient_BeginStop() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewServersClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginStop(ctx, "testrg", "testserver", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/time_rfc3339.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/time_rfc3339.go index 88d7df1fd0a5..8e3761ad11fd 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/time_rfc3339.go +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/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/postgresql/armpostgresqlflexibleservers/virtualnetworksubnetusage_client.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/virtualnetworksubnetusage_client.go index 84b1149dd9de..1e08de7acfb7 100644 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/virtualnetworksubnetusage_client.go +++ b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/virtualnetworksubnetusage_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // VirtualNetworkSubnetUsageClient contains the methods for the VirtualNetworkSubnetUsage group. // Don't use this type directly, use NewVirtualNetworkSubnetUsageClient() instead. type VirtualNetworkSubnetUsageClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewVirtualNetworkSubnetUsageClient creates a new instance of VirtualNetworkSubnetUsageClient 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 NewVirtualNetworkSubnetUsageClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualNetworkSubnetUsageClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".VirtualNetworkSubnetUsageClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &VirtualNetworkSubnetUsageClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Execute - Get virtual network subnet usage for a given vNet resource id. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-12-01 -// locationName - The name of the location. -// parameters - The required parameters for creating or updating a server. -// options - VirtualNetworkSubnetUsageClientExecuteOptions contains the optional parameters for the VirtualNetworkSubnetUsageClient.Execute -// method. +// - locationName - The name of the location. +// - parameters - The required parameters for creating or updating a server. +// - options - VirtualNetworkSubnetUsageClientExecuteOptions contains the optional parameters for the VirtualNetworkSubnetUsageClient.Execute +// method. func (client *VirtualNetworkSubnetUsageClient) Execute(ctx context.Context, locationName string, parameters VirtualNetworkSubnetUsageParameter, options *VirtualNetworkSubnetUsageClientExecuteOptions) (VirtualNetworkSubnetUsageClientExecuteResponse, error) { req, err := client.executeCreateRequest(ctx, locationName, parameters, options) if err != nil { return VirtualNetworkSubnetUsageClientExecuteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualNetworkSubnetUsageClientExecuteResponse{}, err } @@ -88,7 +78,7 @@ func (client *VirtualNetworkSubnetUsageClient) executeCreateRequest(ctx context. return nil, errors.New("parameter locationName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) - req, err := runtime.NewRequest(ctx, http.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/postgresql/armpostgresqlflexibleservers/virtualnetworksubnetusage_client_example_test.go b/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/virtualnetworksubnetusage_client_example_test.go deleted file mode 100644 index c62d41ec85c4..000000000000 --- a/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers/virtualnetworksubnetusage_client_example_test.go +++ /dev/null @@ -1,39 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armpostgresqlflexibleservers_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/postgresql/armpostgresqlflexibleservers/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-12-01/examples/VirtualNetworkSubnetUsage.json -func ExampleVirtualNetworkSubnetUsageClient_Execute() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armpostgresqlflexibleservers.NewVirtualNetworkSubnetUsageClient("ffffffff-ffff-ffff-ffff-ffffffffffff", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Execute(ctx, "westus", armpostgresqlflexibleservers.VirtualNetworkSubnetUsageParameter{ - VirtualNetworkArmResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/testvnet"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -}