From ff508f4eba04832a829730700993849dc5bf8fe4 Mon Sep 17 00:00:00 2001 From: Alancere <804873052@qq.com> Date: Mon, 8 May 2023 10:35:25 +0800 Subject: [PATCH 1/2] [Release] sdk/resourcemanager/resources/armsubscriptions/2.0.0 generation from spec commit: 17aa6a1314de5aafef059d9aa2229901df506e75 --- .../resources/armsubscriptions/CHANGELOG.md | 25 +++ .../resources/armsubscriptions/autorest.md | 7 +- .../resources/armsubscriptions/client.go | 62 +++--- .../armsubscriptions/client_example_test.go | 200 ++++++++++++++++-- .../armsubscriptions/client_factory.go | 19 +- .../resources/armsubscriptions/constants.go | 35 ++- .../resources/armsubscriptions/go.mod | 3 +- .../resources/armsubscriptions/go.sum | 2 + .../resources/armsubscriptions/models.go | 104 +++++++-- .../armsubscriptions/models_serde.go | 164 ++++++++++++++ .../armsubscriptions/operations_client.go | 94 ++++++++ .../armsubscriptions/response_types.go | 5 + .../armsubscriptions/subscription_client.go | 4 +- .../subscription_client_example_test.go | 6 +- .../armsubscriptions/tenants_client.go | 4 +- .../tenants_client_example_test.go | 6 +- 16 files changed, 655 insertions(+), 85 deletions(-) create mode 100644 sdk/resourcemanager/resources/armsubscriptions/operations_client.go diff --git a/sdk/resourcemanager/resources/armsubscriptions/CHANGELOG.md b/sdk/resourcemanager/resources/armsubscriptions/CHANGELOG.md index 865d94fb3d99..de5d68c04e00 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armsubscriptions/CHANGELOG.md @@ -1,5 +1,30 @@ # Release History +## 2.0.0 (2023-05-08) +### Breaking Changes + +- Function `NewClient` parameter(s) have been changed from `(azcore.TokenCredential, *arm.ClientOptions)` to `(string, azcore.TokenCredential, *arm.ClientOptions)` +- Function `*Client.CheckZonePeers` parameter(s) have been changed from `(context.Context, string, CheckZonePeersRequest, *ClientCheckZonePeersOptions)` to `(context.Context, CheckZonePeersRequest, *ClientCheckZonePeersOptions)` +- Function `*Client.Get` parameter(s) have been changed from `(context.Context, string, *ClientGetOptions)` to `(context.Context, *ClientGetOptions)` +- Function `*Client.NewListLocationsPager` parameter(s) have been changed from `(string, *ClientListLocationsOptions)` to `(*ClientListLocationsOptions)` +- Function `NewClientFactory` parameter(s) have been changed from `(azcore.TokenCredential, *arm.ClientOptions)` to `(string, azcore.TokenCredential, *arm.ClientOptions)` + +### Features Added + +- New enum type `ActionType` with values `ActionTypeInternal` +- New enum type `Origin` with values `OriginSystem`, `OriginUser`, `OriginUserSystem` +- New function `*ClientFactory.NewOperationsClient() *OperationsClient` +- New function `NewOperationsClient(azcore.TokenCredential, *arm.ClientOptions) (*OperationsClient, error)` +- New function `*OperationsClient.NewListPager(*OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse]` +- New struct `AvailabilityZoneMappings` +- New struct `OperationAutoGenerated` +- New struct `OperationDisplayAutoGenerated` +- New struct `OperationListResultAutoGenerated` +- New field `AvailabilityZoneMappings` in struct `Location` +- New field `Geography` in struct `LocationMetadata` +- New field `ActionType`, `IsDataAction`, `Origin` in struct `Operation` + + ## 1.1.1 (2023-04-14) ### Bug Fixes diff --git a/sdk/resourcemanager/resources/armsubscriptions/autorest.md b/sdk/resourcemanager/resources/armsubscriptions/autorest.md index fa8459bd6d9d..4653609ea29d 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/autorest.md +++ b/sdk/resourcemanager/resources/armsubscriptions/autorest.md @@ -5,9 +5,10 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.go.md +- https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/resources/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/resources/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.1.1 +module-version: 2.0.0 package-subscriptions: true +tag: package-subscriptions-2022-12 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armsubscriptions/client.go b/sdk/resourcemanager/resources/armsubscriptions/client.go index 44f21edb374e..522c5fcc5547 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/client.go +++ b/sdk/resourcemanager/resources/armsubscriptions/client.go @@ -11,7 +11,6 @@ package armsubscriptions import ( "context" - "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" @@ -25,19 +24,22 @@ import ( // Client contains the methods for the Subscriptions group. // Don't use this type directly, use NewClient() instead. type Client struct { - internal *arm.Client + internal *arm.Client + subscriptionID string } // NewClient creates a new instance of Client with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. -func NewClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { +func NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { cl, err := arm.NewClient(moduleName+".Client", moduleVersion, credential, options) if err != nil { return nil, err } client := &Client{ - internal: cl, + subscriptionID: subscriptionID, + internal: cl, } return client, nil } @@ -45,12 +47,11 @@ func NewClient(credential azcore.TokenCredential, options *arm.ClientOptions) (* // CheckZonePeers - Compares a subscriptions logical zone mapping // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-01-01 -// - subscriptionID - The ID of the target subscription. +// Generated from API version 2022-12-01 // - parameters - Parameters for checking zone peers. // - options - ClientCheckZonePeersOptions contains the optional parameters for the Client.CheckZonePeers method. -func (client *Client) CheckZonePeers(ctx context.Context, subscriptionID string, parameters CheckZonePeersRequest, options *ClientCheckZonePeersOptions) (ClientCheckZonePeersResponse, error) { - req, err := client.checkZonePeersCreateRequest(ctx, subscriptionID, parameters, options) +func (client *Client) CheckZonePeers(ctx context.Context, parameters CheckZonePeersRequest, options *ClientCheckZonePeersOptions) (ClientCheckZonePeersResponse, error) { + req, err := client.checkZonePeersCreateRequest(ctx, parameters, options) if err != nil { return ClientCheckZonePeersResponse{}, err } @@ -65,18 +66,15 @@ func (client *Client) CheckZonePeers(ctx context.Context, subscriptionID string, } // checkZonePeersCreateRequest creates the CheckZonePeers request. -func (client *Client) checkZonePeersCreateRequest(ctx context.Context, subscriptionID string, parameters CheckZonePeersRequest, options *ClientCheckZonePeersOptions) (*policy.Request, error) { +func (client *Client) checkZonePeersCreateRequest(ctx context.Context, parameters CheckZonePeersRequest, options *ClientCheckZonePeersOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/checkZonePeers/" - if subscriptionID == "" { - return nil, errors.New("parameter subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2022-12-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, parameters) @@ -94,11 +92,10 @@ func (client *Client) checkZonePeersHandleResponse(resp *http.Response) (ClientC // Get - Gets details about a specified subscription. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-01-01 -// - subscriptionID - The ID of the target subscription. +// Generated from API version 2022-12-01 // - options - ClientGetOptions contains the optional parameters for the Client.Get method. -func (client *Client) Get(ctx context.Context, subscriptionID string, options *ClientGetOptions) (ClientGetResponse, error) { - req, err := client.getCreateRequest(ctx, subscriptionID, options) +func (client *Client) Get(ctx context.Context, options *ClientGetOptions) (ClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, options) if err != nil { return ClientGetResponse{}, err } @@ -113,18 +110,15 @@ func (client *Client) Get(ctx context.Context, subscriptionID string, options *C } // getCreateRequest creates the Get request. -func (client *Client) getCreateRequest(ctx context.Context, subscriptionID string, options *ClientGetOptions) (*policy.Request, error) { +func (client *Client) getCreateRequest(ctx context.Context, options *ClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}" - if subscriptionID == "" { - return nil, errors.New("parameter subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2022-12-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -141,7 +135,7 @@ func (client *Client) getHandleResponse(resp *http.Response) (ClientGetResponse, // NewListPager - Gets all subscriptions for a tenant. // -// Generated from API version 2021-01-01 +// Generated from API version 2022-12-01 // - options - ClientListOptions contains the optional parameters for the Client.NewListPager method. func (client *Client) NewListPager(options *ClientListOptions) *runtime.Pager[ClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ClientListResponse]{ @@ -179,7 +173,7 @@ func (client *Client) listCreateRequest(ctx context.Context, options *ClientList return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2022-12-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -197,16 +191,15 @@ func (client *Client) listHandleResponse(resp *http.Response) (ClientListRespons // NewListLocationsPager - This operation provides all the locations that are available for resource providers; however, each // resource provider may support a subset of this list. // -// Generated from API version 2021-01-01 -// - subscriptionID - The ID of the target subscription. +// Generated from API version 2022-12-01 // - options - ClientListLocationsOptions contains the optional parameters for the Client.NewListLocationsPager method. -func (client *Client) NewListLocationsPager(subscriptionID string, options *ClientListLocationsOptions) *runtime.Pager[ClientListLocationsResponse] { +func (client *Client) NewListLocationsPager(options *ClientListLocationsOptions) *runtime.Pager[ClientListLocationsResponse] { return runtime.NewPager(runtime.PagingHandler[ClientListLocationsResponse]{ More: func(page ClientListLocationsResponse) bool { return false }, Fetcher: func(ctx context.Context, page *ClientListLocationsResponse) (ClientListLocationsResponse, error) { - req, err := client.listLocationsCreateRequest(ctx, subscriptionID, options) + req, err := client.listLocationsCreateRequest(ctx, options) if err != nil { return ClientListLocationsResponse{}, err } @@ -223,18 +216,15 @@ func (client *Client) NewListLocationsPager(subscriptionID string, options *Clie } // listLocationsCreateRequest creates the ListLocations request. -func (client *Client) listLocationsCreateRequest(ctx context.Context, subscriptionID string, options *ClientListLocationsOptions) (*policy.Request, error) { +func (client *Client) listLocationsCreateRequest(ctx context.Context, options *ClientListLocationsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/locations" - if subscriptionID == "" { - return nil, errors.New("parameter subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(subscriptionID)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2022-12-01") if options != nil && options.IncludeExtendedLocations != nil { reqQP.Set("includeExtendedLocations", strconv.FormatBool(*options.IncludeExtendedLocations)) } diff --git a/sdk/resourcemanager/resources/armsubscriptions/client_example_test.go b/sdk/resourcemanager/resources/armsubscriptions/client_example_test.go index 091f0d85d3b7..43c5f6b7e9e0 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/client_example_test.go +++ b/sdk/resourcemanager/resources/armsubscriptions/client_example_test.go @@ -15,21 +15,21 @@ import ( "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/resources/armsubscriptions" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetLocations.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetLocations.json func ExampleClient_NewListLocationsPager_getLocationsWithASubscriptionId() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) + clientFactory, err := armsubscriptions.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewClient().NewListLocationsPager("291bba3f-e0a5-47bc-a099-3bdcb2a50a05", &armsubscriptions.ClientListLocationsOptions{IncludeExtendedLocations: nil}) + pager := clientFactory.NewClient().NewListLocationsPager(&armsubscriptions.ClientListLocationsOptions{IncludeExtendedLocations: nil}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -41,22 +41,91 @@ func ExampleClient_NewListLocationsPager_getLocationsWithASubscriptionId() { } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.LocationListResult = armsubscriptions.LocationListResult{ + // Value: []*armsubscriptions.Location{ + // { + // Name: to.Ptr("eastus"), + // Type: to.Ptr(armsubscriptions.LocationTypeRegion), + // AvailabilityZoneMappings: []*armsubscriptions.AvailabilityZoneMappings{ + // { + // LogicalZone: to.Ptr("1"), + // PhysicalZone: to.Ptr("eastus-az1"), + // }, + // { + // LogicalZone: to.Ptr("2"), + // PhysicalZone: to.Ptr("eastus-az3"), + // }, + // { + // LogicalZone: to.Ptr("3"), + // PhysicalZone: to.Ptr("eastus-az2"), + // }}, + // DisplayName: to.Ptr("East US"), + // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/eastus"), + // Metadata: &armsubscriptions.LocationMetadata{ + // Geography: to.Ptr("United States"), + // GeographyGroup: to.Ptr("US"), + // Latitude: to.Ptr("37.3719"), + // Longitude: to.Ptr("-79.8164"), + // PairedRegion: []*armsubscriptions.PairedRegion{ + // { + // Name: to.Ptr("westus"), + // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/westus"), + // }}, + // PhysicalLocation: to.Ptr("Virginia"), + // RegionCategory: to.Ptr(armsubscriptions.RegionCategoryRecommended), + // RegionType: to.Ptr(armsubscriptions.RegionTypePhysical), + // }, + // RegionalDisplayName: to.Ptr("(US) East US"), + // }, + // { + // Name: to.Ptr("eastus2"), + // Type: to.Ptr(armsubscriptions.LocationTypeRegion), + // AvailabilityZoneMappings: []*armsubscriptions.AvailabilityZoneMappings{ + // { + // LogicalZone: to.Ptr("1"), + // PhysicalZone: to.Ptr("eastus2-az1"), + // }, + // { + // LogicalZone: to.Ptr("2"), + // PhysicalZone: to.Ptr("eastus2-az3"), + // }, + // { + // LogicalZone: to.Ptr("3"), + // PhysicalZone: to.Ptr("eastus2-az2"), + // }}, + // DisplayName: to.Ptr("East US 2"), + // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/eastus2"), + // Metadata: &armsubscriptions.LocationMetadata{ + // Geography: to.Ptr("United States"), + // GeographyGroup: to.Ptr("US"), + // Latitude: to.Ptr("36.6681"), + // Longitude: to.Ptr("-78.3889"), + // PairedRegion: []*armsubscriptions.PairedRegion{ + // { + // Name: to.Ptr("centralus"), + // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/centralus"), + // }}, + // PhysicalLocation: to.Ptr("Virginia"), + // RegionCategory: to.Ptr(armsubscriptions.RegionCategoryRecommended), + // RegionType: to.Ptr(armsubscriptions.RegionTypePhysical), + // }, + // RegionalDisplayName: to.Ptr("(US) East US 2"), + // }}, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetLocationsWithExtendedLocations.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetLocationsWithExtendedLocations.json func ExampleClient_NewListLocationsPager_getLocationsWithExtendedLocations() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) + clientFactory, err := armsubscriptions.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewClient().NewListLocationsPager("291bba3f-e0a5-47bc-a099-3bdcb2a50a05", &armsubscriptions.ClientListLocationsOptions{IncludeExtendedLocations: to.Ptr(true)}) + pager := clientFactory.NewClient().NewListLocationsPager(&armsubscriptions.ClientListLocationsOptions{IncludeExtendedLocations: to.Ptr(true)}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -68,22 +137,121 @@ func ExampleClient_NewListLocationsPager_getLocationsWithExtendedLocations() { } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. // page.LocationListResult = armsubscriptions.LocationListResult{ + // Value: []*armsubscriptions.Location{ + // { + // Name: to.Ptr("eastus"), + // Type: to.Ptr(armsubscriptions.LocationTypeRegion), + // AvailabilityZoneMappings: []*armsubscriptions.AvailabilityZoneMappings{ + // { + // LogicalZone: to.Ptr("1"), + // PhysicalZone: to.Ptr("eastus-az1"), + // }, + // { + // LogicalZone: to.Ptr("2"), + // PhysicalZone: to.Ptr("eastus-az3"), + // }, + // { + // LogicalZone: to.Ptr("3"), + // PhysicalZone: to.Ptr("eastus-az2"), + // }}, + // DisplayName: to.Ptr("East US"), + // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/eastus"), + // Metadata: &armsubscriptions.LocationMetadata{ + // Geography: to.Ptr("United States"), + // GeographyGroup: to.Ptr("US"), + // Latitude: to.Ptr("37.3719"), + // Longitude: to.Ptr("-79.8164"), + // PairedRegion: []*armsubscriptions.PairedRegion{ + // { + // Name: to.Ptr("westus"), + // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/westus"), + // }}, + // PhysicalLocation: to.Ptr("Virginia"), + // RegionCategory: to.Ptr(armsubscriptions.RegionCategoryRecommended), + // RegionType: to.Ptr(armsubscriptions.RegionTypePhysical), + // }, + // RegionalDisplayName: to.Ptr("(US) East US"), + // }, + // { + // Name: to.Ptr("eastus2"), + // Type: to.Ptr(armsubscriptions.LocationTypeRegion), + // AvailabilityZoneMappings: []*armsubscriptions.AvailabilityZoneMappings{ + // { + // LogicalZone: to.Ptr("1"), + // PhysicalZone: to.Ptr("eastus2-az1"), + // }, + // { + // LogicalZone: to.Ptr("2"), + // PhysicalZone: to.Ptr("eastus2-az3"), + // }, + // { + // LogicalZone: to.Ptr("3"), + // PhysicalZone: to.Ptr("eastus2-az2"), + // }}, + // DisplayName: to.Ptr("East US 2"), + // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/eastus2"), + // Metadata: &armsubscriptions.LocationMetadata{ + // Geography: to.Ptr("United States"), + // GeographyGroup: to.Ptr("US"), + // Latitude: to.Ptr("36.6681"), + // Longitude: to.Ptr("-78.3889"), + // PairedRegion: []*armsubscriptions.PairedRegion{ + // { + // Name: to.Ptr("centralus"), + // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/centralus"), + // }}, + // PhysicalLocation: to.Ptr("Virginia"), + // RegionCategory: to.Ptr(armsubscriptions.RegionCategoryRecommended), + // RegionType: to.Ptr(armsubscriptions.RegionTypePhysical), + // }, + // RegionalDisplayName: to.Ptr("(US) East US 2"), + // }, + // { + // Name: to.Ptr("ezecustomerlabboston1"), + // Type: to.Ptr(armsubscriptions.LocationTypeEdgeZone), + // DisplayName: to.Ptr("EZE Customer Lab Boston 1"), + // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/eastus/edgeZones/ezecustomerlabboston1"), + // Metadata: &armsubscriptions.LocationMetadata{ + // Geography: to.Ptr("United States"), + // GeographyGroup: to.Ptr("US"), + // Latitude: to.Ptr("42.301218"), + // Longitude: to.Ptr("-71.219038"), + // RegionCategory: to.Ptr(armsubscriptions.RegionCategoryExtended), + // RegionType: to.Ptr(armsubscriptions.RegionTypePhysical), + // }, + // RegionalDisplayName: to.Ptr("(US) EZE Customer Lab Boston 1"), + // }, + // { + // Name: to.Ptr("ezecustomerlabhouston1"), + // Type: to.Ptr(armsubscriptions.LocationTypeEdgeZone), + // DisplayName: to.Ptr("EZE Customer Lab Houston 1"), + // ID: to.Ptr("/subscriptions/a1ffc958-d2c7-493e-9f1e-125a0477f536/locations/southcentralus/edgeZones/ezecustomerlabhouston1"), + // Metadata: &armsubscriptions.LocationMetadata{ + // Geography: to.Ptr("United States"), + // GeographyGroup: to.Ptr("US"), + // Latitude: to.Ptr("29.9411"), + // Longitude: to.Ptr("-95.41452"), + // RegionCategory: to.Ptr(armsubscriptions.RegionCategoryExtended), + // RegionType: to.Ptr(armsubscriptions.RegionTypePhysical), + // }, + // RegionalDisplayName: to.Ptr("(US) EZE Customer Lab Houston 1"), + // }}, // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetSubscription.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscription.json func ExampleClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) + clientFactory, err := armsubscriptions.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewClient().Get(ctx, "291bba3f-e0a5-47bc-a099-3bdcb2a50a05", nil) + res, err := clientFactory.NewClient().Get(ctx, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -113,14 +281,14 @@ func ExampleClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetSubscriptions.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscriptions.json func ExampleClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) + clientFactory, err := armsubscriptions.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } @@ -186,18 +354,18 @@ func ExampleClient_NewListPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/PostCheckZonePeers.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/PostCheckZonePeers.json func ExampleClient_CheckZonePeers() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) + clientFactory, err := armsubscriptions.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewClient().CheckZonePeers(ctx, "00000000-0000-0000-0000-00000000000000", armsubscriptions.CheckZonePeersRequest{ + res, err := clientFactory.NewClient().CheckZonePeers(ctx, armsubscriptions.CheckZonePeersRequest{ Location: to.Ptr("eastus"), SubscriptionIDs: []*string{ to.Ptr("subscriptions/11111111-1111-1111-1111-111111111111")}, @@ -235,6 +403,6 @@ func ExampleClient_CheckZonePeers() { // }}, // }}, // Location: to.Ptr("eastus2"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-00000000000000"), + // SubscriptionID: to.Ptr("8d65815f-a5b6-402f-9298-045155da7d74"), // } } diff --git a/sdk/resourcemanager/resources/armsubscriptions/client_factory.go b/sdk/resourcemanager/resources/armsubscriptions/client_factory.go index 3b67c45e2b62..98e1fa58a3ed 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/client_factory.go +++ b/sdk/resourcemanager/resources/armsubscriptions/client_factory.go @@ -17,27 +17,34 @@ import ( // 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 { - credential azcore.TokenCredential - options *arm.ClientOptions + 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. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. -func NewClientFactory(credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { +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{ - credential: credential, - options: options.Clone(), + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), }, nil } +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + func (c *ClientFactory) NewClient() *Client { - subClient, _ := NewClient(c.credential, c.options) + subClient, _ := NewClient(c.subscriptionID, c.credential, c.options) return subClient } diff --git a/sdk/resourcemanager/resources/armsubscriptions/constants.go b/sdk/resourcemanager/resources/armsubscriptions/constants.go index 223396bb4368..e0b847eaa6f6 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/constants.go +++ b/sdk/resourcemanager/resources/armsubscriptions/constants.go @@ -11,9 +11,23 @@ package armsubscriptions const ( moduleName = "armsubscriptions" - moduleVersion = "v1.1.1" + moduleVersion = "v2.0.0" ) +// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + // LocationType - The location type. type LocationType string @@ -30,6 +44,25 @@ func PossibleLocationTypeValues() []LocationType { } } +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" +type Origin string + +const ( + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + // RegionCategory - The category of the region. type RegionCategory string diff --git a/sdk/resourcemanager/resources/armsubscriptions/go.mod b/sdk/resourcemanager/resources/armsubscriptions/go.mod index f9c31cd4dc56..ffd77866d58c 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/go.mod +++ b/sdk/resourcemanager/resources/armsubscriptions/go.mod @@ -1,4 +1,4 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions/v2 go 1.18 @@ -6,6 +6,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions v1.1.1 github.com/stretchr/testify v1.7.0 ) diff --git a/sdk/resourcemanager/resources/armsubscriptions/go.sum b/sdk/resourcemanager/resources/armsubscriptions/go.sum index b0f97586a165..4798de99f82b 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/go.sum +++ b/sdk/resourcemanager/resources/armsubscriptions/go.sum @@ -8,6 +8,8 @@ github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 h1:mLY+pNL github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2/go.mod h1:FbdwsQ2EzwvXxOPcMFYO8ogEc9uMMIj3YkmCdXdAFmk= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 h1:ECsQtyERDVz3NP3kvDOTLvbQhqWp/x9EsGKtb4ogUr8= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0/go.mod h1:s1tW/At+xHqjNFvWU4G0c0Qv33KOhvbGNj0RCTQDV8s= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions v1.1.1 h1:A+a54F7ygu4ANdV9hYsLMfiHFgjuwIUCG+6opLAvxJE= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions v1.1.1/go.mod h1:ThfyMjs6auYrWPnYJjI3H4H++oVPrz01pizpu8lfl3A= 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/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/sdk/resourcemanager/resources/armsubscriptions/models.go b/sdk/resourcemanager/resources/armsubscriptions/models.go index b5c48e3cdb7c..1a2755c9fb38 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/models.go +++ b/sdk/resourcemanager/resources/armsubscriptions/models.go @@ -9,6 +9,15 @@ package armsubscriptions +// AvailabilityZoneMappings - Availability zone mappings for the region +type AvailabilityZoneMappings struct { + // READ-ONLY; The logical zone id for the availability zone + LogicalZone *string + + // READ-ONLY; The fully qualified physical zone id of availability zone to which logical zone id is mapped to + PhysicalZone *string +} + // AvailabilityZonePeers - List of availability zones shared by the subscriptions. type AvailabilityZonePeers struct { // Details of shared availability zone. @@ -128,13 +137,16 @@ type ErrorResponseAutoGenerated struct { // Location information. type Location struct { + // The availability zone mappings for this region. + AvailabilityZoneMappings []*AvailabilityZoneMappings + // Metadata of the location, such as lat/long, paired region, and others. Metadata *LocationMetadata // READ-ONLY; The display name of the location. DisplayName *string - // READ-ONLY; The fully qualified ID of the location. For example, /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. + // READ-ONLY; The fully qualified ID of the location. For example, /subscriptions/8d65815f-a5b6-402f-9298-045155da7d74/locations/westus. ID *string // READ-ONLY; The location name. @@ -161,6 +173,9 @@ type LocationMetadata struct { // The regions paired to this region. PairedRegion []*PairedRegion + // READ-ONLY; The geography of the location. + Geography *string + // READ-ONLY; The geography group of the location. GeographyGroup *string @@ -189,17 +204,67 @@ type ManagedByTenant struct { TenantID *string } -// Operation - Microsoft.Resources operation +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API type Operation struct { - // The object that represents the operation. + // Localized display information for this particular operation. Display *OperationDisplay + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane + // operations. + IsDataAction *bool + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin +} + +// OperationAutoGenerated - Details of a REST API operation, returned from the Resource Provider Operations API +type OperationAutoGenerated struct { + // Localized display information for this particular operation. + Display *OperationDisplayAutoGenerated + // Operation name: {provider}/{resource}/{operation} Name *string + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane + // operations. + IsDataAction *bool + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin } -// OperationDisplay - The object that represents the operation. +// OperationDisplay - Localized display information for this particular operation. type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string +} + +// OperationDisplayAutoGenerated - Localized display information for this particular operation. +type OperationDisplayAutoGenerated struct { // Description of the operation. Description *string @@ -213,19 +278,34 @@ type OperationDisplay struct { Resource *string } -// OperationListResult - Result of the request to list Microsoft.Resources operations. It contains a list of operations and -// a URL link to get the next set of results. +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. type OperationListResult struct { - // URL to get the next set of operation list results if there are any. + // READ-ONLY; URL to get the next set of operation list results (if there are any). NextLink *string - // List of Microsoft.Resources operations. + // READ-ONLY; List of operations supported by the resource provider Value []*Operation } +// OperationListResultAutoGenerated - A list of REST API operations supported by an Azure Resource Provider. It contains an +// URL link to get the next set of results. +type OperationListResultAutoGenerated struct { + // URL to get the next set of operation list results (if there are any). + NextLink *string + + // List of operations supported by the resource provider + Value []*OperationAutoGenerated +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + // PairedRegion - Information regarding paired region. type PairedRegion struct { - // READ-ONLY; The fully qualified ID of the location. For example, /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. + // READ-ONLY; The fully qualified ID of the location. For example, /subscriptions/8d65815f-a5b6-402f-9298-045155da7d74/locations/westus. ID *string // READ-ONLY; The name of the paired region. @@ -271,7 +351,7 @@ type Subscription struct { // READ-ONLY; The subscription display name. DisplayName *string - // READ-ONLY; The fully qualified ID for the subscription. For example, /subscriptions/00000000-0000-0000-0000-000000000000. + // READ-ONLY; The fully qualified ID for the subscription. For example, /subscriptions/8d65815f-a5b6-402f-9298-045155da7d74 ID *string // READ-ONLY; The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. @@ -331,7 +411,7 @@ type TenantIDDescription struct { // READ-ONLY; The list of domains for the tenant. Domains []*string - // READ-ONLY; The fully qualified ID of the tenant. For example, /tenants/00000000-0000-0000-0000-000000000000. + // READ-ONLY; The fully qualified ID of the tenant. For example, /tenants/8d65815f-a5b6-402f-9298-045155da7d74 ID *string // READ-ONLY; The tenant's branding logo URL. Only available for 'Home' tenant category. @@ -340,7 +420,7 @@ type TenantIDDescription struct { // READ-ONLY; Category of the tenant. TenantCategory *TenantCategory - // READ-ONLY; The tenant ID. For example, 00000000-0000-0000-0000-000000000000. + // READ-ONLY; The tenant ID. For example, 8d65815f-a5b6-402f-9298-045155da7d74 TenantID *string // READ-ONLY; The tenant type. Only available for 'Home' tenant category. diff --git a/sdk/resourcemanager/resources/armsubscriptions/models_serde.go b/sdk/resourcemanager/resources/armsubscriptions/models_serde.go index da9adc8fc276..b3225df47e1a 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/models_serde.go +++ b/sdk/resourcemanager/resources/armsubscriptions/models_serde.go @@ -16,6 +16,37 @@ import ( "reflect" ) +// MarshalJSON implements the json.Marshaller interface for type AvailabilityZoneMappings. +func (a AvailabilityZoneMappings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "logicalZone", a.LogicalZone) + populate(objectMap, "physicalZone", a.PhysicalZone) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AvailabilityZoneMappings. +func (a *AvailabilityZoneMappings) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "logicalZone": + err = unpopulate(val, "LogicalZone", &a.LogicalZone) + delete(rawMsg, key) + case "physicalZone": + err = unpopulate(val, "PhysicalZone", &a.PhysicalZone) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type AvailabilityZonePeers. func (a AvailabilityZonePeers) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -295,6 +326,7 @@ func (e *ErrorResponseAutoGenerated) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Location. func (l Location) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "availabilityZoneMappings", l.AvailabilityZoneMappings) populate(objectMap, "displayName", l.DisplayName) populate(objectMap, "id", l.ID) populate(objectMap, "metadata", l.Metadata) @@ -314,6 +346,9 @@ func (l *Location) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "availabilityZoneMappings": + err = unpopulate(val, "AvailabilityZoneMappings", &l.AvailabilityZoneMappings) + delete(rawMsg, key) case "displayName": err = unpopulate(val, "DisplayName", &l.DisplayName) delete(rawMsg, key) @@ -373,6 +408,7 @@ func (l *LocationListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LocationMetadata. func (l LocationMetadata) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "geography", l.Geography) populate(objectMap, "geographyGroup", l.GeographyGroup) populate(objectMap, "homeLocation", l.HomeLocation) populate(objectMap, "latitude", l.Latitude) @@ -393,6 +429,9 @@ func (l *LocationMetadata) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "geography": + err = unpopulate(val, "Geography", &l.Geography) + delete(rawMsg, key) case "geographyGroup": err = unpopulate(val, "GeographyGroup", &l.GeographyGroup) delete(rawMsg, key) @@ -455,8 +494,11 @@ func (m *ManagedByTenant) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Operation. func (o Operation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) return json.Marshal(objectMap) } @@ -469,12 +511,64 @@ func (o *Operation) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) case "display": err = unpopulate(val, "Display", &o.Display) delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &o.Name) delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationAutoGenerated. +func (o OperationAutoGenerated) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationAutoGenerated. +func (o *OperationAutoGenerated) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", o, err) @@ -522,6 +616,45 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type OperationDisplayAutoGenerated. +func (o OperationDisplayAutoGenerated) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplayAutoGenerated. +func (o *OperationDisplayAutoGenerated) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type OperationListResult. func (o OperationListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -553,6 +686,37 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type OperationListResultAutoGenerated. +func (o OperationListResultAutoGenerated) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResultAutoGenerated. +func (o *OperationListResultAutoGenerated) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type PairedRegion. func (p PairedRegion) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) diff --git a/sdk/resourcemanager/resources/armsubscriptions/operations_client.go b/sdk/resourcemanager/resources/armsubscriptions/operations_client.go new file mode 100644 index 000000000000..67d7311fe591 --- /dev/null +++ b/sdk/resourcemanager/resources/armsubscriptions/operations_client.go @@ -0,0 +1,94 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armsubscriptions + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + internal *arm.Client +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - Lists all of the available Microsoft.Resources REST API operations. +// +// Generated from API version 2022-12-01 +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return OperationsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return OperationsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Resources/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/resources/armsubscriptions/response_types.go b/sdk/resourcemanager/resources/armsubscriptions/response_types.go index d402a5660e83..63450c868de9 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/response_types.go +++ b/sdk/resourcemanager/resources/armsubscriptions/response_types.go @@ -29,6 +29,11 @@ type ClientListResponse struct { SubscriptionListResult } +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + OperationListResult +} + // SubscriptionClientCheckResourceNameResponse contains the response from method SubscriptionClient.CheckResourceName. type SubscriptionClientCheckResourceNameResponse struct { CheckResourceNameResult diff --git a/sdk/resourcemanager/resources/armsubscriptions/subscription_client.go b/sdk/resourcemanager/resources/armsubscriptions/subscription_client.go index 98002be98bd3..032e2e73d6df 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/subscription_client.go +++ b/sdk/resourcemanager/resources/armsubscriptions/subscription_client.go @@ -42,7 +42,7 @@ func NewSubscriptionClient(credential azcore.TokenCredential, options *arm.Clien // start with a reserved word // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-01-01 +// Generated from API version 2022-12-01 // - options - SubscriptionClientCheckResourceNameOptions contains the optional parameters for the SubscriptionClient.CheckResourceName // method. func (client *SubscriptionClient) CheckResourceName(ctx context.Context, options *SubscriptionClientCheckResourceNameOptions) (SubscriptionClientCheckResourceNameResponse, error) { @@ -68,7 +68,7 @@ func (client *SubscriptionClient) checkResourceNameCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2022-12-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.ResourceNameDefinition != nil { diff --git a/sdk/resourcemanager/resources/armsubscriptions/subscription_client_example_test.go b/sdk/resourcemanager/resources/armsubscriptions/subscription_client_example_test.go index e2804ee62102..f7a384aac2ed 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/subscription_client_example_test.go +++ b/sdk/resourcemanager/resources/armsubscriptions/subscription_client_example_test.go @@ -14,17 +14,17 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/CheckResourceName.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/CheckResourceName.json func ExampleSubscriptionClient_CheckResourceName() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) + clientFactory, err := armsubscriptions.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } diff --git a/sdk/resourcemanager/resources/armsubscriptions/tenants_client.go b/sdk/resourcemanager/resources/armsubscriptions/tenants_client.go index 988413f808cf..3c5feda9ab6e 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/tenants_client.go +++ b/sdk/resourcemanager/resources/armsubscriptions/tenants_client.go @@ -40,7 +40,7 @@ func NewTenantsClient(credential azcore.TokenCredential, options *arm.ClientOpti // NewListPager - Gets the tenants for your account. // -// Generated from API version 2021-01-01 +// Generated from API version 2022-12-01 // - options - TenantsClientListOptions contains the optional parameters for the TenantsClient.NewListPager method. func (client *TenantsClient) NewListPager(options *TenantsClientListOptions) *runtime.Pager[TenantsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[TenantsClientListResponse]{ @@ -78,7 +78,7 @@ func (client *TenantsClient) listCreateRequest(ctx context.Context, options *Ten return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2022-12-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/resources/armsubscriptions/tenants_client_example_test.go b/sdk/resourcemanager/resources/armsubscriptions/tenants_client_example_test.go index 357079d943a7..62e3fc2f871b 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/tenants_client_example_test.go +++ b/sdk/resourcemanager/resources/armsubscriptions/tenants_client_example_test.go @@ -14,17 +14,17 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetTenants.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetTenants.json func ExampleTenantsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - clientFactory, err := armsubscriptions.NewClientFactory(cred, nil) + clientFactory, err := armsubscriptions.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } From aff4f5988786a58802a45d25658b6647815567c8 Mon Sep 17 00:00:00 2001 From: Alancere <804873052@qq.com> Date: Mon, 8 May 2023 11:36:15 +0800 Subject: [PATCH 2/2] [Release] sdk/resourcemanager/mysql/armmysqlflexibleservers/2.0.0-beta.1 generation from spec commit: 17aa6a1314de5aafef059d9aa2229901df506e75 --- .../armmysqlflexibleservers/CHANGELOG.md | 57 ++ .../mysql/armmysqlflexibleservers/autorest.md | 7 +- .../azureadadministrators_client.go | 321 ++++++++++ ...ureadadministrators_client_example_test.go | 156 +++++ .../backupandexport_client.go | 171 +++++ .../backupandexport_client_example_test.go | 96 +++ .../armmysqlflexibleservers/backups_client.go | 70 +- .../backups_client_example_test.go | 36 +- .../checknameavailability_client.go | 4 +- ...ecknameavailability_client_example_test.go | 4 +- ...knameavailabilitywithoutlocation_client.go | 94 +++ ...litywithoutlocation_client_example_test.go | 47 ++ .../checkvirtualnetworksubnetusage_client.go | 4 +- ...lnetworksubnetusage_client_example_test.go | 6 +- .../armmysqlflexibleservers/client_factory.go | 40 +- .../configurations_client.go | 104 ++- .../configurations_client_example_test.go | 59 +- .../armmysqlflexibleservers/constants.go | 105 ++- .../databases_client.go | 20 +- .../databases_client_example_test.go | 10 +- .../firewallrules_client.go | 20 +- .../firewallrules_client_example_test.go | 10 +- .../getprivatednszonesuffix_client.go | 4 +- ...rivatednszonesuffix_client_example_test.go | 4 +- .../mysql/armmysqlflexibleservers/go.mod | 2 +- .../locationbasedcapabilities_client.go | 4 +- ...onbasedcapabilities_client_example_test.go | 4 +- .../logfiles_client.go | 115 ++++ .../logfiles_client_example_test.go | 58 ++ .../mysql/armmysqlflexibleservers/models.go | 311 ++++++++- .../armmysqlflexibleservers/models_serde.go | 598 +++++++++++++++++- .../operations_client.go | 4 +- .../operations_client_example_test.go | 4 +- .../polymorphic_helpers.go | 30 + .../replicas_client.go | 4 +- .../replicas_client_example_test.go | 4 +- .../armmysqlflexibleservers/response_types.go | 55 ++ .../armmysqlflexibleservers/servers_client.go | 125 +++- .../servers_client_example_test.go | 64 +- 39 files changed, 2684 insertions(+), 147 deletions(-) create mode 100644 sdk/resourcemanager/mysql/armmysqlflexibleservers/azureadadministrators_client.go create mode 100644 sdk/resourcemanager/mysql/armmysqlflexibleservers/azureadadministrators_client_example_test.go create mode 100644 sdk/resourcemanager/mysql/armmysqlflexibleservers/backupandexport_client.go create mode 100644 sdk/resourcemanager/mysql/armmysqlflexibleservers/backupandexport_client_example_test.go create mode 100644 sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailabilitywithoutlocation_client.go create mode 100644 sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailabilitywithoutlocation_client_example_test.go create mode 100644 sdk/resourcemanager/mysql/armmysqlflexibleservers/logfiles_client.go create mode 100644 sdk/resourcemanager/mysql/armmysqlflexibleservers/logfiles_client_example_test.go create mode 100644 sdk/resourcemanager/mysql/armmysqlflexibleservers/polymorphic_helpers.go diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/CHANGELOG.md b/sdk/resourcemanager/mysql/armmysqlflexibleservers/CHANGELOG.md index 2b9163d36704..78a1919f0b1d 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/CHANGELOG.md +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/CHANGELOG.md @@ -1,5 +1,62 @@ # Release History +## 2.0.0-beta.1 (2023-05-26) +### Breaking Changes + +- Type of `Identity.Type` has been changed from `*string` to `*ManagedServiceIdentityType` + +### Features Added + +- New enum type `AdministratorName` with values `AdministratorNameActiveDirectory` +- New enum type `AdministratorType` with values `AdministratorTypeActiveDirectory` +- New enum type `BackupFormat` with values `BackupFormatCollatedFormat`, `BackupFormatNone` +- New enum type `ManagedServiceIdentityType` with values `ManagedServiceIdentityTypeUserAssigned` +- New enum type `OperationStatus` with values `OperationStatusCancelInProgress`, `OperationStatusCanceled`, `OperationStatusFailed`, `OperationStatusInProgress`, `OperationStatusPending`, `OperationStatusSucceeded` +- New enum type `ResetAllToDefault` with values `ResetAllToDefaultFalse`, `ResetAllToDefaultTrue` +- New function `NewAzureADAdministratorsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*AzureADAdministratorsClient, error)` +- New function `*AzureADAdministratorsClient.BeginCreateOrUpdate(context.Context, string, string, AdministratorName, AzureADAdministrator, *AzureADAdministratorsClientBeginCreateOrUpdateOptions) (*runtime.Poller[AzureADAdministratorsClientCreateOrUpdateResponse], error)` +- New function `*AzureADAdministratorsClient.BeginDelete(context.Context, string, string, AdministratorName, *AzureADAdministratorsClientBeginDeleteOptions) (*runtime.Poller[AzureADAdministratorsClientDeleteResponse], error)` +- New function `*AzureADAdministratorsClient.Get(context.Context, string, string, AdministratorName, *AzureADAdministratorsClientGetOptions) (AzureADAdministratorsClientGetResponse, error)` +- New function `*AzureADAdministratorsClient.NewListByServerPager(string, string, *AzureADAdministratorsClientListByServerOptions) *runtime.Pager[AzureADAdministratorsClientListByServerResponse]` +- New function `NewBackupAndExportClient(string, azcore.TokenCredential, *arm.ClientOptions) (*BackupAndExportClient, error)` +- New function `*BackupAndExportClient.BeginCreate(context.Context, string, string, BackupAndExportRequest, *BackupAndExportClientBeginCreateOptions) (*runtime.Poller[BackupAndExportClientCreateResponse], error)` +- New function `*BackupAndExportClient.ValidateBackup(context.Context, string, string, *BackupAndExportClientValidateBackupOptions) (BackupAndExportClientValidateBackupResponse, error)` +- New function `*BackupStoreDetails.GetBackupStoreDetails() *BackupStoreDetails` +- New function `*BackupsClient.Put(context.Context, string, string, string, *BackupsClientPutOptions) (BackupsClientPutResponse, error)` +- New function `NewCheckNameAvailabilityWithoutLocationClient(string, azcore.TokenCredential, *arm.ClientOptions) (*CheckNameAvailabilityWithoutLocationClient, error)` +- New function `*CheckNameAvailabilityWithoutLocationClient.Execute(context.Context, NameAvailabilityRequest, *CheckNameAvailabilityWithoutLocationClientExecuteOptions) (CheckNameAvailabilityWithoutLocationClientExecuteResponse, error)` +- New function `*ClientFactory.NewAzureADAdministratorsClient() *AzureADAdministratorsClient` +- New function `*ClientFactory.NewBackupAndExportClient() *BackupAndExportClient` +- New function `*ClientFactory.NewCheckNameAvailabilityWithoutLocationClient() *CheckNameAvailabilityWithoutLocationClient` +- New function `*ClientFactory.NewLogFilesClient() *LogFilesClient` +- New function `*ConfigurationsClient.BeginCreateOrUpdate(context.Context, string, string, string, Configuration, *ConfigurationsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ConfigurationsClientCreateOrUpdateResponse], error)` +- New function `*FullBackupStoreDetails.GetBackupStoreDetails() *BackupStoreDetails` +- New function `NewLogFilesClient(string, azcore.TokenCredential, *arm.ClientOptions) (*LogFilesClient, error)` +- New function `*LogFilesClient.NewListByServerPager(string, string, *LogFilesClientListByServerOptions) *runtime.Pager[LogFilesClientListByServerResponse]` +- New function `*ServersClient.BeginResetGtid(context.Context, string, string, ServerGtidSetParameter, *ServersClientBeginResetGtidOptions) (*runtime.Poller[ServersClientResetGtidResponse], error)` +- New struct `AdministratorListResult` +- New struct `AdministratorProperties` +- New struct `AzureADAdministrator` +- New struct `BackupAndExportRequest` +- New struct `BackupAndExportResponse` +- New struct `BackupAndExportResponseProperties` +- New struct `BackupRequestBase` +- New struct `BackupSettings` +- New struct `FullBackupStoreDetails` +- New struct `LogFile` +- New struct `LogFileListResult` +- New struct `LogFileProperties` +- New struct `ServerGtidSetParameter` +- New struct `ValidateBackupResponse` +- New struct `ValidateBackupResponseProperties` +- New field `ResetAllToDefault` in struct `ConfigurationListForBatchUpdate` +- New field `CurrentValue`, `DocumentationLink` in struct `ConfigurationProperties` +- New field `Keyword`, `Page`, `PageSize`, `Tags` in struct `ConfigurationsClientListByServerOptions` +- New field `Version` in struct `ServerPropertiesForUpdate` +- New field `AutoIoScaling`, `LogOnDisk` in struct `Storage` +- New field `Location`, `SubscriptionID` in struct `VirtualNetworkSubnetUsageResult` + + ## 1.1.1 (2023-04-14) ### Bug Fixes diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/autorest.md b/sdk/resourcemanager/mysql/armmysqlflexibleservers/autorest.md index 7888d98c079f..3f8b67318523 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/autorest.md +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/autorest.md @@ -5,9 +5,10 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/readme.go.md +- https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.1.1 +module-version: 2.0.0-beta.1 package-flexibleservers: true +tag: package-flexibleserver-2022-09-30-preview ``` \ No newline at end of file diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/azureadadministrators_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/azureadadministrators_client.go new file mode 100644 index 000000000000..3bf0e8ec7506 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/azureadadministrators_client.go @@ -0,0 +1,321 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armmysqlflexibleservers + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// AzureADAdministratorsClient contains the methods for the AzureADAdministrators group. +// Don't use this type directly, use NewAzureADAdministratorsClient() instead. +type AzureADAdministratorsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewAzureADAdministratorsClient creates a new instance of AzureADAdministratorsClient 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. +func NewAzureADAdministratorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AzureADAdministratorsClient, error) { + cl, err := arm.NewClient(moduleName+".AzureADAdministratorsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &AzureADAdministratorsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates an existing Azure Active Directory administrator. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - administratorName - The name of the Azure AD Administrator. +// - parameters - The required parameters for creating or updating an aad administrator. +// - options - AzureADAdministratorsClientBeginCreateOrUpdateOptions contains the optional parameters for the AzureADAdministratorsClient.BeginCreateOrUpdate +// method. +func (client *AzureADAdministratorsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, administratorName AdministratorName, parameters AzureADAdministrator, options *AzureADAdministratorsClientBeginCreateOrUpdateOptions) (*runtime.Poller[AzureADAdministratorsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, serverName, administratorName, parameters, options) + if err != nil { + return nil, err + } + return runtime.NewPoller[AzureADAdministratorsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + } else { + return runtime.NewPollerFromResumeToken[AzureADAdministratorsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Creates or updates an existing Azure Active Directory administrator. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-12-01-preview +func (client *AzureADAdministratorsClient) createOrUpdate(ctx context.Context, resourceGroupName string, serverName string, administratorName AdministratorName, parameters AzureADAdministrator, options *AzureADAdministratorsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serverName, administratorName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *AzureADAdministratorsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serverName string, administratorName AdministratorName, parameters AzureADAdministrator, options *AzureADAdministratorsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + if administratorName == "" { + return nil, errors.New("parameter administratorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{administratorName}", url.PathEscape(string(administratorName))) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + +// BeginDelete - Deletes an Azure AD Administrator. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - administratorName - The name of the Azure AD Administrator. +// - options - AzureADAdministratorsClientBeginDeleteOptions contains the optional parameters for the AzureADAdministratorsClient.BeginDelete +// method. +func (client *AzureADAdministratorsClient) BeginDelete(ctx context.Context, resourceGroupName string, serverName string, administratorName AdministratorName, options *AzureADAdministratorsClientBeginDeleteOptions) (*runtime.Poller[AzureADAdministratorsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, serverName, administratorName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AzureADAdministratorsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[AzureADAdministratorsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Deletes an Azure AD Administrator. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-12-01-preview +func (client *AzureADAdministratorsClient) deleteOperation(ctx context.Context, resourceGroupName string, serverName string, administratorName AdministratorName, options *AzureADAdministratorsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serverName, administratorName, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AzureADAdministratorsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serverName string, administratorName AdministratorName, options *AzureADAdministratorsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + if administratorName == "" { + return nil, errors.New("parameter administratorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{administratorName}", url.PathEscape(string(administratorName))) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets information about an azure ad administrator. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - administratorName - The name of the Azure AD Administrator. +// - options - AzureADAdministratorsClientGetOptions contains the optional parameters for the AzureADAdministratorsClient.Get +// method. +func (client *AzureADAdministratorsClient) Get(ctx context.Context, resourceGroupName string, serverName string, administratorName AdministratorName, options *AzureADAdministratorsClientGetOptions) (AzureADAdministratorsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serverName, administratorName, options) + if err != nil { + return AzureADAdministratorsClientGetResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AzureADAdministratorsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AzureADAdministratorsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *AzureADAdministratorsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serverName string, administratorName AdministratorName, options *AzureADAdministratorsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators/{administratorName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + if administratorName == "" { + return nil, errors.New("parameter administratorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{administratorName}", url.PathEscape(string(administratorName))) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AzureADAdministratorsClient) getHandleResponse(resp *http.Response) (AzureADAdministratorsClientGetResponse, error) { + result := AzureADAdministratorsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AzureADAdministrator); err != nil { + return AzureADAdministratorsClientGetResponse{}, err + } + return result, nil +} + +// NewListByServerPager - List all the AAD administrators in a given server. +// +// Generated from API version 2021-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - AzureADAdministratorsClientListByServerOptions contains the optional parameters for the AzureADAdministratorsClient.NewListByServerPager +// method. +func (client *AzureADAdministratorsClient) NewListByServerPager(resourceGroupName string, serverName string, options *AzureADAdministratorsClientListByServerOptions) *runtime.Pager[AzureADAdministratorsClientListByServerResponse] { + return runtime.NewPager(runtime.PagingHandler[AzureADAdministratorsClientListByServerResponse]{ + More: func(page AzureADAdministratorsClientListByServerResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AzureADAdministratorsClientListByServerResponse) (AzureADAdministratorsClientListByServerResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByServerCreateRequest(ctx, resourceGroupName, serverName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return AzureADAdministratorsClientListByServerResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AzureADAdministratorsClientListByServerResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AzureADAdministratorsClientListByServerResponse{}, runtime.NewResponseError(resp) + } + return client.listByServerHandleResponse(resp) + }, + }) +} + +// listByServerCreateRequest creates the ListByServer request. +func (client *AzureADAdministratorsClient) listByServerCreateRequest(ctx context.Context, resourceGroupName string, serverName string, options *AzureADAdministratorsClientListByServerOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/administrators" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByServerHandleResponse handles the ListByServer response. +func (client *AzureADAdministratorsClient) listByServerHandleResponse(resp *http.Response) (AzureADAdministratorsClientListByServerResponse, error) { + result := AzureADAdministratorsClientListByServerResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AdministratorListResult); err != nil { + return AzureADAdministratorsClientListByServerResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/azureadadministrators_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/azureadadministrators_client_example_test.go new file mode 100644 index 000000000000..1d4259771715 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/azureadadministrators_client_example_test.go @@ -0,0 +1,156 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armmysqlflexibleservers_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers/v2" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/AAD/preview/2021-12-01-preview/examples/AzureADAdministratorCreate.json +func ExampleAzureADAdministratorsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAzureADAdministratorsClient().BeginCreateOrUpdate(ctx, "testrg", "mysqltestsvc4", armmysqlflexibleservers.AdministratorNameActiveDirectory, armmysqlflexibleservers.AzureADAdministrator{ + Properties: &armmysqlflexibleservers.AdministratorProperties{ + AdministratorType: to.Ptr(armmysqlflexibleservers.AdministratorTypeActiveDirectory), + IdentityResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/test-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi"), + Login: to.Ptr("bob@contoso.com"), + Sid: to.Ptr("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + TenantID: to.Ptr("c12b7025-bfe2-46c1-b463-993b5e4cd467"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AzureADAdministrator = armmysqlflexibleservers.AzureADAdministrator{ + // Name: to.Ptr("ActiveDirectory"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/administrators"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestsvc4/administrators/ActiveDirectory"), + // Properties: &armmysqlflexibleservers.AdministratorProperties{ + // AdministratorType: to.Ptr(armmysqlflexibleservers.AdministratorTypeActiveDirectory), + // IdentityResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/test-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi"), + // Login: to.Ptr("bob@contoso.com"), + // Sid: to.Ptr("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + // TenantID: to.Ptr("c12b7025-bfe2-46c1-b463-993b5e4cd467"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/AAD/preview/2021-12-01-preview/examples/AzureADAdministratorDelete.json +func ExampleAzureADAdministratorsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAzureADAdministratorsClient().BeginDelete(ctx, "testrg", "mysqltestsvc4", armmysqlflexibleservers.AdministratorNameActiveDirectory, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/AAD/preview/2021-12-01-preview/examples/AzureADAdministratorGet.json +func ExampleAzureADAdministratorsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAzureADAdministratorsClient().Get(ctx, "testrg", "mysqltestsvc4", armmysqlflexibleservers.AdministratorNameActiveDirectory, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AzureADAdministrator = armmysqlflexibleservers.AzureADAdministrator{ + // Name: to.Ptr("ActiveDirectory"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/administrators"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestsvc4/administrators/ActiveDirectory"), + // Properties: &armmysqlflexibleservers.AdministratorProperties{ + // AdministratorType: to.Ptr(armmysqlflexibleservers.AdministratorTypeActiveDirectory), + // IdentityResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/test-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi"), + // Login: to.Ptr("bob@contoso.com"), + // Sid: to.Ptr("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + // TenantID: to.Ptr("c12b7025-bfe2-46c1-b463-993b5e4cd467"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/AAD/preview/2021-12-01-preview/examples/AzureADAdministratorsListByServer.json +func ExampleAzureADAdministratorsClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAzureADAdministratorsClient().NewListByServerPager("testrg", "mysqltestsvc4", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AdministratorListResult = armmysqlflexibleservers.AdministratorListResult{ + // Value: []*armmysqlflexibleservers.AzureADAdministrator{ + // { + // Name: to.Ptr("ActiveDirectory"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/administrators"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestsvc4/administrators/ActiveDirectory"), + // Properties: &armmysqlflexibleservers.AdministratorProperties{ + // AdministratorType: to.Ptr(armmysqlflexibleservers.AdministratorTypeActiveDirectory), + // IdentityResourceID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/test-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi"), + // Login: to.Ptr("bob@contoso.com"), + // Sid: to.Ptr("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + // TenantID: to.Ptr("c12b7025-bfe2-46c1-b463-993b5e4cd467"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/backupandexport_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/backupandexport_client.go new file mode 100644 index 000000000000..f04049aefa06 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/backupandexport_client.go @@ -0,0 +1,171 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armmysqlflexibleservers + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// BackupAndExportClient contains the methods for the BackupAndExport group. +// Don't use this type directly, use NewBackupAndExportClient() instead. +type BackupAndExportClient struct { + internal *arm.Client + subscriptionID string +} + +// NewBackupAndExportClient creates a new instance of BackupAndExportClient 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. +func NewBackupAndExportClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BackupAndExportClient, error) { + cl, err := arm.NewClient(moduleName+".BackupAndExportClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &BackupAndExportClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Exports the backup of the given server by creating a backup if not existing. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-30-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - parameters - The required parameters for creating and exporting backup of the given server. +// - options - BackupAndExportClientBeginCreateOptions contains the optional parameters for the BackupAndExportClient.BeginCreate +// method. +func (client *BackupAndExportClient) BeginCreate(ctx context.Context, resourceGroupName string, serverName string, parameters BackupAndExportRequest, options *BackupAndExportClientBeginCreateOptions) (*runtime.Poller[BackupAndExportClientCreateResponse], 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.internal.Pipeline(), &runtime.NewPollerOptions[BackupAndExportClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[BackupAndExportClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Create - Exports the backup of the given server by creating a backup if not existing. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-30-preview +func (client *BackupAndExportClient) create(ctx context.Context, resourceGroupName string, serverName string, parameters BackupAndExportRequest, options *BackupAndExportClientBeginCreateOptions) (*http.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, serverName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *BackupAndExportClient) createCreateRequest(ctx context.Context, resourceGroupName string, serverName string, parameters BackupAndExportRequest, options *BackupAndExportClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backupAndExport" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-09-30-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + +// ValidateBackup - Validates if backup can be performed for given server. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-30-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - BackupAndExportClientValidateBackupOptions contains the optional parameters for the BackupAndExportClient.ValidateBackup +// method. +func (client *BackupAndExportClient) ValidateBackup(ctx context.Context, resourceGroupName string, serverName string, options *BackupAndExportClientValidateBackupOptions) (BackupAndExportClientValidateBackupResponse, error) { + req, err := client.validateBackupCreateRequest(ctx, resourceGroupName, serverName, options) + if err != nil { + return BackupAndExportClientValidateBackupResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BackupAndExportClientValidateBackupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return BackupAndExportClientValidateBackupResponse{}, runtime.NewResponseError(resp) + } + return client.validateBackupHandleResponse(resp) +} + +// validateBackupCreateRequest creates the ValidateBackup request. +func (client *BackupAndExportClient) validateBackupCreateRequest(ctx context.Context, resourceGroupName string, serverName string, options *BackupAndExportClientValidateBackupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/validateBackup" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-09-30-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// validateBackupHandleResponse handles the ValidateBackup response. +func (client *BackupAndExportClient) validateBackupHandleResponse(resp *http.Response) (BackupAndExportClientValidateBackupResponse, error) { + result := BackupAndExportClientValidateBackupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ValidateBackupResponse); err != nil { + return BackupAndExportClientValidateBackupResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/backupandexport_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/backupandexport_client_example_test.go new file mode 100644 index 000000000000..e5b828900e63 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/backupandexport_client_example_test.go @@ -0,0 +1,96 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armmysqlflexibleservers_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers/v2" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/preview/2022-09-30-preview/examples/BackupAndExport.json +func ExampleBackupAndExportClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewBackupAndExportClient().BeginCreate(ctx, "TestGroup", "mysqltestserver", armmysqlflexibleservers.BackupAndExportRequest{ + BackupSettings: &armmysqlflexibleservers.BackupSettings{ + BackupName: to.Ptr("customer-backup-name"), + }, + TargetDetails: &armmysqlflexibleservers.FullBackupStoreDetails{ + ObjectType: to.Ptr("FullBackupStoreDetails"), + SasURIList: []*string{ + to.Ptr("sasuri1"), + to.Ptr("sasuri2")}, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BackupAndExportResponse = armmysqlflexibleservers.BackupAndExportResponse{ + // Name: to.Ptr("custom-backup101"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/backupAndExport"), + // ID: to.Ptr("/subscriptions/cb9d743d-2140-4e73-b871-cd31abab1d2f/resourceGroups/mrgsumitkumatest1/providers/Microsoft.DBforMySQL/flexibleServers/servermysql-01/backupAndExport/custom-backup101"), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-12-29T07:37:05.6406008Z"); return t}()), + // Error: &armmysqlflexibleservers.ErrorResponse{ + // Code: to.Ptr("AggregateException"), + // Message: to.Ptr("System.AggregateException: One or more errors occurred. (Mismatch in count of number of Commited-Blocks from service.)"), + // }, + // PercentComplete: to.Ptr[float64](100), + // Properties: &armmysqlflexibleservers.BackupAndExportResponseProperties{ + // BackupMetadata: to.Ptr("{\"key1\":\"value1\",\"key2\":\"value2\"}"), + // DataTransferredInBytes: to.Ptr[int64](1024), + // DatasourceSizeInBytes: to.Ptr[int64](1024), + // }, + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-12-29T07:34:02.328326Z"); return t}()), + // Status: to.Ptr(armmysqlflexibleservers.OperationStatusFailed), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/preview/2022-09-30-preview/examples/ValidateBackup.json +func ExampleBackupAndExportClient_ValidateBackup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBackupAndExportClient().ValidateBackup(ctx, "TestGroup", "mysqltestserver", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ValidateBackupResponse = armmysqlflexibleservers.ValidateBackupResponse{ + // Properties: &armmysqlflexibleservers.ValidateBackupResponseProperties{ + // NumberOfContainers: to.Ptr[int32](1), + // }, + // } +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/backups_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/backups_client.go index 5287b47d89c1..045ac801865f 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/backups_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/backups_client.go @@ -47,7 +47,7 @@ func NewBackupsClient(subscriptionID string, credential azcore.TokenCredential, // Get - List all the backups for a given server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serverName - The name of the server. // - backupName - The name of the backup. @@ -91,7 +91,7 @@ func (client *BackupsClient) getCreateRequest(ctx context.Context, resourceGroup return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-09-30-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -108,7 +108,7 @@ func (client *BackupsClient) getHandleResponse(resp *http.Response) (BackupsClie // NewListByServerPager - List all the backups for a given server. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview // - 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 @@ -161,7 +161,7 @@ func (client *BackupsClient) listByServerCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-09-30-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -175,3 +175,65 @@ func (client *BackupsClient) listByServerHandleResponse(resp *http.Response) (Ba } return result, nil } + +// Put - Create backup for a given server with specified backup name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-30-preview +// - 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 - BackupsClientPutOptions contains the optional parameters for the BackupsClient.Put method. +func (client *BackupsClient) Put(ctx context.Context, resourceGroupName string, serverName string, backupName string, options *BackupsClientPutOptions) (BackupsClientPutResponse, error) { + req, err := client.putCreateRequest(ctx, resourceGroupName, serverName, backupName, options) + if err != nil { + return BackupsClientPutResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BackupsClientPutResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return BackupsClientPutResponse{}, runtime.NewResponseError(resp) + } + return client.putHandleResponse(resp) +} + +// putCreateRequest creates the Put request. +func (client *BackupsClient) putCreateRequest(ctx context.Context, resourceGroupName string, serverName string, backupName string, options *BackupsClientPutOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/backups/{backupName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + if backupName == "" { + return nil, errors.New("parameter backupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{backupName}", url.PathEscape(backupName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-09-30-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// putHandleResponse handles the Put response. +func (client *BackupsClient) putHandleResponse(resp *http.Response) (BackupsClientPutResponse, error) { + result := BackupsClientPutResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ServerBackup); err != nil { + return BackupsClientPutResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/backups_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/backups_client_example_test.go index 862667091e36..e20e46f78d18 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/backups_client_example_test.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/backups_client_example_test.go @@ -14,10 +14,40 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/BackupGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/preview/2022-09-30-preview/examples/BackupPut.json +func ExampleBackupsClient_Put() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBackupsClient().Put(ctx, "TestGroup", "mysqltestserver", "mybackup", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ServerBackup = armmysqlflexibleservers.ServerBackup{ + // Name: to.Ptr("customer_20220507t073755_bb392c3b-17c6-4d3f-9742-8479ca87b3ac_mybackup"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/backups"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestserver/backups/customer_20220507t073755_bb392c3b-17c6-4d3f-9742-8479ca87b3ac_mybackup"), + // Properties: &armmysqlflexibleservers.ServerBackupProperties{ + // BackupType: to.Ptr("FULL"), + // CompletedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-05-07T07:38:01.1498043+00:00"); return t}()), + // Source: to.Ptr("Automatic"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/preview/2022-09-30-preview/examples/BackupGet.json func ExampleBackupsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -47,7 +77,7 @@ func ExampleBackupsClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/BackupsListByServer.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/preview/2022-09-30-preview/examples/BackupsListByServer.json func ExampleBackupsClient_NewListByServerPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailability_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailability_client.go index c32a3a9e1648..6b5adcb75442 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailability_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailability_client.go @@ -47,7 +47,7 @@ func NewCheckNameAvailabilityClient(subscriptionID string, credential azcore.Tok // Execute - Check the availability of name for server // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview // - locationName - The name of the location. // - nameAvailabilityRequest - The required parameters for checking if server name is available. // - options - CheckNameAvailabilityClientExecuteOptions contains the optional parameters for the CheckNameAvailabilityClient.Execute @@ -83,7 +83,7 @@ func (client *CheckNameAvailabilityClient) executeCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, nameAvailabilityRequest) diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailability_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailability_client_example_test.go index e6e26026ffa5..daa51d2550f1 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailability_client_example_test.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailability_client_example_test.go @@ -15,10 +15,10 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/CheckNameAvailability.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/ServiceOperations/preview/2021-12-01-preview/examples/CheckNameAvailability.json func ExampleCheckNameAvailabilityClient_Execute() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailabilitywithoutlocation_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailabilitywithoutlocation_client.go new file mode 100644 index 000000000000..3a421accdc5d --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailabilitywithoutlocation_client.go @@ -0,0 +1,94 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armmysqlflexibleservers + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// CheckNameAvailabilityWithoutLocationClient contains the methods for the CheckNameAvailabilityWithoutLocation group. +// Don't use this type directly, use NewCheckNameAvailabilityWithoutLocationClient() instead. +type CheckNameAvailabilityWithoutLocationClient struct { + internal *arm.Client + subscriptionID string +} + +// NewCheckNameAvailabilityWithoutLocationClient creates a new instance of CheckNameAvailabilityWithoutLocationClient 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. +func NewCheckNameAvailabilityWithoutLocationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CheckNameAvailabilityWithoutLocationClient, error) { + cl, err := arm.NewClient(moduleName+".CheckNameAvailabilityWithoutLocationClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &CheckNameAvailabilityWithoutLocationClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Execute - Check the availability of name for server +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-12-01-preview +// - nameAvailabilityRequest - The required parameters for checking if server name is available. +// - options - CheckNameAvailabilityWithoutLocationClientExecuteOptions contains the optional parameters for the CheckNameAvailabilityWithoutLocationClient.Execute +// method. +func (client *CheckNameAvailabilityWithoutLocationClient) Execute(ctx context.Context, nameAvailabilityRequest NameAvailabilityRequest, options *CheckNameAvailabilityWithoutLocationClientExecuteOptions) (CheckNameAvailabilityWithoutLocationClientExecuteResponse, error) { + req, err := client.executeCreateRequest(ctx, nameAvailabilityRequest, options) + if err != nil { + return CheckNameAvailabilityWithoutLocationClientExecuteResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CheckNameAvailabilityWithoutLocationClientExecuteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CheckNameAvailabilityWithoutLocationClientExecuteResponse{}, runtime.NewResponseError(resp) + } + return client.executeHandleResponse(resp) +} + +// executeCreateRequest creates the Execute request. +func (client *CheckNameAvailabilityWithoutLocationClient) executeCreateRequest(ctx context.Context, nameAvailabilityRequest NameAvailabilityRequest, options *CheckNameAvailabilityWithoutLocationClientExecuteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMySQL/checkNameAvailability" + if client.subscriptionID == "" { + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, nameAvailabilityRequest) +} + +// executeHandleResponse handles the Execute response. +func (client *CheckNameAvailabilityWithoutLocationClient) executeHandleResponse(resp *http.Response) (CheckNameAvailabilityWithoutLocationClientExecuteResponse, error) { + result := CheckNameAvailabilityWithoutLocationClientExecuteResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.NameAvailability); err != nil { + return CheckNameAvailabilityWithoutLocationClientExecuteResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailabilitywithoutlocation_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailabilitywithoutlocation_client_example_test.go new file mode 100644 index 000000000000..d90d25bc94e1 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checknameavailabilitywithoutlocation_client_example_test.go @@ -0,0 +1,47 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armmysqlflexibleservers_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers/v2" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/ServiceOperations/preview/2021-12-01-preview/examples/CheckNameAvailability.json +func ExampleCheckNameAvailabilityWithoutLocationClient_Execute() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewCheckNameAvailabilityWithoutLocationClient().Execute(ctx, armmysqlflexibleservers.NameAvailabilityRequest{ + Name: to.Ptr("name1"), + Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.NameAvailability = armmysqlflexibleservers.NameAvailability{ + // Message: to.Ptr(""), + // NameAvailable: to.Ptr(true), + // Reason: to.Ptr(""), + // } +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/checkvirtualnetworksubnetusage_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checkvirtualnetworksubnetusage_client.go index ed41d242f287..31ea182af63e 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/checkvirtualnetworksubnetusage_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checkvirtualnetworksubnetusage_client.go @@ -47,7 +47,7 @@ func NewCheckVirtualNetworkSubnetUsageClient(subscriptionID string, credential a // Execute - Get virtual network subnet usage for a given vNet resource id. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview // - locationName - The name of the location. // - parameters - The required parameters for creating or updating a server. // - options - CheckVirtualNetworkSubnetUsageClientExecuteOptions contains the optional parameters for the CheckVirtualNetworkSubnetUsageClient.Execute @@ -83,7 +83,7 @@ func (client *CheckVirtualNetworkSubnetUsageClient) executeCreateRequest(ctx con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, parameters) diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/checkvirtualnetworksubnetusage_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checkvirtualnetworksubnetusage_client_example_test.go index 8d800a4f3e85..6cf3a994aea2 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/checkvirtualnetworksubnetusage_client_example_test.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/checkvirtualnetworksubnetusage_client_example_test.go @@ -15,10 +15,10 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/CheckVirtualNetworkSubnetUsage.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/ServiceOperations/preview/2021-12-01-preview/examples/CheckVirtualNetworkSubnetUsage.json func ExampleCheckVirtualNetworkSubnetUsageClient_Execute() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -48,5 +48,7 @@ func ExampleCheckVirtualNetworkSubnetUsageClient_Execute() { // SubnetName: to.Ptr("test-subnet-2"), // Usage: to.Ptr[int64](3), // }}, + // Location: to.Ptr("WestUS"), + // SubscriptionID: to.Ptr("ffffffff-ffff-ffff-ffff-ffffffffffff"), // } } diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/client_factory.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/client_factory.go index 938882c6f81d..820ba49f823c 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/client_factory.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/client_factory.go @@ -38,23 +38,23 @@ func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, }, nil } -func (c *ClientFactory) NewServersClient() *ServersClient { - subClient, _ := NewServersClient(c.subscriptionID, c.credential, c.options) +func (c *ClientFactory) NewAzureADAdministratorsClient() *AzureADAdministratorsClient { + subClient, _ := NewAzureADAdministratorsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewReplicasClient() *ReplicasClient { - subClient, _ := NewReplicasClient(c.subscriptionID, c.credential, c.options) +func (c *ClientFactory) NewBackupsClient() *BackupsClient { + subClient, _ := NewBackupsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewBackupsClient() *BackupsClient { - subClient, _ := NewBackupsClient(c.subscriptionID, c.credential, c.options) +func (c *ClientFactory) NewBackupAndExportClient() *BackupAndExportClient { + subClient, _ := NewBackupAndExportClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewFirewallRulesClient() *FirewallRulesClient { - subClient, _ := NewFirewallRulesClient(c.subscriptionID, c.credential, c.options) +func (c *ClientFactory) NewConfigurationsClient() *ConfigurationsClient { + subClient, _ := NewConfigurationsClient(c.subscriptionID, c.credential, c.options) return subClient } @@ -63,8 +63,23 @@ func (c *ClientFactory) NewDatabasesClient() *DatabasesClient { return subClient } -func (c *ClientFactory) NewConfigurationsClient() *ConfigurationsClient { - subClient, _ := NewConfigurationsClient(c.subscriptionID, c.credential, c.options) +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) NewReplicasClient() *ReplicasClient { + subClient, _ := NewReplicasClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewLogFilesClient() *LogFilesClient { + subClient, _ := NewLogFilesClient(c.subscriptionID, c.credential, c.options) return subClient } @@ -83,6 +98,11 @@ func (c *ClientFactory) NewCheckNameAvailabilityClient() *CheckNameAvailabilityC return subClient } +func (c *ClientFactory) NewCheckNameAvailabilityWithoutLocationClient() *CheckNameAvailabilityWithoutLocationClient { + subClient, _ := NewCheckNameAvailabilityWithoutLocationClient(c.subscriptionID, c.credential, c.options) + return subClient +} + func (c *ClientFactory) NewGetPrivateDNSZoneSuffixClient() *GetPrivateDNSZoneSuffixClient { subClient, _ := NewGetPrivateDNSZoneSuffixClient(c.credential, c.options) return subClient diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/configurations_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/configurations_client.go index ebfd334e1ed4..62eea28b0379 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/configurations_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/configurations_client.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" + "strconv" "strings" ) @@ -47,7 +48,7 @@ func NewConfigurationsClient(subscriptionID string, credential azcore.TokenCrede // BeginBatchUpdate - Update a list of configurations in a given server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serverName - The name of the server. // - parameters - The parameters for updating a list of server configuration. @@ -70,7 +71,7 @@ func (client *ConfigurationsClient) BeginBatchUpdate(ctx context.Context, resour // BatchUpdate - Update a list of configurations in a given server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview func (client *ConfigurationsClient) batchUpdate(ctx context.Context, resourceGroupName string, serverName string, parameters ConfigurationListForBatchUpdate, options *ConfigurationsClientBeginBatchUpdateOptions) (*http.Response, error) { req, err := client.batchUpdateCreateRequest(ctx, resourceGroupName, serverName, parameters, options) if err != nil { @@ -106,7 +107,78 @@ func (client *ConfigurationsClient) batchUpdateCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + +// BeginCreateOrUpdate - Updates a configuration of a server. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - configurationName - The name of the server configuration. +// - parameters - The required parameters for updating a server configuration. +// - options - ConfigurationsClientBeginCreateOrUpdateOptions contains the optional parameters for the ConfigurationsClient.BeginCreateOrUpdate +// method. +func (client *ConfigurationsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration, options *ConfigurationsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ConfigurationsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, serverName, configurationName, parameters, options) + if err != nil { + return nil, err + } + return runtime.NewPoller[ConfigurationsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + } else { + return runtime.NewPollerFromResumeToken[ConfigurationsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Updates a configuration of a server. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-12-01-preview +func (client *ConfigurationsClient) createOrUpdate(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration, options *ConfigurationsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serverName, configurationName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ConfigurationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration, options *ConfigurationsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/configurations/{configurationName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + return nil, errors.New("parameter serverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serverName}", url.PathEscape(serverName)) + if configurationName == "" { + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, parameters) @@ -115,7 +187,7 @@ func (client *ConfigurationsClient) batchUpdateCreateRequest(ctx context.Context // Get - Gets information about a configuration of server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview // - 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. @@ -159,7 +231,7 @@ func (client *ConfigurationsClient) getCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -176,7 +248,7 @@ func (client *ConfigurationsClient) getHandleResponse(resp *http.Response) (Conf // NewListByServerPager - List all the configurations in a given server. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview // - 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 @@ -229,7 +301,19 @@ func (client *ConfigurationsClient) listByServerCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2021-12-01-preview") + if options != nil && options.Tags != nil { + reqQP.Set("tags", *options.Tags) + } + if options != nil && options.Keyword != nil { + reqQP.Set("keyword", *options.Keyword) + } + if options != nil && options.Page != nil { + reqQP.Set("page", strconv.FormatInt(int64(*options.Page), 10)) + } + if options != nil && options.PageSize != nil { + reqQP.Set("pageSize", strconv.FormatInt(int64(*options.PageSize), 10)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -247,7 +331,7 @@ func (client *ConfigurationsClient) listByServerHandleResponse(resp *http.Respon // BeginUpdate - Updates a configuration of a server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview // - 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. @@ -269,7 +353,7 @@ func (client *ConfigurationsClient) BeginUpdate(ctx context.Context, resourceGro // Update - Updates a configuration of a server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview func (client *ConfigurationsClient) update(ctx context.Context, resourceGroupName string, serverName string, configurationName string, parameters Configuration, options *ConfigurationsClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, serverName, configurationName, parameters, options) if err != nil { @@ -309,7 +393,7 @@ func (client *ConfigurationsClient) updateCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, parameters) diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/configurations_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/configurations_client_example_test.go index f5470234e5bf..09800f288994 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/configurations_client_example_test.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/configurations_client_example_test.go @@ -15,10 +15,52 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ConfigurationUpdate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/Configurations/preview/2021-12-01-preview/examples/ConfigurationCreateOrUpdate.json +func ExampleConfigurationsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewConfigurationsClient().BeginCreateOrUpdate(ctx, "TestGroup", "testserver", "event_scheduler", armmysqlflexibleservers.Configuration{ + Properties: &armmysqlflexibleservers.ConfigurationProperties{ + Source: to.Ptr(armmysqlflexibleservers.ConfigurationSourceUserOverride), + Value: to.Ptr("off"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Configuration = armmysqlflexibleservers.Configuration{ + // Name: to.Ptr("event_scheduler"), + // Type: to.Ptr("Microsoft.DBforMySQL/servers/configurations"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.DBforMySQL/servers/testserver/configurations/event_scheduler"), + // Properties: &armmysqlflexibleservers.ConfigurationProperties{ + // Description: to.Ptr("Indicates the status of the Event Scheduler."), + // AllowedValues: to.Ptr("ON,OFF,DISABLED"), + // DataType: to.Ptr("Enumeration"), + // DefaultValue: to.Ptr("OFF"), + // Source: to.Ptr(armmysqlflexibleservers.ConfigurationSourceUserOverride), + // Value: to.Ptr("ON"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/Configurations/preview/2021-12-01-preview/examples/ConfigurationUpdate.json func ExampleConfigurationsClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -63,7 +105,7 @@ func ExampleConfigurationsClient_BeginUpdate() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ConfigurationGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/Configurations/preview/2021-12-01-preview/examples/ConfigurationGet.json func ExampleConfigurationsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -99,7 +141,7 @@ func ExampleConfigurationsClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ConfigurationsBatchUpdate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/Configurations/preview/2021-12-01-preview/examples/ConfigurationsBatchUpdate.json func ExampleConfigurationsClient_BeginBatchUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -111,6 +153,7 @@ func ExampleConfigurationsClient_BeginBatchUpdate() { log.Fatalf("failed to create client: %v", err) } poller, err := clientFactory.NewConfigurationsClient().BeginBatchUpdate(ctx, "testrg", "mysqltestserver", armmysqlflexibleservers.ConfigurationListForBatchUpdate{ + ResetAllToDefault: to.Ptr(armmysqlflexibleservers.ResetAllToDefaultFalse), Value: []*armmysqlflexibleservers.ConfigurationForBatchUpdate{ { Name: to.Ptr("event_scheduler"), @@ -172,7 +215,7 @@ func ExampleConfigurationsClient_BeginBatchUpdate() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ConfigurationsListByServer.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/Configurations/preview/2021-12-01-preview/examples/ConfigurationsListByServer.json func ExampleConfigurationsClient_NewListByServerPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -183,7 +226,11 @@ func ExampleConfigurationsClient_NewListByServerPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewConfigurationsClient().NewListByServerPager("testrg", "mysqltestserver", nil) + pager := clientFactory.NewConfigurationsClient().NewListByServerPager("testrg", "mysqltestserver", &armmysqlflexibleservers.ConfigurationsClientListByServerOptions{Tags: nil, + Keyword: nil, + Page: to.Ptr[int32](1), + PageSize: to.Ptr[int32](8), + }) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/constants.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/constants.go index 1fea8e92b078..83e2f7fad93f 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/constants.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/constants.go @@ -11,9 +11,52 @@ package armmysqlflexibleservers const ( moduleName = "armmysqlflexibleservers" - moduleVersion = "v1.1.1" + moduleVersion = "v2.0.0-beta.1" ) +type AdministratorName string + +const ( + AdministratorNameActiveDirectory AdministratorName = "ActiveDirectory" +) + +// PossibleAdministratorNameValues returns the possible values for the AdministratorName const type. +func PossibleAdministratorNameValues() []AdministratorName { + return []AdministratorName{ + AdministratorNameActiveDirectory, + } +} + +// AdministratorType - Type of the sever administrator. +type AdministratorType string + +const ( + AdministratorTypeActiveDirectory AdministratorType = "ActiveDirectory" +) + +// PossibleAdministratorTypeValues returns the possible values for the AdministratorType const type. +func PossibleAdministratorTypeValues() []AdministratorType { + return []AdministratorType{ + AdministratorTypeActiveDirectory, + } +} + +// BackupFormat - Backup Format for the current backup. (CollatedFormat is INTERNAL – DO NOT USE) +type BackupFormat string + +const ( + BackupFormatCollatedFormat BackupFormat = "CollatedFormat" + BackupFormatNone BackupFormat = "None" +) + +// PossibleBackupFormatValues returns the possible values for the BackupFormat const type. +func PossibleBackupFormatValues() []BackupFormat { + return []BackupFormat{ + BackupFormatCollatedFormat, + BackupFormatNone, + } +} + // ConfigurationSource - Source of the configuration. type ConfigurationSource string @@ -190,6 +233,50 @@ func PossibleIsReadOnlyValues() []IsReadOnly { } } +// ManagedServiceIdentityType - Type of managed service identity. +type ManagedServiceIdentityType string + +const ( + ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" +) + +// PossibleManagedServiceIdentityTypeValues returns the possible values for the ManagedServiceIdentityType const type. +func PossibleManagedServiceIdentityTypeValues() []ManagedServiceIdentityType { + return []ManagedServiceIdentityType{ + ManagedServiceIdentityTypeUserAssigned, + } +} + +// OperationStatus - The operation status +type OperationStatus string + +const ( + // OperationStatusPending - The operation has been accepted but hasn't started. + OperationStatusPending OperationStatus = "Pending" + // OperationStatusInProgress - The operation is running + OperationStatusInProgress OperationStatus = "InProgress" + // OperationStatusSucceeded - The operation Succeeded + OperationStatusSucceeded OperationStatus = "Succeeded" + // OperationStatusFailed - The operation Failed + OperationStatusFailed OperationStatus = "Failed" + // OperationStatusCancelInProgress - The cancellation in progress + OperationStatusCancelInProgress OperationStatus = "CancelInProgress" + // OperationStatusCanceled - The operation has been Canceled + OperationStatusCanceled OperationStatus = "Canceled" +) + +// PossibleOperationStatusValues returns the possible values for the OperationStatus const type. +func PossibleOperationStatusValues() []OperationStatus { + return []OperationStatus{ + OperationStatusPending, + OperationStatusInProgress, + OperationStatusSucceeded, + OperationStatusFailed, + OperationStatusCancelInProgress, + OperationStatusCanceled, + } +} + // ReplicationRole - The replication role. type ReplicationRole string @@ -208,6 +295,22 @@ func PossibleReplicationRoleValues() []ReplicationRole { } } +// ResetAllToDefault - Whether to reset all server parameters to default. +type ResetAllToDefault string + +const ( + ResetAllToDefaultFalse ResetAllToDefault = "False" + ResetAllToDefaultTrue ResetAllToDefault = "True" +) + +// PossibleResetAllToDefaultValues returns the possible values for the ResetAllToDefault const type. +func PossibleResetAllToDefaultValues() []ResetAllToDefault { + return []ResetAllToDefault{ + ResetAllToDefaultFalse, + ResetAllToDefaultTrue, + } +} + // SKUTier - The tier of the particular SKU, e.g. GeneralPurpose. type SKUTier string diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/databases_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/databases_client.go index 6c5c0ea45ce3..2f2de50daa32 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/databases_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/databases_client.go @@ -47,7 +47,7 @@ func NewDatabasesClient(subscriptionID string, credential azcore.TokenCredential // BeginCreateOrUpdate - Creates a new database or updates an existing database. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serverName - The name of the server. // - databaseName - The name of the database. @@ -69,7 +69,7 @@ func (client *DatabasesClient) BeginCreateOrUpdate(ctx context.Context, resource // CreateOrUpdate - Creates a new database or updates an existing database. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview func (client *DatabasesClient) createOrUpdate(ctx context.Context, resourceGroupName string, serverName string, databaseName string, parameters Database, options *DatabasesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serverName, databaseName, parameters, options) if err != nil { @@ -109,7 +109,7 @@ func (client *DatabasesClient) createOrUpdateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, parameters) @@ -118,7 +118,7 @@ func (client *DatabasesClient) createOrUpdateCreateRequest(ctx context.Context, // BeginDelete - Deletes a database. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serverName - The name of the server. // - databaseName - The name of the database. @@ -138,7 +138,7 @@ func (client *DatabasesClient) BeginDelete(ctx context.Context, resourceGroupNam // Delete - Deletes a database. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview 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 { @@ -178,7 +178,7 @@ func (client *DatabasesClient) deleteCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -187,7 +187,7 @@ func (client *DatabasesClient) deleteCreateRequest(ctx context.Context, resource // Get - Gets information about a database. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serverName - The name of the server. // - databaseName - The name of the database. @@ -231,7 +231,7 @@ func (client *DatabasesClient) getCreateRequest(ctx context.Context, resourceGro return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -248,7 +248,7 @@ func (client *DatabasesClient) getHandleResponse(resp *http.Response) (Databases // NewListByServerPager - List all the databases in a given server. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview // - 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 @@ -301,7 +301,7 @@ func (client *DatabasesClient) listByServerCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/databases_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/databases_client_example_test.go index 2f67c5698430..ef77b6ef696f 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/databases_client_example_test.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/databases_client_example_test.go @@ -15,10 +15,10 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/DatabaseCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/Databases/preview/2021-12-01-preview/examples/DatabaseCreate.json func ExampleDatabasesClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -56,7 +56,7 @@ func ExampleDatabasesClient_BeginCreateOrUpdate() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/DatabaseDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/Databases/preview/2021-12-01-preview/examples/DatabaseDelete.json func ExampleDatabasesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -77,7 +77,7 @@ func ExampleDatabasesClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/DatabaseGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/Databases/preview/2021-12-01-preview/examples/DatabaseGet.json func ExampleDatabasesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -106,7 +106,7 @@ func ExampleDatabasesClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/DatabasesListByServer.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/Databases/preview/2021-12-01-preview/examples/DatabasesListByServer.json func ExampleDatabasesClient_NewListByServerPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/firewallrules_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/firewallrules_client.go index 5bd4a644560e..31c7024f852b 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/firewallrules_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/firewallrules_client.go @@ -47,7 +47,7 @@ func NewFirewallRulesClient(subscriptionID string, credential azcore.TokenCreden // BeginCreateOrUpdate - Creates a new firewall rule or updates an existing firewall rule. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview // - 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. @@ -69,7 +69,7 @@ func (client *FirewallRulesClient) BeginCreateOrUpdate(ctx context.Context, reso // CreateOrUpdate - Creates a new firewall rule or updates an existing firewall rule. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview 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 { @@ -109,7 +109,7 @@ func (client *FirewallRulesClient) createOrUpdateCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, parameters) @@ -118,7 +118,7 @@ func (client *FirewallRulesClient) createOrUpdateCreateRequest(ctx context.Conte // BeginDelete - Deletes a firewall rule. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview // - 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. @@ -139,7 +139,7 @@ func (client *FirewallRulesClient) BeginDelete(ctx context.Context, resourceGrou // Delete - Deletes a firewall rule. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview 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 { @@ -179,7 +179,7 @@ func (client *FirewallRulesClient) deleteCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -188,7 +188,7 @@ func (client *FirewallRulesClient) deleteCreateRequest(ctx context.Context, reso // Get - Gets information about a server firewall rule. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview // - 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. @@ -232,7 +232,7 @@ func (client *FirewallRulesClient) getCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -249,7 +249,7 @@ func (client *FirewallRulesClient) getHandleResponse(resp *http.Response) (Firew // NewListByServerPager - List all the firewall rules in a given server. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview // - 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 @@ -302,7 +302,7 @@ func (client *FirewallRulesClient) listByServerCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/firewallrules_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/firewallrules_client_example_test.go index b638b2098f41..dd4eb2d03a4c 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/firewallrules_client_example_test.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/firewallrules_client_example_test.go @@ -15,10 +15,10 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/FirewallRuleCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/Firewall/preview/2021-12-01-preview/examples/FirewallRuleCreate.json func ExampleFirewallRulesClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -56,7 +56,7 @@ func ExampleFirewallRulesClient_BeginCreateOrUpdate() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/FirewallRuleDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/Firewall/preview/2021-12-01-preview/examples/FirewallRuleDelete.json func ExampleFirewallRulesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -77,7 +77,7 @@ func ExampleFirewallRulesClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/FirewallRuleGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/Firewall/preview/2021-12-01-preview/examples/FirewallRuleGet.json func ExampleFirewallRulesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -106,7 +106,7 @@ func ExampleFirewallRulesClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/FirewallRulesListByServer.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/Firewall/preview/2021-12-01-preview/examples/FirewallRulesListByServer.json func ExampleFirewallRulesClient_NewListByServerPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/getprivatednszonesuffix_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/getprivatednszonesuffix_client.go index 71a3c30b592c..2eafb540f197 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/getprivatednszonesuffix_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/getprivatednszonesuffix_client.go @@ -41,7 +41,7 @@ func NewGetPrivateDNSZoneSuffixClient(credential azcore.TokenCredential, options // Execute - Get private DNS zone suffix in the cloud. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview // - options - GetPrivateDNSZoneSuffixClientExecuteOptions contains the optional parameters for the GetPrivateDNSZoneSuffixClient.Execute // method. func (client *GetPrivateDNSZoneSuffixClient) Execute(ctx context.Context, options *GetPrivateDNSZoneSuffixClientExecuteOptions) (GetPrivateDNSZoneSuffixClientExecuteResponse, error) { @@ -67,7 +67,7 @@ func (client *GetPrivateDNSZoneSuffixClient) executeCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/getprivatednszonesuffix_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/getprivatednszonesuffix_client_example_test.go index 07a0517be695..dfaa4386b012 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/getprivatednszonesuffix_client_example_test.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/getprivatednszonesuffix_client_example_test.go @@ -14,10 +14,10 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/GetPrivateDnsZoneSuffix.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/ServiceOperations/preview/2021-12-01-preview/examples/GetPrivateDnsZoneSuffix.json func ExampleGetPrivateDNSZoneSuffixClient_Execute() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/go.mod b/sdk/resourcemanager/mysql/armmysqlflexibleservers/go.mod index f91b08d34d5e..521a5db0631d 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/go.mod +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/go.mod @@ -1,4 +1,4 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers/v2 go 1.18 diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/locationbasedcapabilities_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/locationbasedcapabilities_client.go index 33c7c98e52cf..f74c9212886c 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/locationbasedcapabilities_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/locationbasedcapabilities_client.go @@ -46,7 +46,7 @@ func NewLocationBasedCapabilitiesClient(subscriptionID string, credential azcore // NewListPager - Get capabilities at specified location in a given subscription. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview // - locationName - The name of the location. // - options - LocationBasedCapabilitiesClientListOptions contains the optional parameters for the LocationBasedCapabilitiesClient.NewListPager // method. @@ -94,7 +94,7 @@ func (client *LocationBasedCapabilitiesClient) listCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/locationbasedcapabilities_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/locationbasedcapabilities_client_example_test.go index 0d3d408fe5f2..2d5295544e3c 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/locationbasedcapabilities_client_example_test.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/locationbasedcapabilities_client_example_test.go @@ -14,10 +14,10 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/CapabilitiesByLocationList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/ServiceOperations/preview/2021-12-01-preview/examples/CapabilitiesByLocationList.json func ExampleLocationBasedCapabilitiesClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/logfiles_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/logfiles_client.go new file mode 100644 index 000000000000..37bf7fd8285e --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/logfiles_client.go @@ -0,0 +1,115 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armmysqlflexibleservers + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// LogFilesClient contains the methods for the LogFiles group. +// Don't use this type directly, use NewLogFilesClient() instead. +type LogFilesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewLogFilesClient creates a new instance of LogFilesClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewLogFilesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LogFilesClient, error) { + cl, err := arm.NewClient(moduleName+".LogFilesClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &LogFilesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// NewListByServerPager - List all the server log files in a given server. +// +// Generated from API version 2021-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - options - LogFilesClientListByServerOptions contains the optional parameters for the LogFilesClient.NewListByServerPager +// method. +func (client *LogFilesClient) NewListByServerPager(resourceGroupName string, serverName string, options *LogFilesClientListByServerOptions) *runtime.Pager[LogFilesClientListByServerResponse] { + return runtime.NewPager(runtime.PagingHandler[LogFilesClientListByServerResponse]{ + More: func(page LogFilesClientListByServerResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *LogFilesClientListByServerResponse) (LogFilesClientListByServerResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByServerCreateRequest(ctx, resourceGroupName, serverName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return LogFilesClientListByServerResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return LogFilesClientListByServerResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return LogFilesClientListByServerResponse{}, runtime.NewResponseError(resp) + } + return client.listByServerHandleResponse(resp) + }, + }) +} + +// listByServerCreateRequest creates the ListByServer request. +func (client *LogFilesClient) listByServerCreateRequest(ctx context.Context, resourceGroupName string, serverName string, options *LogFilesClientListByServerOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/logFiles" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByServerHandleResponse handles the ListByServer response. +func (client *LogFilesClient) listByServerHandleResponse(resp *http.Response) (LogFilesClientListByServerResponse, error) { + result := LogFilesClientListByServerResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LogFileListResult); err != nil { + return LogFilesClientListByServerResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/logfiles_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/logfiles_client_example_test.go new file mode 100644 index 000000000000..4e08a958ed1b --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/logfiles_client_example_test.go @@ -0,0 +1,58 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armmysqlflexibleservers_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers/v2" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/LogFiles/preview/2021-12-01-preview/examples/LogFilesListByServer.json +func ExampleLogFilesClient_NewListByServerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewLogFilesClient().NewListByServerPager("testrg", "mysqltestsvc1", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.LogFileListResult = armmysqlflexibleservers.LogFileListResult{ + // Value: []*armmysqlflexibleservers.LogFile{ + // { + // Name: to.Ptr("mysql-slow-mysqltestsvc1-2018022823.log"), + // Type: to.Ptr("Microsoft.DBforMySQL/flexibleServers/logFiles"), + // ID: to.Ptr("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBforMySQL/flexibleServers/mysqltestsvc1/logFiles/mysql-slow-mysqltestsvc1-2018022823.log"), + // Properties: &armmysqlflexibleservers.LogFileProperties{ + // Type: to.Ptr("slowlog"), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "0001-01-01T00:00:00+00:00"); return t}()), + // LastModifiedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-01T06:09:20+00:00"); return t}()), + // SizeInKB: to.Ptr[int64](1), + // URL: to.Ptr("https://wasd2prodwus1afse42.file.core.windows.net/833c99b2f36c47349e5554b903fe0440/serverlogs/mysql-slow-mysqltestsvc1-2018022823.log?sv=2015-04-05&sr=f&sig=D9Ga4N5Pa%2BPe5Bmjpvs7A0TPD%2FF7IZpk9e4KWR0jgpM%3D&se=2018-03-01T07%3A12%3A13Z&sp=r"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/models.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/models.go index 92828f6d2984..2d5ddf12603e 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/models.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/models.go @@ -11,6 +11,76 @@ package armmysqlflexibleservers import "time" +// AdministratorListResult - A List of azure ad administrators. +type AdministratorListResult struct { + // The link used to get the next page of operations. + NextLink *string + + // The list of azure ad administrator of a server + Value []*AzureADAdministrator +} + +// AdministratorProperties - The properties of an administrator. +type AdministratorProperties struct { + // Type of the sever administrator. + AdministratorType *AdministratorType + + // The resource id of the identity used for AAD Authentication. + IdentityResourceID *string + + // Login name of the server administrator. + Login *string + + // SID (object ID) of the server administrator. + Sid *string + + // Tenant ID of the administrator. + TenantID *string +} + +// AzureADAdministrator - Represents a Administrator. +type AzureADAdministrator struct { + // The properties of an administrator. + Properties *AdministratorProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// AzureADAdministratorsClientBeginCreateOrUpdateOptions contains the optional parameters for the AzureADAdministratorsClient.BeginCreateOrUpdate +// method. +type AzureADAdministratorsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// AzureADAdministratorsClientBeginDeleteOptions contains the optional parameters for the AzureADAdministratorsClient.BeginDelete +// method. +type AzureADAdministratorsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// AzureADAdministratorsClientGetOptions contains the optional parameters for the AzureADAdministratorsClient.Get method. +type AzureADAdministratorsClientGetOptions struct { + // placeholder for future optional parameters +} + +// AzureADAdministratorsClientListByServerOptions contains the optional parameters for the AzureADAdministratorsClient.NewListByServerPager +// method. +type AzureADAdministratorsClientListByServerOptions struct { + // placeholder for future optional parameters +} + // Backup - Storage Profile properties of a server type Backup struct { // Backup retention days for the server. @@ -23,6 +93,102 @@ type Backup struct { EarliestRestoreDate *time.Time } +// BackupAndExportClientBeginCreateOptions contains the optional parameters for the BackupAndExportClient.BeginCreate method. +type BackupAndExportClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// BackupAndExportClientValidateBackupOptions contains the optional parameters for the BackupAndExportClient.ValidateBackup +// method. +type BackupAndExportClientValidateBackupOptions struct { + // placeholder for future optional parameters +} + +// BackupAndExportRequest - BackupAndExport API Request +type BackupAndExportRequest struct { + // REQUIRED; Backup Settings + BackupSettings *BackupSettings + + // REQUIRED; Backup Target Store Details + TargetDetails BackupStoreDetailsClassification +} + +// BackupAndExportResponse - Represents BackupAndExport API Response +type BackupAndExportResponse struct { + // End time + EndTime *time.Time + + // The BackupAndExport operation error response. + Error *ErrorResponse + + // Operation progress (0-100). + PercentComplete *float64 + + // The response properties of a backup and export operation. + Properties *BackupAndExportResponseProperties + + // Start time + StartTime *time.Time + + // The operation status + Status *OperationStatus + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// BackupAndExportResponseProperties - BackupAndExport Response Properties +type BackupAndExportResponseProperties struct { + // Metadata related to backup to be stored for restoring resource in key-value pairs. + BackupMetadata *string + + // Data transferred in bytes + DataTransferredInBytes *int64 + + // Size of datasource in bytes + DatasourceSizeInBytes *int64 +} + +// BackupRequestBase is the base for all backup request. +type BackupRequestBase struct { + // REQUIRED; Backup Settings + BackupSettings *BackupSettings +} + +// BackupSettings - Backup Settings +type BackupSettings struct { + // REQUIRED; The name of the backup. + BackupName *string + + // Backup Format for the current backup. (CollatedFormat is INTERNAL – DO NOT USE) + BackupFormat *BackupFormat +} + +// BackupStoreDetailsClassification provides polymorphic access to related types. +// Call the interface's GetBackupStoreDetails() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *BackupStoreDetails, *FullBackupStoreDetails +type BackupStoreDetailsClassification interface { + // GetBackupStoreDetails returns the BackupStoreDetails content of the underlying type. + GetBackupStoreDetails() *BackupStoreDetails +} + +// BackupStoreDetails - Details about the target where the backup content will be stored. +type BackupStoreDetails struct { + // REQUIRED; Type of the specific object - used for deserializing + ObjectType *string +} + +// GetBackupStoreDetails implements the BackupStoreDetailsClassification interface for type BackupStoreDetails. +func (b *BackupStoreDetails) GetBackupStoreDetails() *BackupStoreDetails { return b } + // BackupsClientGetOptions contains the optional parameters for the BackupsClient.Get method. type BackupsClientGetOptions struct { // placeholder for future optional parameters @@ -33,6 +199,11 @@ type BackupsClientListByServerOptions struct { // placeholder for future optional parameters } +// BackupsClientPutOptions contains the optional parameters for the BackupsClient.Put method. +type BackupsClientPutOptions struct { + // placeholder for future optional parameters +} + // CapabilitiesListResult - location capability type CapabilitiesListResult struct { // READ-ONLY; Link to retrieve next page of results. @@ -63,6 +234,12 @@ type CheckNameAvailabilityClientExecuteOptions struct { // placeholder for future optional parameters } +// CheckNameAvailabilityWithoutLocationClientExecuteOptions contains the optional parameters for the CheckNameAvailabilityWithoutLocationClient.Execute +// method. +type CheckNameAvailabilityWithoutLocationClientExecuteOptions struct { + // placeholder for future optional parameters +} + // CheckVirtualNetworkSubnetUsageClientExecuteOptions contains the optional parameters for the CheckVirtualNetworkSubnetUsageClient.Execute // method. type CheckVirtualNetworkSubnetUsageClientExecuteOptions struct { @@ -107,6 +284,9 @@ type ConfigurationForBatchUpdateProperties struct { // ConfigurationListForBatchUpdate - A list of server configurations to update. type ConfigurationListForBatchUpdate struct { + // Whether to reset all server parameters to default. + ResetAllToDefault *ResetAllToDefault + // The list of server configurations. Value []*ConfigurationForBatchUpdate } @@ -122,6 +302,9 @@ type ConfigurationListResult struct { // ConfigurationProperties - The properties of a configuration. type ConfigurationProperties struct { + // Current value of the configuration. + CurrentValue *string + // Source of the configuration. Source *ConfigurationSource @@ -140,6 +323,9 @@ type ConfigurationProperties struct { // READ-ONLY; Description of the configuration. Description *string + // READ-ONLY; The link used to get the document from community or Azure site. + DocumentationLink *string + // READ-ONLY; If is the configuration pending restart or not. IsConfigPendingRestart *IsConfigPendingRestart @@ -157,6 +343,13 @@ type ConfigurationsClientBeginBatchUpdateOptions struct { ResumeToken string } +// ConfigurationsClientBeginCreateOrUpdateOptions contains the optional parameters for the ConfigurationsClient.BeginCreateOrUpdate +// method. +type ConfigurationsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + // ConfigurationsClientBeginUpdateOptions contains the optional parameters for the ConfigurationsClient.BeginUpdate method. type ConfigurationsClientBeginUpdateOptions struct { // Resumes the LRO from the provided token. @@ -171,7 +364,14 @@ type ConfigurationsClientGetOptions struct { // ConfigurationsClientListByServerOptions contains the optional parameters for the ConfigurationsClient.NewListByServerPager // method. type ConfigurationsClientListByServerOptions struct { - // placeholder for future optional parameters + // The keyword of the server configuration. + Keyword *string + // The page of the server configuration. + Page *int32 + // The pageSize of the server configuration. + PageSize *int32 + // The tags of the server configuration. + Tags *string } // DataEncryption - The date encryption for cmk. @@ -348,6 +548,22 @@ type FirewallRulesClientListByServerOptions struct { // placeholder for future optional parameters } +// FullBackupStoreDetails is used for scenarios where backup data is streamed/copied over to a storage destination. +type FullBackupStoreDetails struct { + // REQUIRED; Type of the specific object - used for deserializing + ObjectType *string + + // REQUIRED; SASUriList of storage containers where backup data is to be streamed/copied. + SasURIList []*string +} + +// GetBackupStoreDetails implements the BackupStoreDetailsClassification interface for type FullBackupStoreDetails. +func (f *FullBackupStoreDetails) GetBackupStoreDetails() *BackupStoreDetails { + return &BackupStoreDetails{ + ObjectType: f.ObjectType, + } +} + // GetPrivateDNSZoneSuffixClientExecuteOptions contains the optional parameters for the GetPrivateDNSZoneSuffixClient.Execute // method. type GetPrivateDNSZoneSuffixClientExecuteOptions struct { @@ -375,7 +591,7 @@ type HighAvailability struct { // Identity - Properties to configure Identity for Bring your Own Keys type Identity struct { // Type of managed service identity. - Type *string + Type *ManagedServiceIdentityType // Metadata of user assigned identity. UserAssignedIdentities map[string]any @@ -393,6 +609,56 @@ type LocationBasedCapabilitiesClientListOptions struct { // placeholder for future optional parameters } +// LogFile - Represents a logFile. +type LogFile struct { + // The properties of a logFile. + Properties *LogFileProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The system metadata relating to this resource. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// LogFileListResult - A List of logFiles. +type LogFileListResult struct { + // The link used to get the next page of operations. + NextLink *string + + // The list of logFiles in a server + Value []*LogFile +} + +// LogFileProperties - The properties of a logFile. +type LogFileProperties struct { + // Creation timestamp of the log file. + CreatedTime *time.Time + + // Last modified timestamp of the log file. + LastModifiedTime *time.Time + + // The size in kb of the logFile. + SizeInKB *int64 + + // Type of the log file. + Type *string + + // The url to download the log file from. + URL *string +} + +// LogFilesClientListByServerOptions contains the optional parameters for the LogFilesClient.NewListByServerPager method. +type LogFilesClientListByServerOptions struct { + // placeholder for future optional parameters +} + // MaintenanceWindow - Maintenance window of a server. type MaintenanceWindow struct { // indicates whether custom window is enabled or disabled @@ -437,7 +703,7 @@ type Network struct { // Private DNS zone resource id. PrivateDNSZoneResourceID *string - // READ-ONLY; Whether or not public network access is allowed for this server. Value is 'Disabled' when server has VNet integration. + // Whether or not public network access is allowed for this server. Value is 'Disabled' when server has VNet integration. PublicNetworkAccess *EnableStatusEnum } @@ -635,6 +901,12 @@ type ServerForUpdate struct { Tags map[string]*string } +// ServerGtidSetParameter - Server gtid set parameters. +type ServerGtidSetParameter struct { + // The gtid set of server. + GtidSet *string +} + // ServerListResult - A list of servers. type ServerListResult struct { // The link used to get the next page of operations. @@ -721,6 +993,9 @@ type ServerPropertiesForUpdate struct { // Storage related properties of a server. Storage *Storage + + // Server version. + Version *ServerVersion } // ServerRestartParameter - Server restart parameters. @@ -759,6 +1034,12 @@ type ServersClientBeginFailoverOptions struct { ResumeToken string } +// ServersClientBeginResetGtidOptions contains the optional parameters for the ServersClient.BeginResetGtid method. +type ServersClientBeginResetGtidOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + // ServersClientBeginRestartOptions contains the optional parameters for the ServersClient.BeginRestart method. type ServersClientBeginRestartOptions struct { // Resumes the LRO from the provided token. @@ -804,9 +1085,15 @@ type Storage struct { // Enable Storage Auto Grow or not. AutoGrow *EnableStatusEnum + // Enable IO Auto Scaling or not. + AutoIoScaling *EnableStatusEnum + // Storage IOPS for a server. Iops *int32 + // Enable Log On Disk or not. + LogOnDisk *EnableStatusEnum + // Max storage size allowed for a server. StorageSizeGB *int32 @@ -881,6 +1168,18 @@ type UserAssignedIdentity struct { PrincipalID *string } +// ValidateBackupResponse - Represents ValidateBackup API Response +type ValidateBackupResponse struct { + // The response properties of a pre backup operation. + Properties *ValidateBackupResponseProperties +} + +// ValidateBackupResponseProperties - ValidateBackup Response Properties +type ValidateBackupResponseProperties struct { + // Estimated no of storage containers required for resource data to be backed up. + NumberOfContainers *int32 +} + // VirtualNetworkSubnetUsageParameter - Virtual network subnet usage parameter type VirtualNetworkSubnetUsageParameter struct { // Virtual network resource id. @@ -891,4 +1190,10 @@ type VirtualNetworkSubnetUsageParameter struct { type VirtualNetworkSubnetUsageResult struct { // READ-ONLY; A list of delegated subnet usage DelegatedSubnetsUsage []*DelegatedSubnetUsage + + // READ-ONLY; The location name. + Location *string + + // READ-ONLY; The subscription id. + SubscriptionID *string } diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/models_serde.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/models_serde.go index 77975d9b499f..69d72d4a673d 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/models_serde.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/models_serde.go @@ -16,6 +16,123 @@ import ( "reflect" ) +// MarshalJSON implements the json.Marshaller interface for type AdministratorListResult. +func (a AdministratorListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AdministratorListResult. +func (a *AdministratorListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AdministratorProperties. +func (a AdministratorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "administratorType", a.AdministratorType) + populate(objectMap, "identityResourceId", a.IdentityResourceID) + populate(objectMap, "login", a.Login) + populate(objectMap, "sid", a.Sid) + populate(objectMap, "tenantId", a.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AdministratorProperties. +func (a *AdministratorProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "administratorType": + err = unpopulate(val, "AdministratorType", &a.AdministratorType) + delete(rawMsg, key) + case "identityResourceId": + err = unpopulate(val, "IdentityResourceID", &a.IdentityResourceID) + delete(rawMsg, key) + case "login": + err = unpopulate(val, "Login", &a.Login) + delete(rawMsg, key) + case "sid": + err = unpopulate(val, "Sid", &a.Sid) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &a.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AzureADAdministrator. +func (a AzureADAdministrator) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureADAdministrator. +func (a *AzureADAdministrator) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Backup. func (b Backup) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -51,6 +168,216 @@ func (b *Backup) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type BackupAndExportRequest. +func (b BackupAndExportRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "backupSettings", b.BackupSettings) + populate(objectMap, "targetDetails", b.TargetDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BackupAndExportRequest. +func (b *BackupAndExportRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "backupSettings": + err = unpopulate(val, "BackupSettings", &b.BackupSettings) + delete(rawMsg, key) + case "targetDetails": + b.TargetDetails, err = unmarshalBackupStoreDetailsClassification(val) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BackupAndExportResponse. +func (b BackupAndExportResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "endTime", b.EndTime) + populate(objectMap, "error", b.Error) + populate(objectMap, "id", b.ID) + populate(objectMap, "name", b.Name) + populate(objectMap, "percentComplete", b.PercentComplete) + populate(objectMap, "properties", b.Properties) + populateTimeRFC3339(objectMap, "startTime", b.StartTime) + populate(objectMap, "status", b.Status) + populate(objectMap, "type", b.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BackupAndExportResponse. +func (b *BackupAndExportResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endTime": + err = unpopulateTimeRFC3339(val, "EndTime", &b.EndTime) + delete(rawMsg, key) + case "error": + err = unpopulate(val, "Error", &b.Error) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &b.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &b.Name) + delete(rawMsg, key) + case "percentComplete": + err = unpopulate(val, "PercentComplete", &b.PercentComplete) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &b.Properties) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &b.StartTime) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &b.Status) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &b.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BackupAndExportResponseProperties. +func (b BackupAndExportResponseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "backupMetadata", b.BackupMetadata) + populate(objectMap, "dataTransferredInBytes", b.DataTransferredInBytes) + populate(objectMap, "datasourceSizeInBytes", b.DatasourceSizeInBytes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BackupAndExportResponseProperties. +func (b *BackupAndExportResponseProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "backupMetadata": + err = unpopulate(val, "BackupMetadata", &b.BackupMetadata) + delete(rawMsg, key) + case "dataTransferredInBytes": + err = unpopulate(val, "DataTransferredInBytes", &b.DataTransferredInBytes) + delete(rawMsg, key) + case "datasourceSizeInBytes": + err = unpopulate(val, "DatasourceSizeInBytes", &b.DatasourceSizeInBytes) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BackupRequestBase. +func (b BackupRequestBase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "backupSettings", b.BackupSettings) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BackupRequestBase. +func (b *BackupRequestBase) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "backupSettings": + err = unpopulate(val, "BackupSettings", &b.BackupSettings) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BackupSettings. +func (b BackupSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "backupFormat", b.BackupFormat) + populate(objectMap, "backupName", b.BackupName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BackupSettings. +func (b *BackupSettings) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "backupFormat": + err = unpopulate(val, "BackupFormat", &b.BackupFormat) + delete(rawMsg, key) + case "backupName": + err = unpopulate(val, "BackupName", &b.BackupName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BackupStoreDetails. +func (b BackupStoreDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["objectType"] = b.ObjectType + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BackupStoreDetails. +func (b *BackupStoreDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "objectType": + err = unpopulate(val, "ObjectType", &b.ObjectType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type CapabilitiesListResult. func (c CapabilitiesListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -229,6 +556,7 @@ func (c *ConfigurationForBatchUpdateProperties) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type ConfigurationListForBatchUpdate. func (c ConfigurationListForBatchUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "resetAllToDefault", c.ResetAllToDefault) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) } @@ -242,6 +570,9 @@ func (c *ConfigurationListForBatchUpdate) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "resetAllToDefault": + err = unpopulate(val, "ResetAllToDefault", &c.ResetAllToDefault) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &c.Value) delete(rawMsg, key) @@ -288,9 +619,11 @@ func (c *ConfigurationListResult) UnmarshalJSON(data []byte) error { func (c ConfigurationProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "allowedValues", c.AllowedValues) + populate(objectMap, "currentValue", c.CurrentValue) populate(objectMap, "dataType", c.DataType) populate(objectMap, "defaultValue", c.DefaultValue) populate(objectMap, "description", c.Description) + populate(objectMap, "documentationLink", c.DocumentationLink) populate(objectMap, "isConfigPendingRestart", c.IsConfigPendingRestart) populate(objectMap, "isDynamicConfig", c.IsDynamicConfig) populate(objectMap, "isReadOnly", c.IsReadOnly) @@ -311,6 +644,9 @@ func (c *ConfigurationProperties) UnmarshalJSON(data []byte) error { case "allowedValues": err = unpopulate(val, "AllowedValues", &c.AllowedValues) delete(rawMsg, key) + case "currentValue": + err = unpopulate(val, "CurrentValue", &c.CurrentValue) + delete(rawMsg, key) case "dataType": err = unpopulate(val, "DataType", &c.DataType) delete(rawMsg, key) @@ -320,6 +656,9 @@ func (c *ConfigurationProperties) UnmarshalJSON(data []byte) error { case "description": err = unpopulate(val, "Description", &c.Description) delete(rawMsg, key) + case "documentationLink": + err = unpopulate(val, "DocumentationLink", &c.DocumentationLink) + delete(rawMsg, key) case "isConfigPendingRestart": err = unpopulate(val, "IsConfigPendingRestart", &c.IsConfigPendingRestart) delete(rawMsg, key) @@ -346,9 +685,9 @@ 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]any) - populate(objectMap, "geoBackupKeyUri", d.GeoBackupKeyURI) + populate(objectMap, "geoBackupKeyURI", d.GeoBackupKeyURI) populate(objectMap, "geoBackupUserAssignedIdentityId", d.GeoBackupUserAssignedIdentityID) - populate(objectMap, "primaryKeyUri", d.PrimaryKeyURI) + populate(objectMap, "primaryKeyURI", d.PrimaryKeyURI) populate(objectMap, "primaryUserAssignedIdentityId", d.PrimaryUserAssignedIdentityID) populate(objectMap, "type", d.Type) return json.Marshal(objectMap) @@ -363,13 +702,13 @@ func (d *DataEncryption) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "geoBackupKeyUri": + case "geoBackupKeyURI": err = unpopulate(val, "GeoBackupKeyURI", &d.GeoBackupKeyURI) delete(rawMsg, key) case "geoBackupUserAssignedIdentityId": err = unpopulate(val, "GeoBackupUserAssignedIdentityID", &d.GeoBackupUserAssignedIdentityID) delete(rawMsg, key) - case "primaryKeyUri": + case "primaryKeyURI": err = unpopulate(val, "PrimaryKeyURI", &d.PrimaryKeyURI) delete(rawMsg, key) case "primaryUserAssignedIdentityId": @@ -701,6 +1040,37 @@ func (f *FirewallRuleProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type FullBackupStoreDetails. +func (f FullBackupStoreDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["objectType"] = "FullBackupStoreDetails" + populate(objectMap, "sasUriList", f.SasURIList) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FullBackupStoreDetails. +func (f *FullBackupStoreDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "objectType": + err = unpopulate(val, "ObjectType", &f.ObjectType) + delete(rawMsg, key) + case "sasUriList": + err = unpopulate(val, "SasURIList", &f.SasURIList) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type GetPrivateDNSZoneSuffixResponse. func (g GetPrivateDNSZoneSuffixResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -768,7 +1138,7 @@ func (i Identity) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "principalId", i.PrincipalID) populate(objectMap, "tenantId", i.TenantID) - objectMap["type"] = "UserAssigned" + populate(objectMap, "type", i.Type) populate(objectMap, "userAssignedIdentities", i.UserAssignedIdentities) return json.Marshal(objectMap) } @@ -802,6 +1172,123 @@ func (i *Identity) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type LogFile. +func (l LogFile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", l.ID) + populate(objectMap, "name", l.Name) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "systemData", l.SystemData) + populate(objectMap, "type", l.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogFile. +func (l *LogFile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &l.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &l.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &l.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &l.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &l.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LogFileListResult. +func (l LogFileListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogFileListResult. +func (l *LogFileListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &l.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &l.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LogFileProperties. +func (l LogFileProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdTime", l.CreatedTime) + populateTimeRFC3339(objectMap, "lastModifiedTime", l.LastModifiedTime) + populate(objectMap, "sizeInKB", l.SizeInKB) + populate(objectMap, "type", l.Type) + populate(objectMap, "url", l.URL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LogFileProperties. +func (l *LogFileProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdTime": + err = unpopulateTimeRFC3339(val, "CreatedTime", &l.CreatedTime) + delete(rawMsg, key) + case "lastModifiedTime": + err = unpopulateTimeRFC3339(val, "LastModifiedTime", &l.LastModifiedTime) + delete(rawMsg, key) + case "sizeInKB": + err = unpopulate(val, "SizeInKB", &l.SizeInKB) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &l.Type) + delete(rawMsg, key) + case "url": + err = unpopulate(val, "URL", &l.URL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type MaintenanceWindow. func (m MaintenanceWindow) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1433,6 +1920,33 @@ func (s *ServerForUpdate) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ServerGtidSetParameter. +func (s ServerGtidSetParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "gtidSet", s.GtidSet) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ServerGtidSetParameter. +func (s *ServerGtidSetParameter) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "gtidSet": + err = unpopulate(val, "GtidSet", &s.GtidSet) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ServerListResult. func (s ServerListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1565,6 +2079,7 @@ func (s ServerPropertiesForUpdate) MarshalJSON() ([]byte, error) { populate(objectMap, "maintenanceWindow", s.MaintenanceWindow) populate(objectMap, "replicationRole", s.ReplicationRole) populate(objectMap, "storage", s.Storage) + populate(objectMap, "version", s.Version) return json.Marshal(objectMap) } @@ -1598,6 +2113,9 @@ func (s *ServerPropertiesForUpdate) UnmarshalJSON(data []byte) error { case "storage": err = unpopulate(val, "Storage", &s.Storage) delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &s.Version) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", s, err) @@ -1672,7 +2190,9 @@ func (s *ServerVersionCapability) UnmarshalJSON(data []byte) error { func (s Storage) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "autoGrow", s.AutoGrow) + populate(objectMap, "autoIoScaling", s.AutoIoScaling) populate(objectMap, "iops", s.Iops) + populate(objectMap, "logOnDisk", s.LogOnDisk) populate(objectMap, "storageSku", s.StorageSKU) populate(objectMap, "storageSizeGB", s.StorageSizeGB) return json.Marshal(objectMap) @@ -1690,9 +2210,15 @@ func (s *Storage) UnmarshalJSON(data []byte) error { case "autoGrow": err = unpopulate(val, "AutoGrow", &s.AutoGrow) delete(rawMsg, key) + case "autoIoScaling": + err = unpopulate(val, "AutoIoScaling", &s.AutoIoScaling) + delete(rawMsg, key) case "iops": err = unpopulate(val, "Iops", &s.Iops) delete(rawMsg, key) + case "logOnDisk": + err = unpopulate(val, "LogOnDisk", &s.LogOnDisk) + delete(rawMsg, key) case "storageSku": err = unpopulate(val, "StorageSKU", &s.StorageSKU) delete(rawMsg, key) @@ -1871,6 +2397,60 @@ func (u *UserAssignedIdentity) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ValidateBackupResponse. +func (v ValidateBackupResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", v.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ValidateBackupResponse. +func (v *ValidateBackupResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &v.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ValidateBackupResponseProperties. +func (v ValidateBackupResponseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "numberOfContainers", v.NumberOfContainers) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ValidateBackupResponseProperties. +func (v *ValidateBackupResponseProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "numberOfContainers": + err = unpopulate(val, "NumberOfContainers", &v.NumberOfContainers) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type VirtualNetworkSubnetUsageParameter. func (v VirtualNetworkSubnetUsageParameter) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1902,6 +2482,8 @@ func (v *VirtualNetworkSubnetUsageParameter) UnmarshalJSON(data []byte) error { func (v VirtualNetworkSubnetUsageResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "delegatedSubnetsUsage", v.DelegatedSubnetsUsage) + populate(objectMap, "location", v.Location) + populate(objectMap, "subscriptionId", v.SubscriptionID) return json.Marshal(objectMap) } @@ -1917,6 +2499,12 @@ func (v *VirtualNetworkSubnetUsageResult) UnmarshalJSON(data []byte) error { case "delegatedSubnetsUsage": err = unpopulate(val, "DelegatedSubnetsUsage", &v.DelegatedSubnetsUsage) delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &v.Location) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &v.SubscriptionID) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", v, err) diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/operations_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/operations_client.go index 8daaa3b82d47..6a41d144936e 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/operations_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/operations_client.go @@ -40,7 +40,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - Lists all of the available REST API operations. // -// Generated from API version 2021-05-01 +// Generated from API version 2021-12-01-preview // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ @@ -78,7 +78,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2021-12-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/operations_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/operations_client_example_test.go index 3e71889096dc..0744ec661e32 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/operations_client_example_test.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/operations_client_example_test.go @@ -14,10 +14,10 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/OperationsList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/ServiceOperations/preview/2021-12-01-preview/examples/OperationsList.json func ExampleOperationsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/polymorphic_helpers.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/polymorphic_helpers.go new file mode 100644 index 000000000000..97646202e955 --- /dev/null +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/polymorphic_helpers.go @@ -0,0 +1,30 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armmysqlflexibleservers + +import "encoding/json" + +func unmarshalBackupStoreDetailsClassification(rawMsg json.RawMessage) (BackupStoreDetailsClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b BackupStoreDetailsClassification + switch m["objectType"] { + case "FullBackupStoreDetails": + b = &FullBackupStoreDetails{} + default: + b = &BackupStoreDetails{} + } + return b, json.Unmarshal(rawMsg, b) +} diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/replicas_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/replicas_client.go index 755f87e68205..bf2d44ce5507 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/replicas_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/replicas_client.go @@ -46,7 +46,7 @@ func NewReplicasClient(subscriptionID string, credential azcore.TokenCredential, // NewListByServerPager - List all the replicas for a given server. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview // - 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 @@ -99,7 +99,7 @@ func (client *ReplicasClient) listByServerCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-09-30-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/replicas_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/replicas_client_example_test.go index 70eb44a6e31d..6cbb470187c9 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/replicas_client_example_test.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/replicas_client_example_test.go @@ -14,10 +14,10 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ReplicasListByServer.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2022-09-30-preview/examples/ReplicasListByServer.json func ExampleReplicasClient_NewListByServerPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/response_types.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/response_types.go index 1f95c4eba075..c7a96c2efc10 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/response_types.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/response_types.go @@ -9,6 +9,36 @@ package armmysqlflexibleservers +// AzureADAdministratorsClientCreateOrUpdateResponse contains the response from method AzureADAdministratorsClient.BeginCreateOrUpdate. +type AzureADAdministratorsClientCreateOrUpdateResponse struct { + AzureADAdministrator +} + +// AzureADAdministratorsClientDeleteResponse contains the response from method AzureADAdministratorsClient.BeginDelete. +type AzureADAdministratorsClientDeleteResponse struct { + // placeholder for future response values +} + +// AzureADAdministratorsClientGetResponse contains the response from method AzureADAdministratorsClient.Get. +type AzureADAdministratorsClientGetResponse struct { + AzureADAdministrator +} + +// AzureADAdministratorsClientListByServerResponse contains the response from method AzureADAdministratorsClient.NewListByServerPager. +type AzureADAdministratorsClientListByServerResponse struct { + AdministratorListResult +} + +// BackupAndExportClientCreateResponse contains the response from method BackupAndExportClient.BeginCreate. +type BackupAndExportClientCreateResponse struct { + BackupAndExportResponse +} + +// BackupAndExportClientValidateBackupResponse contains the response from method BackupAndExportClient.ValidateBackup. +type BackupAndExportClientValidateBackupResponse struct { + ValidateBackupResponse +} + // BackupsClientGetResponse contains the response from method BackupsClient.Get. type BackupsClientGetResponse struct { ServerBackup @@ -19,11 +49,21 @@ type BackupsClientListByServerResponse struct { ServerBackupListResult } +// BackupsClientPutResponse contains the response from method BackupsClient.Put. +type BackupsClientPutResponse struct { + ServerBackup +} + // CheckNameAvailabilityClientExecuteResponse contains the response from method CheckNameAvailabilityClient.Execute. type CheckNameAvailabilityClientExecuteResponse struct { NameAvailability } +// CheckNameAvailabilityWithoutLocationClientExecuteResponse contains the response from method CheckNameAvailabilityWithoutLocationClient.Execute. +type CheckNameAvailabilityWithoutLocationClientExecuteResponse struct { + NameAvailability +} + // CheckVirtualNetworkSubnetUsageClientExecuteResponse contains the response from method CheckVirtualNetworkSubnetUsageClient.Execute. type CheckVirtualNetworkSubnetUsageClientExecuteResponse struct { VirtualNetworkSubnetUsageResult @@ -34,6 +74,11 @@ type ConfigurationsClientBatchUpdateResponse struct { ConfigurationListResult } +// ConfigurationsClientCreateOrUpdateResponse contains the response from method ConfigurationsClient.BeginCreateOrUpdate. +type ConfigurationsClientCreateOrUpdateResponse struct { + Configuration +} + // ConfigurationsClientGetResponse contains the response from method ConfigurationsClient.Get. type ConfigurationsClientGetResponse struct { Configuration @@ -99,6 +144,11 @@ type LocationBasedCapabilitiesClientListResponse struct { CapabilitiesListResult } +// LogFilesClientListByServerResponse contains the response from method LogFilesClient.NewListByServerPager. +type LogFilesClientListByServerResponse struct { + LogFileListResult +} + // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationListResult @@ -139,6 +189,11 @@ type ServersClientListResponse struct { ServerListResult } +// ServersClientResetGtidResponse contains the response from method ServersClient.BeginResetGtid. +type ServersClientResetGtidResponse struct { + // placeholder for future response values +} + // ServersClientRestartResponse contains the response from method ServersClient.BeginRestart. type ServersClientRestartResponse struct { // placeholder for future response values diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/servers_client.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/servers_client.go index 2cb55bbc4ecd..19cac3c35e4f 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/servers_client.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/servers_client.go @@ -47,7 +47,7 @@ func NewServersClient(subscriptionID string, credential azcore.TokenCredential, // BeginCreate - Creates a new server or updates an existing server. The update action will overwrite the existing server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview // - 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. @@ -67,7 +67,7 @@ func (client *ServersClient) BeginCreate(ctx context.Context, resourceGroupName // Create - Creates a new server or updates an existing server. The update action will overwrite the existing server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview 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 { @@ -103,7 +103,7 @@ func (client *ServersClient) createCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-09-30-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, parameters) @@ -112,7 +112,7 @@ func (client *ServersClient) createCreateRequest(ctx context.Context, resourceGr // BeginDelete - Deletes a server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview // - 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. @@ -122,7 +122,9 @@ func (client *ServersClient) BeginDelete(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller[ServersClientDeleteResponse](resp, client.internal.Pipeline(), nil) + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ServersClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) } else { return runtime.NewPollerFromResumeToken[ServersClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -131,7 +133,7 @@ func (client *ServersClient) BeginDelete(ctx context.Context, resourceGroupName // Delete - Deletes a server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview 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 { @@ -167,7 +169,7 @@ func (client *ServersClient) deleteCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-09-30-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -176,7 +178,7 @@ func (client *ServersClient) deleteCreateRequest(ctx context.Context, resourceGr // BeginFailover - Manual failover a server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serverName - The name of the server. // - options - ServersClientBeginFailoverOptions contains the optional parameters for the ServersClient.BeginFailover method. @@ -195,7 +197,7 @@ func (client *ServersClient) BeginFailover(ctx context.Context, resourceGroupNam // Failover - Manual failover a server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview func (client *ServersClient) failover(ctx context.Context, resourceGroupName string, serverName string, options *ServersClientBeginFailoverOptions) (*http.Response, error) { req, err := client.failoverCreateRequest(ctx, resourceGroupName, serverName, options) if err != nil { @@ -231,7 +233,7 @@ func (client *ServersClient) failoverCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-09-30-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -240,7 +242,7 @@ func (client *ServersClient) failoverCreateRequest(ctx context.Context, resource // Get - Gets information about a server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview // - 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. @@ -279,7 +281,7 @@ func (client *ServersClient) getCreateRequest(ctx context.Context, resourceGroup return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-09-30-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -296,7 +298,7 @@ func (client *ServersClient) getHandleResponse(resp *http.Response) (ServersClie // NewListPager - List all the servers in a given subscription. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview // - 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]{ @@ -338,7 +340,7 @@ func (client *ServersClient) listCreateRequest(ctx context.Context, options *Ser return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-09-30-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -355,7 +357,7 @@ func (client *ServersClient) listHandleResponse(resp *http.Response) (ServersCli // NewListByResourceGroupPager - List all the servers in a given resource group. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ServersClientListByResourceGroupOptions contains the optional parameters for the ServersClient.NewListByResourceGroupPager // method. @@ -403,7 +405,7 @@ func (client *ServersClient) listByResourceGroupCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-09-30-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -418,10 +420,77 @@ func (client *ServersClient) listByResourceGroupHandleResponse(resp *http.Respon return result, nil } +// BeginResetGtid - Resets GTID on a server. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-30-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - serverName - The name of the server. +// - parameters - The required parameters for resetting GTID on a server. +// - options - ServersClientBeginResetGtidOptions contains the optional parameters for the ServersClient.BeginResetGtid method. +func (client *ServersClient) BeginResetGtid(ctx context.Context, resourceGroupName string, serverName string, parameters ServerGtidSetParameter, options *ServersClientBeginResetGtidOptions) (*runtime.Poller[ServersClientResetGtidResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.resetGtid(ctx, resourceGroupName, serverName, parameters, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ServersClientResetGtidResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[ServersClientResetGtidResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// ResetGtid - Resets GTID on a server. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-09-30-preview +func (client *ServersClient) resetGtid(ctx context.Context, resourceGroupName string, serverName string, parameters ServerGtidSetParameter, options *ServersClientBeginResetGtidOptions) (*http.Response, error) { + req, err := client.resetGtidCreateRequest(ctx, resourceGroupName, serverName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// resetGtidCreateRequest creates the ResetGtid request. +func (client *ServersClient) resetGtidCreateRequest(ctx context.Context, resourceGroupName string, serverName string, parameters ServerGtidSetParameter, options *ServersClientBeginResetGtidOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/resetGtid" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serverName == "" { + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-09-30-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + // BeginRestart - Restarts a server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. // - serverName - The name of the server. // - parameters - The required parameters for restarting a server. @@ -441,7 +510,7 @@ func (client *ServersClient) BeginRestart(ctx context.Context, resourceGroupName // Restart - Restarts a server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview func (client *ServersClient) restart(ctx context.Context, resourceGroupName string, serverName string, parameters ServerRestartParameter, options *ServersClientBeginRestartOptions) (*http.Response, error) { req, err := client.restartCreateRequest(ctx, resourceGroupName, serverName, parameters, options) if err != nil { @@ -477,7 +546,7 @@ func (client *ServersClient) restartCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-09-30-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, parameters) @@ -486,7 +555,7 @@ func (client *ServersClient) restartCreateRequest(ctx context.Context, resourceG // BeginStart - Starts a server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview // - 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. @@ -505,7 +574,7 @@ func (client *ServersClient) BeginStart(ctx context.Context, resourceGroupName s // Start - Starts a server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview 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 { @@ -541,7 +610,7 @@ func (client *ServersClient) startCreateRequest(ctx context.Context, resourceGro return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-09-30-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -550,7 +619,7 @@ func (client *ServersClient) startCreateRequest(ctx context.Context, resourceGro // BeginStop - Stops a server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview // - 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. @@ -569,7 +638,7 @@ func (client *ServersClient) BeginStop(ctx context.Context, resourceGroupName st // Stop - Stops a server. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview 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 { @@ -605,7 +674,7 @@ func (client *ServersClient) stopCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-09-30-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -615,7 +684,7 @@ func (client *ServersClient) stopCreateRequest(ctx context.Context, resourceGrou // server definition. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview // - 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. @@ -636,7 +705,7 @@ func (client *ServersClient) BeginUpdate(ctx context.Context, resourceGroupName // definition. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-05-01 +// Generated from API version 2022-09-30-preview 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 { @@ -672,7 +741,7 @@ func (client *ServersClient) updateCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-05-01") + reqQP.Set("api-version", "2022-09-30-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, parameters) diff --git a/sdk/resourcemanager/mysql/armmysqlflexibleservers/servers_client_example_test.go b/sdk/resourcemanager/mysql/armmysqlflexibleservers/servers_client_example_test.go index 125077f87480..b70434c0d8e3 100644 --- a/sdk/resourcemanager/mysql/armmysqlflexibleservers/servers_client_example_test.go +++ b/sdk/resourcemanager/mysql/armmysqlflexibleservers/servers_client_example_test.go @@ -17,10 +17,10 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mysql/armmysqlflexibleservers/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerCreate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2022-09-30-preview/examples/ServerCreate.json func ExampleServersClient_BeginCreate_createANewServer() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -120,7 +120,7 @@ func ExampleServersClient_BeginCreate_createANewServer() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerCreateReplica.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2022-09-30-preview/examples/ServerCreateReplica.json func ExampleServersClient_BeginCreate_createAReplicaServer() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -197,7 +197,7 @@ func ExampleServersClient_BeginCreate_createAReplicaServer() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerCreateWithPointInTimeRestore.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2022-09-30-preview/examples/ServerCreateWithPointInTimeRestore.json func ExampleServersClient_BeginCreate_createAServerAsAPointInTimeRestore() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -281,7 +281,7 @@ func ExampleServersClient_BeginCreate_createAServerAsAPointInTimeRestore() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerCreateWithBYOK.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2022-09-30-preview/examples/ServerCreateWithBYOK.json func ExampleServersClient_BeginCreate_createAServerWithByok() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -298,7 +298,7 @@ func ExampleServersClient_BeginCreate_createAServerWithByok() { "num": to.Ptr("1"), }, Identity: &armmysqlflexibleservers.Identity{ - Type: to.Ptr("UserAssigned"), + Type: to.Ptr(armmysqlflexibleservers.ManagedServiceIdentityTypeUserAssigned), UserAssignedIdentities: map[string]any{ "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": map[string]any{}, }, @@ -394,7 +394,7 @@ func ExampleServersClient_BeginCreate_createAServerWithByok() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerUpdate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2022-09-30-preview/examples/ServerUpdate.json func ExampleServersClient_BeginUpdate_updateAServer() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -409,6 +409,7 @@ func ExampleServersClient_BeginUpdate_updateAServer() { Properties: &armmysqlflexibleservers.ServerPropertiesForUpdate{ Storage: &armmysqlflexibleservers.Storage{ AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + AutoIoScaling: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), Iops: to.Ptr[int32](200), StorageSizeGB: to.Ptr[int32](30), }, @@ -459,6 +460,7 @@ func ExampleServersClient_BeginUpdate_updateAServer() { // State: to.Ptr(armmysqlflexibleservers.ServerStateReady), // Storage: &armmysqlflexibleservers.Storage{ // AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), + // AutoIoScaling: to.Ptr(armmysqlflexibleservers.EnableStatusEnumDisabled), // Iops: to.Ptr[int32](200), // StorageSizeGB: to.Ptr[int32](30), // StorageSKU: to.Ptr("Premium_LRS"), @@ -472,7 +474,7 @@ func ExampleServersClient_BeginUpdate_updateAServer() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerUpdateWithCustomerMaintenanceWindow.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2022-09-30-preview/examples/ServerUpdateWithCustomerMaintenanceWindow.json func ExampleServersClient_BeginUpdate_updateServerCustomerMaintenanceWindow() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -551,7 +553,7 @@ func ExampleServersClient_BeginUpdate_updateServerCustomerMaintenanceWindow() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerUpdateWithBYOK.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2022-09-30-preview/examples/ServerUpdateWithBYOK.json func ExampleServersClient_BeginUpdate_updateServerWithByok() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -564,7 +566,7 @@ func ExampleServersClient_BeginUpdate_updateServerWithByok() { } poller, err := clientFactory.NewServersClient().BeginUpdate(ctx, "testrg", "mysqltestserver", armmysqlflexibleservers.ServerForUpdate{ Identity: &armmysqlflexibleservers.Identity{ - Type: to.Ptr("UserAssigned"), + Type: to.Ptr(armmysqlflexibleservers.ManagedServiceIdentityTypeUserAssigned), UserAssignedIdentities: map[string]any{ "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity": map[string]any{}, }, @@ -638,7 +640,7 @@ func ExampleServersClient_BeginUpdate_updateServerWithByok() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2022-09-30-preview/examples/ServerDelete.json func ExampleServersClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -659,7 +661,7 @@ func ExampleServersClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2022-09-30-preview/examples/ServerGet.json func ExampleServersClient_Get_getAServer() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -712,6 +714,7 @@ func ExampleServersClient_Get_getAServer() { // State: to.Ptr(armmysqlflexibleservers.ServerStateReady), // Storage: &armmysqlflexibleservers.Storage{ // AutoGrow: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), + // AutoIoScaling: to.Ptr(armmysqlflexibleservers.EnableStatusEnumEnabled), // Iops: to.Ptr[int32](600), // StorageSizeGB: to.Ptr[int32](100), // StorageSKU: to.Ptr("Premium_LRS"), @@ -725,7 +728,7 @@ func ExampleServersClient_Get_getAServer() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerGetWithVnet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2022-09-30-preview/examples/ServerGetWithVnet.json func ExampleServersClient_Get_getAServerWithVnet() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -792,7 +795,7 @@ func ExampleServersClient_Get_getAServerWithVnet() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServersListByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2022-09-30-preview/examples/ServersListByResourceGroup.json func ExampleServersClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -958,7 +961,7 @@ func ExampleServersClient_NewListByResourceGroupPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServersList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2022-09-30-preview/examples/ServersList.json func ExampleServersClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1124,7 +1127,7 @@ func ExampleServersClient_NewListPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerFailover.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2022-09-30-preview/examples/ServerFailover.json func ExampleServersClient_BeginFailover() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1145,7 +1148,7 @@ func ExampleServersClient_BeginFailover() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerRestart.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2022-09-30-preview/examples/ServerRestart.json func ExampleServersClient_BeginRestart() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1169,7 +1172,7 @@ func ExampleServersClient_BeginRestart() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerStart.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2022-09-30-preview/examples/ServerStart.json func ExampleServersClient_BeginStart() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1190,7 +1193,7 @@ func ExampleServersClient_BeginStart() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/mysql/resource-manager/Microsoft.DBforMySQL/stable/2021-05-01/examples/ServerStop.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2022-09-30-preview/examples/ServerStop.json func ExampleServersClient_BeginStop() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1210,3 +1213,26 @@ func ExampleServersClient_BeginStop() { log.Fatalf("failed to pull the result: %v", err) } } + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/preview/2022-09-30-preview/examples/ServerResetGtid.json +func ExampleServersClient_BeginResetGtid() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmysqlflexibleservers.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewServersClient().BeginResetGtid(ctx, "TestGroup", "testserver", armmysqlflexibleservers.ServerGtidSetParameter{ + GtidSet: to.Ptr("4aff5b51-97ba-11ed-a955-002248036acc:1-16"), + }, 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) + } +}