From 3d239dd8877acfb2da845eea066efadf53d2a9cb Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 26 Apr 2023 08:23:05 +0000 Subject: [PATCH] CodeGen from PR 23482 in Azure/azure-rest-api-specs Merge cd49c89edaf34831a46edecedd6e131cec3f7a1f into 38311a16b5bfcb756164c6c48a64b0bc90d01a54 --- .../resources/armsubscriptions/CHANGELOG.md | 25 ++ .../resources/armsubscriptions/autorest.md | 6 +- .../resources/armsubscriptions/client.go | 62 ++--- .../armsubscriptions/client_example_test.go | 240 ------------------ .../armsubscriptions/client_factory.go | 19 +- .../resources/armsubscriptions/constants.go | 35 ++- .../resources/armsubscriptions/go.mod | 4 +- .../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 | 43 ---- .../armsubscriptions/tenants_client.go | 4 +- .../tenants_client_example_test.go | 82 ------ 15 files changed, 462 insertions(+), 429 deletions(-) delete mode 100644 sdk/resourcemanager/resources/armsubscriptions/client_example_test.go create mode 100644 sdk/resourcemanager/resources/armsubscriptions/operations_client.go delete mode 100644 sdk/resourcemanager/resources/armsubscriptions/subscription_client_example_test.go delete mode 100644 sdk/resourcemanager/resources/armsubscriptions/tenants_client_example_test.go diff --git a/sdk/resourcemanager/resources/armsubscriptions/CHANGELOG.md b/sdk/resourcemanager/resources/armsubscriptions/CHANGELOG.md index 865d94fb3d99..c827703042c8 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-04-26) +### 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..aa7805a7bb50 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/autorest.md +++ b/sdk/resourcemanager/resources/armsubscriptions/autorest.md @@ -5,9 +5,9 @@ ``` 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 +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/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 ``` \ 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 deleted file mode 100644 index 091f0d85d3b7..000000000000 --- a/sdk/resourcemanager/resources/armsubscriptions/client_example_test.go +++ /dev/null @@ -1,240 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armsubscriptions_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/resources/armsubscriptions" -) - -// 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 -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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListLocationsPager("291bba3f-e0a5-47bc-a099-3bdcb2a50a05", &armsubscriptions.ClientListLocationsOptions{IncludeExtendedLocations: 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.LocationListResult = armsubscriptions.LocationListResult{ - // } - } -} - -// 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 -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) - 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)}) - 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.LocationListResult = armsubscriptions.LocationListResult{ - // } - } -} - -// 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 -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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().Get(ctx, "291bba3f-e0a5-47bc-a099-3bdcb2a50a05", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Subscription = armsubscriptions.Subscription{ - // AuthorizationSource: to.Ptr("Bypassed"), - // DisplayName: to.Ptr("Example Subscription"), - // ID: to.Ptr("/subscriptions/291bba3f-e0a5-47bc-a099-3bdcb2a50a05"), - // ManagedByTenants: []*armsubscriptions.ManagedByTenant{ - // { - // TenantID: to.Ptr("8f70baf1-1f6e-46a2-a1ff-238dac1ebfb7"), - // }}, - // State: to.Ptr(armsubscriptions.SubscriptionStateEnabled), - // SubscriptionID: to.Ptr("291bba3f-e0a5-47bc-a099-3bdcb2a50a05"), - // SubscriptionPolicies: &armsubscriptions.SubscriptionPolicies{ - // LocationPlacementID: to.Ptr("Internal_2014-09-01"), - // QuotaID: to.Ptr("Internal_2014-09-01"), - // SpendingLimit: to.Ptr(armsubscriptions.SpendingLimitOff), - // }, - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tagValue1"), - // "tagKey2": to.Ptr("tagValue2"), - // }, - // TenantID: to.Ptr("31c75423-32d6-4322-88b7-c478bdde4858"), - // } -} - -// 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 -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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.SubscriptionListResult = armsubscriptions.SubscriptionListResult{ - // Value: []*armsubscriptions.Subscription{ - // { - // AuthorizationSource: to.Ptr("RoleBased"), - // DisplayName: to.Ptr("Example Subscription"), - // ID: to.Ptr("/subscriptions/291bba3f-e0a5-47bc-a099-3bdcb2a50a05"), - // ManagedByTenants: []*armsubscriptions.ManagedByTenant{ - // { - // TenantID: to.Ptr("8f70baf1-1f6e-46a2-a1ff-238dac1ebfb7"), - // }}, - // State: to.Ptr(armsubscriptions.SubscriptionStateEnabled), - // SubscriptionID: to.Ptr("291bba3f-e0a5-47bc-a099-3bdcb2a50a05"), - // SubscriptionPolicies: &armsubscriptions.SubscriptionPolicies{ - // LocationPlacementID: to.Ptr("Internal_2014-09-01"), - // QuotaID: to.Ptr("Internal_2014-09-01"), - // SpendingLimit: to.Ptr(armsubscriptions.SpendingLimitOff), - // }, - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tagValue1"), - // "tagKey2": to.Ptr("tagValue2"), - // }, - // TenantID: to.Ptr("31c75423-32d6-4322-88b7-c478bdde4858"), - // }, - // { - // AuthorizationSource: to.Ptr("RoleBased"), - // DisplayName: to.Ptr("Example Subscription2"), - // ID: to.Ptr("/subscriptions/72ac930a-f34e-42d8-b06d-dc2a9e12ed71"), - // ManagedByTenants: []*armsubscriptions.ManagedByTenant{ - // { - // TenantID: to.Ptr("8f70baf1-1f6e-46a2-a1ff-238dac1ebfb7"), - // }, - // { - // TenantID: to.Ptr("f7fb6af2-321d-47c8-9c0f-b0239eaad39a"), - // }}, - // State: to.Ptr(armsubscriptions.SubscriptionStateEnabled), - // SubscriptionID: to.Ptr("72ac930a-f34e-42d8-b06d-dc2a9e12ed71"), - // SubscriptionPolicies: &armsubscriptions.SubscriptionPolicies{ - // LocationPlacementID: to.Ptr("Internal_2014-09-01"), - // QuotaID: to.Ptr("Internal_2014-09-01"), - // SpendingLimit: to.Ptr(armsubscriptions.SpendingLimitOff), - // }, - // Tags: map[string]*string{ - // "tagKey1": to.Ptr("tagValue1"), - // "tagKey2": to.Ptr("tagValue2"), - // }, - // TenantID: to.Ptr("2a0ff0de-96b2-4859-bb7c-a430d07a3e0c"), - // }}, - // } - } -} - -// 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 -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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().CheckZonePeers(ctx, "00000000-0000-0000-0000-00000000000000", armsubscriptions.CheckZonePeersRequest{ - Location: to.Ptr("eastus"), - SubscriptionIDs: []*string{ - to.Ptr("subscriptions/11111111-1111-1111-1111-111111111111")}, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CheckZonePeersResult = armsubscriptions.CheckZonePeersResult{ - // AvailabilityZonePeers: []*armsubscriptions.AvailabilityZonePeers{ - // { - // AvailabilityZone: to.Ptr("1"), - // Peers: []*armsubscriptions.Peers{ - // { - // AvailabilityZone: to.Ptr("3"), - // SubscriptionID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // }}, - // }, - // { - // AvailabilityZone: to.Ptr("2"), - // Peers: []*armsubscriptions.Peers{ - // { - // AvailabilityZone: to.Ptr("2"), - // SubscriptionID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // }}, - // }, - // { - // AvailabilityZone: to.Ptr("3"), - // Peers: []*armsubscriptions.Peers{ - // { - // AvailabilityZone: to.Ptr("1"), - // SubscriptionID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // }}, - // }}, - // Location: to.Ptr("eastus2"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-00000000000000"), - // } -} 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..f37ee5128a61 100644 --- a/sdk/resourcemanager/resources/armsubscriptions/go.mod +++ b/sdk/resourcemanager/resources/armsubscriptions/go.mod @@ -1,15 +1,15 @@ -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 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/stretchr/testify v1.7.0 ) require ( + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 // indirect 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 deleted file mode 100644 index e2804ee62102..000000000000 --- a/sdk/resourcemanager/resources/armsubscriptions/subscription_client_example_test.go +++ /dev/null @@ -1,43 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armsubscriptions_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions" -) - -// 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 -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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewSubscriptionClient().CheckResourceName(ctx, &armsubscriptions.SubscriptionClientCheckResourceNameOptions{ResourceNameDefinition: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CheckResourceNameResult = armsubscriptions.CheckResourceNameResult{ - // Name: to.Ptr("isxbox"), - // Type: to.Ptr("ResourceProviderTestHost/TestResourceType"), - // Status: to.Ptr(armsubscriptions.ResourceNameStatusAllowed), - // } -} 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 deleted file mode 100644 index 357079d943a7..000000000000 --- a/sdk/resourcemanager/resources/armsubscriptions/tenants_client_example_test.go +++ /dev/null @@ -1,82 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armsubscriptions_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions" -) - -// 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 -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) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewTenantsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.TenantListResult = armsubscriptions.TenantListResult{ - // Value: []*armsubscriptions.TenantIDDescription{ - // { - // CountryCode: to.Ptr("US"), - // DefaultDomain: to.Ptr("aad50.ccsctp.net"), - // DisplayName: to.Ptr("Test_Test_aad50"), - // Domains: []*string{ - // to.Ptr("aad50.ccsctp.net")}, - // ID: to.Ptr("/tenants/a70a1586-9c4a-4373-b907-1d310660dbd1"), - // TenantCategory: to.Ptr(armsubscriptions.TenantCategoryManagedBy), - // TenantID: to.Ptr("a70a1586-9c4a-4373-b907-1d310660dbd1"), - // TenantType: to.Ptr("AAD"), - // }, - // { - // CountryCode: to.Ptr("US"), - // DefaultDomain: to.Ptr("auxteststagemanual.ccsctp.net"), - // DisplayName: to.Ptr("Contoso Corp."), - // Domains: []*string{ - // to.Ptr("auxteststagemanual.ccsctp.net")}, - // ID: to.Ptr("/tenants/83abe5cd-bcc3-441a-bd86-e6a75360cecc"), - // TenantCategory: to.Ptr(armsubscriptions.TenantCategoryHome), - // TenantID: to.Ptr("83abe5cd-bcc3-441a-bd86-e6a75360cecc"), - // TenantType: to.Ptr("AAD"), - // }, - // { - // CountryCode: to.Ptr("US"), - // DefaultDomain: to.Ptr("rdvmohoro.ccsctp.net"), - // DisplayName: to.Ptr("TEST_TEST_RDV"), - // Domains: []*string{ - // to.Ptr("rdvmohoro.ccsctp.net"), - // to.Ptr("rdvmohoro.mail.ccsctp.net"), - // to.Ptr("rdvmohoro.com")}, - // ID: to.Ptr("/tenants/daea2e9b-847b-4c93-850d-2aa6f2d7af33"), - // TenantBrandingLogoURL: to.Ptr("logo1.logo.rdvmohoro.com"), - // TenantCategory: to.Ptr(armsubscriptions.TenantCategoryProjectedBy), - // TenantID: to.Ptr("daea2e9b-847b-4c93-850d-2aa6f2d7af33"), - // TenantType: to.Ptr("AAD"), - // }}, - // } - } -}