diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/CHANGELOG.md b/sdk/resourcemanager/managementgroups/armmanagementgroups/CHANGELOG.md index abe4dbea3bbd..e67eae152009 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/CHANGELOG.md +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/CHANGELOG.md @@ -1,5 +1,32 @@ # Release History +## 2.0.0 (2025-11-26) +### Breaking Changes + +- Type of `Operation.Display` has been changed from `*OperationDisplayProperties` to `*OperationDisplay` +- Operation `*HierarchySettingsClient.List` has supported pagination, use `*HierarchySettingsClient.NewListPager` instead. +- Struct `CreateManagementGroupChildInfo` has been removed +- Struct `EntityHierarchyItem` has been removed +- Struct `EntityHierarchyItemProperties` has been removed +- Struct `ErrorDetails` has been removed +- Struct `ErrorResponse` has been removed +- Struct `OperationDisplayProperties` has been removed +- Struct `OperationResults` has been removed +- Field `Count` of struct `EntityListResult` has been removed + +### Features Added + +- New enum type `ActionType` with values `ActionTypeInternal` +- New enum type `CreatedByType` with values `CreatedByTypeApplication`, `CreatedByTypeKey`, `CreatedByTypeManagedIdentity`, `CreatedByTypeUser` +- New enum type `Origin` with values `OriginSystem`, `OriginUser`, `OriginUserSystem` +- New struct `OperationDisplay` +- New struct `SystemData` +- New field `SystemData` in struct `HierarchySettings` +- New field `SystemData` in struct `ManagementGroup` +- New field `ActionType`, `IsDataAction`, `Origin` in struct `Operation` +- New field `SystemData` in struct `SubscriptionUnderManagementGroup` + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/README.md b/sdk/resourcemanager/managementgroups/armmanagementgroups/README.md index 3241945c728a..f73dd86e43c9 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/README.md +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/README.md @@ -18,7 +18,7 @@ This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for ve Install the Azure Management Groups module: ```sh -go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups/v2 ``` ## Authorization diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/api_client.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/api_client.go index 75ab1515a907..eec9c52c1c4a 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/api_client.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/api_client.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armmanagementgroups @@ -17,7 +13,7 @@ import ( "net/http" ) -// APIClient contains the methods for the ManagementGroupsAPI group. +// APIClient contains the methods for the API group. // Don't use this type directly, use NewAPIClient() instead. type APIClient struct { internal *arm.Client @@ -25,7 +21,7 @@ type APIClient struct { // NewAPIClient creates a new instance of APIClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewAPIClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*APIClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -40,8 +36,8 @@ func NewAPIClient(credential azcore.TokenCredential, options *arm.ClientOptions) // CheckNameAvailability - Checks if the specified management group name is valid and unique // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 -// - checkNameAvailabilityRequest - Management group name availability check parameters. +// Generated from API version 2023-04-01 +// - checkNameAvailabilityRequest - The request body // - options - APIClientCheckNameAvailabilityOptions contains the optional parameters for the APIClient.CheckNameAvailability // method. func (client *APIClient) CheckNameAvailability(ctx context.Context, checkNameAvailabilityRequest CheckNameAvailabilityRequest, options *APIClientCheckNameAvailabilityOptions) (APIClientCheckNameAvailabilityResponse, error) { @@ -67,16 +63,17 @@ func (client *APIClient) CheckNameAvailability(ctx context.Context, checkNameAva } // checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. -func (client *APIClient) checkNameAvailabilityCreateRequest(ctx context.Context, checkNameAvailabilityRequest CheckNameAvailabilityRequest, options *APIClientCheckNameAvailabilityOptions) (*policy.Request, error) { +func (client *APIClient) checkNameAvailabilityCreateRequest(ctx context.Context, checkNameAvailabilityRequest CheckNameAvailabilityRequest, _ *APIClientCheckNameAvailabilityOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/checkNameAvailability" 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-04-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, checkNameAvailabilityRequest); err != nil { return nil, err } @@ -95,7 +92,7 @@ func (client *APIClient) checkNameAvailabilityHandleResponse(resp *http.Response // StartTenantBackfill - Starts backfilling subscriptions for the Tenant. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2023-04-01 // - options - APIClientStartTenantBackfillOptions contains the optional parameters for the APIClient.StartTenantBackfill method. func (client *APIClient) StartTenantBackfill(ctx context.Context, options *APIClientStartTenantBackfillOptions) (APIClientStartTenantBackfillResponse, error) { var err error @@ -120,14 +117,14 @@ func (client *APIClient) StartTenantBackfill(ctx context.Context, options *APICl } // startTenantBackfillCreateRequest creates the StartTenantBackfill request. -func (client *APIClient) startTenantBackfillCreateRequest(ctx context.Context, options *APIClientStartTenantBackfillOptions) (*policy.Request, error) { +func (client *APIClient) startTenantBackfillCreateRequest(ctx context.Context, _ *APIClientStartTenantBackfillOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/startTenantBackfill" 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-04-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -145,7 +142,7 @@ func (client *APIClient) startTenantBackfillHandleResponse(resp *http.Response) // TenantBackfillStatus - Gets tenant backfill status // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2023-04-01 // - options - APIClientTenantBackfillStatusOptions contains the optional parameters for the APIClient.TenantBackfillStatus // method. func (client *APIClient) TenantBackfillStatus(ctx context.Context, options *APIClientTenantBackfillStatusOptions) (APIClientTenantBackfillStatusResponse, error) { @@ -171,14 +168,14 @@ func (client *APIClient) TenantBackfillStatus(ctx context.Context, options *APIC } // tenantBackfillStatusCreateRequest creates the TenantBackfillStatus request. -func (client *APIClient) tenantBackfillStatusCreateRequest(ctx context.Context, options *APIClientTenantBackfillStatusOptions) (*policy.Request, error) { +func (client *APIClient) tenantBackfillStatusCreateRequest(ctx context.Context, _ *APIClientTenantBackfillStatusOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/tenantBackfillStatus" 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-04-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/api_client_example_test.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/api_client_example_test.go index 937244b7d7c0..68c64a5d0821 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/api_client_example_test.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/api_client_example_test.go @@ -15,7 +15,7 @@ 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/managementgroups/armmanagementgroups" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups/v2" ) // Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/CheckManagementGroupNameAvailability.json @@ -30,8 +30,8 @@ func ExampleAPIClient_CheckNameAvailability() { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewAPIClient().CheckNameAvailability(ctx, armmanagementgroups.CheckNameAvailabilityRequest{ - Name: to.Ptr("nameTocheck"), - Type: to.Ptr("Microsoft.Management/managementGroups"), + Name: to.Ptr("nameTocheck"), + Type: to.Ptr("Microsoft.Management/managementGroups"), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/autorest.md b/sdk/resourcemanager/managementgroups/armmanagementgroups/autorest.md deleted file mode 100644 index d14441024ed5..000000000000 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/autorest.md +++ /dev/null @@ -1,12 +0,0 @@ -### AutoRest Configuration - -> see https://aka.ms/autorest - -``` yaml -azure-arm: true -require: -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/readme.go.md -license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.2.0 -``` \ No newline at end of file diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/build.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/build.go deleted file mode 100644 index 4712a15e55df..000000000000 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/build.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -// This file enables 'go generate' to regenerate this specific SDK -//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/managementgroups/armmanagementgroups - -package armmanagementgroups diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/client.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/client.go index f2a51c9101a7..0a1f98da8374 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/client.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/client.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armmanagementgroups @@ -21,7 +17,7 @@ import ( "strings" ) -// Client contains the methods for the ManagementGroups group. +// Client contains the methods for the service. // Don't use this type directly, use NewClient() instead. type Client struct { internal *arm.Client @@ -29,7 +25,7 @@ type Client struct { // NewClient creates a new instance of Client with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -41,11 +37,12 @@ func NewClient(credential azcore.TokenCredential, options *arm.ClientOptions) (* return client, nil } -// BeginCreateOrUpdate - Create or update a management group. If a management group is already created and a subsequent create -// request is issued with different properties, the management group properties will be updated. +// BeginCreateOrUpdate - Create or update a management group. +// If a management group is already created and a subsequent create request is issued with different properties, the management +// group properties will be updated. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2023-04-01 // - groupID - Management Group ID. // - createManagementGroupRequest - Management group creation parameters. // - options - ClientBeginCreateOrUpdateOptions contains the optional parameters for the Client.BeginCreateOrUpdate method. @@ -67,11 +64,12 @@ func (client *Client) BeginCreateOrUpdate(ctx context.Context, groupID string, c } } -// CreateOrUpdate - Create or update a management group. If a management group is already created and a subsequent create -// request is issued with different properties, the management group properties will be updated. +// CreateOrUpdate - Create or update a management group. +// If a management group is already created and a subsequent create request is issued with different properties, the management +// group properties will be updated. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2023-04-01 func (client *Client) createOrUpdate(ctx context.Context, groupID string, createManagementGroupRequest CreateManagementGroupRequest, options *ClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "Client.BeginCreateOrUpdate" @@ -105,22 +103,24 @@ func (client *Client) createOrUpdateCreateRequest(ctx context.Context, groupID s return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.CacheControl != nil { req.Raw().Header["Cache-Control"] = []string{*options.CacheControl} } - req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, createManagementGroupRequest); err != nil { return nil, err } return req, nil } -// BeginDelete - Delete management group. If a management group contains child resources, the request will fail. +// BeginDelete - Delete management group. +// If a management group contains child resources, the request will fail. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2023-04-01 // - groupID - Management Group ID. // - options - ClientBeginDeleteOptions contains the optional parameters for the Client.BeginDelete method. func (client *Client) BeginDelete(ctx context.Context, groupID string, options *ClientBeginDeleteOptions) (*runtime.Poller[ClientDeleteResponse], error) { @@ -141,10 +141,11 @@ func (client *Client) BeginDelete(ctx context.Context, groupID string, options * } } -// Delete - Delete management group. If a management group contains child resources, the request will fail. +// Delete - Delete management group. +// If a management group contains child resources, the request will fail. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2023-04-01 func (client *Client) deleteOperation(ctx context.Context, groupID string, options *ClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "Client.BeginDelete" @@ -178,19 +179,19 @@ func (client *Client) deleteCreateRequest(ctx context.Context, groupID string, o return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.CacheControl != nil { req.Raw().Header["Cache-Control"] = []string{*options.CacheControl} } - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // Get - Get the details of the management group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2023-04-01 // - groupID - Management Group ID. // - options - ClientGetOptions contains the optional parameters for the Client.Get method. func (client *Client) Get(ctx context.Context, groupID string, options *ClientGetOptions) (ClientGetResponse, error) { @@ -227,21 +228,21 @@ func (client *Client) getCreateRequest(ctx context.Context, groupID string, opti return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") if options != nil && options.Expand != nil { reqQP.Set("$expand", string(*options.Expand)) } - if options != nil && options.Recurse != nil { - reqQP.Set("$recurse", strconv.FormatBool(*options.Recurse)) - } if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } + if options != nil && options.Recurse != nil { + reqQP.Set("$recurse", strconv.FormatBool(*options.Recurse)) + } + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.CacheControl != nil { req.Raw().Header["Cache-Control"] = []string{*options.CacheControl} } - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -256,7 +257,7 @@ func (client *Client) getHandleResponse(resp *http.Response) (ClientGetResponse, // NewGetDescendantsPager - List all entities that descend from a management group. // -// Generated from API version 2021-04-01 +// Generated from API version 2023-04-01 // - groupID - Management Group ID. // - options - ClientGetDescendantsOptions contains the optional parameters for the Client.NewGetDescendantsPager method. func (client *Client) NewGetDescendantsPager(groupID string, options *ClientGetDescendantsOptions) *runtime.Pager[ClientGetDescendantsResponse] { @@ -294,13 +295,13 @@ func (client *Client) getDescendantsCreateRequest(ctx context.Context, groupID s return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") if options != nil && options.Skiptoken != nil { reqQP.Set("$skiptoken", *options.Skiptoken) } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -317,7 +318,7 @@ func (client *Client) getDescendantsHandleResponse(resp *http.Response) (ClientG // NewListPager - List management groups for the authenticated user. // -// Generated from API version 2021-04-01 +// Generated from API version 2023-04-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]{ @@ -350,15 +351,15 @@ func (client *Client) listCreateRequest(ctx context.Context, options *ClientList return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") if options != nil && options.Skiptoken != nil { reqQP.Set("$skiptoken", *options.Skiptoken) } + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.CacheControl != nil { req.Raw().Header["Cache-Control"] = []string{*options.CacheControl} } - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -374,7 +375,7 @@ func (client *Client) listHandleResponse(resp *http.Response) (ClientListRespons // Update - Update a management group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2023-04-01 // - groupID - Management Group ID. // - patchGroupRequest - Management group patch parameters. // - options - ClientUpdateOptions contains the optional parameters for the Client.Update method. @@ -412,12 +413,13 @@ func (client *Client) updateCreateRequest(ctx context.Context, groupID string, p return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.CacheControl != nil { req.Raw().Header["Cache-Control"] = []string{*options.CacheControl} } - req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, patchGroupRequest); err != nil { return nil, err } diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/client_example_test.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/client_example_test.go index 97226bbae034..0663c74fdc65 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/client_example_test.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/client_example_test.go @@ -1,25 +1,19 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armmanagementgroups_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/managementgroups/armmanagementgroups" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/ListManagementGroups.json -func ExampleClient_NewListPager() { +// Generated from example definition: 2023-04-01/PutManagementGroup.json +func ExampleClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -29,88 +23,52 @@ func ExampleClient_NewListPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewClient().NewListPager(&armmanagementgroups.ClientListOptions{CacheControl: to.Ptr("no-cache"), - Skiptoken: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ManagementGroupListResult = armmanagementgroups.ManagementGroupListResult{ - // Value: []*armmanagementgroups.ManagementGroupInfo{ - // { - // Name: to.Ptr("20000000-0001-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Management/managementGroups"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0001-0000-0000-000000000000"), - // Properties: &armmanagementgroups.ManagementGroupInfoProperties{ - // DisplayName: to.Ptr("Group 1 Tenant 2"), - // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), - // }, - // }, - // { - // Name: to.Ptr("20000000-0004-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Management/managementGroups"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0004-0000-0000-000000000000"), - // Properties: &armmanagementgroups.ManagementGroupInfoProperties{ - // DisplayName: to.Ptr("Group 4 Tenant 2"), - // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroup.json -func ExampleClient_Get_getManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmanagementgroups.NewClientFactory(cred, nil) + poller, err := clientFactory.NewClient().BeginCreateOrUpdate(ctx, "ChildGroup", armmanagementgroups.CreateManagementGroupRequest{ + Properties: &armmanagementgroups.CreateManagementGroupProperties{ + DisplayName: to.Ptr("ChildGroup"), + Details: &armmanagementgroups.CreateManagementGroupDetails{ + Parent: &armmanagementgroups.CreateParentGroupInfo{ + ID: to.Ptr("/providers/Microsoft.Management/managementGroups/RootGroup"), + }, + }, + }, + }, &armmanagementgroups.ClientBeginCreateOrUpdateOptions{ + CacheControl: to.Ptr("no-cache")}) if err != nil { - log.Fatalf("failed to create client: %v", err) + log.Fatalf("failed to finish the request: %v", err) } - res, err := clientFactory.NewClient().Get(ctx, "20000000-0001-0000-0000-000000000000", &armmanagementgroups.ClientGetOptions{Expand: nil, - Recurse: nil, - Filter: nil, - CacheControl: to.Ptr("no-cache"), - }) + res, err := poller.PollUntilDone(ctx, nil) if err != nil { - log.Fatalf("failed to finish the request: %v", err) + 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.ManagementGroup = armmanagementgroups.ManagementGroup{ - // Name: to.Ptr("20000000-0001-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Management/managementGroups"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0001-0000-0000-000000000000"), - // Properties: &armmanagementgroups.ManagementGroupProperties{ - // DisplayName: to.Ptr("Group 1 Tenant 2"), - // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), - // Details: &armmanagementgroups.ManagementGroupDetails{ - // Parent: &armmanagementgroups.ParentGroupInfo{ - // Name: to.Ptr("RootGroup"), - // DisplayName: to.Ptr("RootGroup"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/RootGroup"), + // res = armmanagementgroups.ClientCreateOrUpdateResponse{ + // ManagementGroup: &armmanagementgroups.ManagementGroup{ + // Name: to.Ptr("ChildGroup"), + // Type: to.Ptr("Microsoft.Management/managementGroups"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/ChildGroup"), + // Properties: &armmanagementgroups.ManagementGroupProperties{ + // DisplayName: to.Ptr("ChildGroup"), + // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), + // Details: &armmanagementgroups.ManagementGroupDetails{ + // Parent: &armmanagementgroups.ParentGroupInfo{ + // Name: to.Ptr("RootGroup"), + // DisplayName: to.Ptr("RootGroup"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/RootGroup"), + // }, + // UpdatedBy: to.Ptr("16b8ef21-5c9f-420c-bcc9-e4f8c9f30b4b"), + // UpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.00Z"); return t}()), + // Version: to.Ptr[int32](1), // }, - // UpdatedBy: to.Ptr("16b8ef21-5c9f-420c-bcc9-e4f8c9f30b4b"), - // UpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.000Z"); return t}()), - // Version: to.Ptr[int32](1), // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithAncestors.json -func ExampleClient_Get_getManagementGroupWithAncestors() { +// Generated from example definition: 2023-04-01/DeleteManagementGroup.json +func ExampleClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -120,49 +78,19 @@ func ExampleClient_Get_getManagementGroupWithAncestors() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewClient().Get(ctx, "20000000-0001-0000-0000-00000000000", &armmanagementgroups.ClientGetOptions{Expand: to.Ptr(armmanagementgroups.ManagementGroupExpandTypeAncestors), - Recurse: nil, - Filter: nil, - CacheControl: to.Ptr("no-cache"), - }) + poller, err := clientFactory.NewClient().BeginDelete(ctx, "GroupToDelete", &armmanagementgroups.ClientBeginDeleteOptions{ + CacheControl: to.Ptr("no-cache")}) 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.ManagementGroup = armmanagementgroups.ManagementGroup{ - // Name: to.Ptr("20000000-0001-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Management/managementGroups"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0001-0000-0000-000000000000"), - // Properties: &armmanagementgroups.ManagementGroupProperties{ - // DisplayName: to.Ptr("Group 1 Tenant 2"), - // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), - // Details: &armmanagementgroups.ManagementGroupDetails{ - // ManagementGroupAncestorsChain: []*armmanagementgroups.ManagementGroupPathElement{ - // { - // Name: to.Ptr("20000000-0000-0000-0000-000000000001"), - // DisplayName: to.Ptr("Parent display name"), - // }, - // { - // Name: to.Ptr("20000000-0000-0000-0000-000000000000"), - // DisplayName: to.Ptr("Grandparent display name"), - // }}, - // Parent: &armmanagementgroups.ParentGroupInfo{ - // Name: to.Ptr("20000000-0000-0000-0000-000000000001"), - // DisplayName: to.Ptr("Parent display name"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000001"), - // }, - // UpdatedBy: to.Ptr("Test"), - // UpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.000Z"); return t}()), - // Version: to.Ptr[int32](1), - // }, - // }, - // } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpand.json -func ExampleClient_Get_getManagementGroupWithExpand() { +// Generated from example definition: 2023-04-01/GetManagementGroup.json +func ExampleClient_Get_getManagementGroup() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -172,71 +100,39 @@ func ExampleClient_Get_getManagementGroupWithExpand() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewClient().Get(ctx, "20000000-0001-0000-0000-000000000000", &armmanagementgroups.ClientGetOptions{Expand: to.Ptr(armmanagementgroups.ManagementGroupExpandTypeChildren), - Recurse: nil, - Filter: nil, - CacheControl: to.Ptr("no-cache"), - }) + res, err := clientFactory.NewClient().Get(ctx, "20000000-0001-0000-0000-000000000000", &armmanagementgroups.ClientGetOptions{ + CacheControl: to.Ptr("no-cache")}) 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.ManagementGroup = armmanagementgroups.ManagementGroup{ - // Name: to.Ptr("20000000-0001-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Management/managementGroups"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0001-0000-0000-000000000000"), - // Properties: &armmanagementgroups.ManagementGroupProperties{ - // Children: []*armmanagementgroups.ManagementGroupChildInfo{ - // { - // Name: to.Ptr("20000000-0002-0000-0000-000000000000"), - // Type: to.Ptr(armmanagementgroups.ManagementGroupChildTypeMicrosoftManagementManagementGroups), - // DisplayName: to.Ptr("Group 2 Tenant 2"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0002-0000-0000-000000000000"), - // }, - // { - // Name: to.Ptr("20000000-0003-0000-0000-000000000000"), - // Type: to.Ptr(armmanagementgroups.ManagementGroupChildTypeMicrosoftManagementManagementGroups), - // DisplayName: to.Ptr("Group 3 Tenant 2"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0003-0000-0000-000000000000"), - // }, - // { - // Name: to.Ptr("10000000-F004-0000-0000-000000000000"), - // Type: to.Ptr(armmanagementgroups.ManagementGroupChildTypeSubscriptions), - // DisplayName: to.Ptr("Subscription 4 Tenant 1"), - // ID: to.Ptr("/subscriptions/10000000-F004-0000-0000-000000000000"), - // }, - // { - // Name: to.Ptr("20000000-F005-0000-0000-000000000000"), - // Type: to.Ptr(armmanagementgroups.ManagementGroupChildTypeSubscriptions), - // DisplayName: to.Ptr("Subscription 5 Tenant 2"), - // ID: to.Ptr("/subscriptions/20000000-F005-0000-0000-000000000000"), - // }, - // { - // Name: to.Ptr("30000000-F003-0000-0000-000000000000"), - // Type: to.Ptr(armmanagementgroups.ManagementGroupChildTypeSubscriptions), - // DisplayName: to.Ptr("Subscription 3 Tenant 3"), - // ID: to.Ptr("/subscriptions/30000000-F003-0000-0000-000000000000"), - // }}, - // DisplayName: to.Ptr("Group 1 Tenant 2"), - // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), - // Details: &armmanagementgroups.ManagementGroupDetails{ - // Parent: &armmanagementgroups.ParentGroupInfo{ - // Name: to.Ptr("20000000-0000-0000-0000-000000000000"), - // DisplayName: to.Ptr("20000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000000"), + // res = armmanagementgroups.ClientGetResponse{ + // ManagementGroup: &armmanagementgroups.ManagementGroup{ + // Name: to.Ptr("20000000-0001-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Management/managementGroups"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0001-0000-0000-000000000000"), + // Properties: &armmanagementgroups.ManagementGroupProperties{ + // DisplayName: to.Ptr("Group 1 Tenant 2"), + // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), + // Details: &armmanagementgroups.ManagementGroupDetails{ + // Parent: &armmanagementgroups.ParentGroupInfo{ + // Name: to.Ptr("RootGroup"), + // DisplayName: to.Ptr("RootGroup"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/RootGroup"), + // }, + // UpdatedBy: to.Ptr("16b8ef21-5c9f-420c-bcc9-e4f8c9f30b4b"), + // UpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.00Z"); return t}()), + // Version: to.Ptr[int32](1), // }, - // UpdatedBy: to.Ptr("Test"), - // UpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.000Z"); return t}()), - // Version: to.Ptr[int32](1), // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithPath.json -func ExampleClient_Get_getManagementGroupWithPath() { +// Generated from example definition: 2023-04-01/GetManagementGroupWithAncestors.json +func ExampleClient_Get_getManagementGroupWithAncestors() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -246,49 +142,50 @@ func ExampleClient_Get_getManagementGroupWithPath() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewClient().Get(ctx, "20000000-0001-0000-0000-000000000000", &armmanagementgroups.ClientGetOptions{Expand: to.Ptr(armmanagementgroups.ManagementGroupExpandTypePath), - Recurse: nil, - Filter: nil, - CacheControl: to.Ptr("no-cache"), - }) + res, err := clientFactory.NewClient().Get(ctx, "20000000-0001-0000-0000-00000000000", &armmanagementgroups.ClientGetOptions{ + Expand: to.Ptr(armmanagementgroups.ManagementGroupExpandTypeAncestors), + CacheControl: to.Ptr("no-cache")}) 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.ManagementGroup = armmanagementgroups.ManagementGroup{ - // Name: to.Ptr("20000000-0001-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Management/managementGroups"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0001-0000-0000-000000000000"), - // Properties: &armmanagementgroups.ManagementGroupProperties{ - // DisplayName: to.Ptr("Group 1 Tenant 2"), - // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), - // Details: &armmanagementgroups.ManagementGroupDetails{ - // Path: []*armmanagementgroups.ManagementGroupPathElement{ - // { - // Name: to.Ptr("20000000-0000-0000-0000-000000000000"), - // DisplayName: to.Ptr("Grandparent display name"), + // res = armmanagementgroups.ClientGetResponse{ + // ManagementGroup: &armmanagementgroups.ManagementGroup{ + // Name: to.Ptr("20000000-0001-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Management/managementGroups"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0001-0000-0000-000000000000"), + // Properties: &armmanagementgroups.ManagementGroupProperties{ + // DisplayName: to.Ptr("Group 1 Tenant 2"), + // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), + // Details: &armmanagementgroups.ManagementGroupDetails{ + // ManagementGroupAncestorsChain: []*armmanagementgroups.ManagementGroupPathElement{ + // { + // Name: to.Ptr("20000000-0000-0000-0000-000000000001"), + // DisplayName: to.Ptr("Parent display name"), + // }, + // { + // Name: to.Ptr("20000000-0000-0000-0000-000000000000"), + // DisplayName: to.Ptr("Grandparent display name"), + // }, // }, - // { + // Parent: &armmanagementgroups.ParentGroupInfo{ // Name: to.Ptr("20000000-0000-0000-0000-000000000001"), // DisplayName: to.Ptr("Parent display name"), - // }}, - // Parent: &armmanagementgroups.ParentGroupInfo{ - // Name: to.Ptr("20000000-0000-0000-0000-000000000001"), - // DisplayName: to.Ptr("Parent display name"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000001"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000001"), + // }, + // UpdatedBy: to.Ptr("Test"), + // UpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.00Z"); return t}()), + // Version: to.Ptr[int32](1), // }, - // UpdatedBy: to.Ptr("Test"), - // UpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.000Z"); return t}()), - // Version: to.Ptr[int32](1), // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpandAndRecurse.json -func ExampleClient_Get_getManagementGroupsWithExpandAndRecurse() { +// Generated from example definition: 2023-04-01/GetManagementGroupWithExpand.json +func ExampleClient_Get_getManagementGroupWithExpand() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -298,67 +195,72 @@ func ExampleClient_Get_getManagementGroupsWithExpandAndRecurse() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewClient().Get(ctx, "20000000-0001-0000-0000-000000000000", &armmanagementgroups.ClientGetOptions{Expand: to.Ptr(armmanagementgroups.ManagementGroupExpandTypeChildren), - Recurse: to.Ptr(true), - Filter: nil, - CacheControl: to.Ptr("no-cache"), - }) + res, err := clientFactory.NewClient().Get(ctx, "20000000-0001-0000-0000-000000000000", &armmanagementgroups.ClientGetOptions{ + Expand: to.Ptr(armmanagementgroups.ManagementGroupExpandTypeChildren), + CacheControl: to.Ptr("no-cache")}) 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.ManagementGroup = armmanagementgroups.ManagementGroup{ - // Name: to.Ptr("RootGroup"), - // Type: to.Ptr("Microsoft.Management/managementGroups"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/RootGroup"), - // Properties: &armmanagementgroups.ManagementGroupProperties{ - // Children: []*armmanagementgroups.ManagementGroupChildInfo{ - // { - // Name: to.Ptr("Child"), - // Type: to.Ptr(armmanagementgroups.ManagementGroupChildTypeMicrosoftManagementManagementGroups), - // Children: []*armmanagementgroups.ManagementGroupChildInfo{ - // { - // Name: to.Ptr("Leaf"), - // Type: to.Ptr(armmanagementgroups.ManagementGroupChildTypeMicrosoftManagementManagementGroups), - // Children: []*armmanagementgroups.ManagementGroupChildInfo{ - // { - // Name: to.Ptr("728bcbe4-8d56-4510-86c2-4921b8beefbc"), - // Type: to.Ptr(armmanagementgroups.ManagementGroupChildTypeSubscriptions), - // DisplayName: to.Ptr("Pay-As-You-Go"), - // ID: to.Ptr("/subscriptions/728bcbe4-8d56-4510-86c2-4921b8beefbc"), - // }}, - // DisplayName: to.Ptr("Leaf"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/Leaf"), - // }}, - // DisplayName: to.Ptr("Child"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/Child"), + // res = armmanagementgroups.ClientGetResponse{ + // ManagementGroup: &armmanagementgroups.ManagementGroup{ + // Name: to.Ptr("20000000-0001-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Management/managementGroups"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0001-0000-0000-000000000000"), + // Properties: &armmanagementgroups.ManagementGroupProperties{ + // Children: []*armmanagementgroups.ManagementGroupChildInfo{ + // { + // Name: to.Ptr("20000000-0002-0000-0000-000000000000"), + // Type: to.Ptr(armmanagementgroups.ManagementGroupChildTypeMicrosoftManagementManagementGroups), + // DisplayName: to.Ptr("Group 2 Tenant 2"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0002-0000-0000-000000000000"), + // }, + // { + // Name: to.Ptr("20000000-0003-0000-0000-000000000000"), + // Type: to.Ptr(armmanagementgroups.ManagementGroupChildTypeMicrosoftManagementManagementGroups), + // DisplayName: to.Ptr("Group 3 Tenant 2"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0003-0000-0000-000000000000"), + // }, + // { + // Name: to.Ptr("10000000-F004-0000-0000-000000000000"), + // Type: to.Ptr(armmanagementgroups.ManagementGroupChildTypeSubscriptions), + // DisplayName: to.Ptr("Subscription 4 Tenant 1"), + // ID: to.Ptr("/subscriptions/10000000-F004-0000-0000-000000000000"), + // }, + // { + // Name: to.Ptr("20000000-F005-0000-0000-000000000000"), + // Type: to.Ptr(armmanagementgroups.ManagementGroupChildTypeSubscriptions), + // DisplayName: to.Ptr("Subscription 5 Tenant 2"), + // ID: to.Ptr("/subscriptions/20000000-F005-0000-0000-000000000000"), + // }, + // { + // Name: to.Ptr("30000000-F003-0000-0000-000000000000"), + // Type: to.Ptr(armmanagementgroups.ManagementGroupChildTypeSubscriptions), + // DisplayName: to.Ptr("Subscription 3 Tenant 3"), + // ID: to.Ptr("/subscriptions/30000000-F003-0000-0000-000000000000"), + // }, // }, - // { - // Name: to.Ptr("AnotherChild"), - // Type: to.Ptr(armmanagementgroups.ManagementGroupChildTypeMicrosoftManagementManagementGroups), - // DisplayName: to.Ptr("Leaf"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/AnotherChild"), - // }}, - // DisplayName: to.Ptr("RootGroup"), - // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), - // Details: &armmanagementgroups.ManagementGroupDetails{ - // Parent: &armmanagementgroups.ParentGroupInfo{ - // Name: to.Ptr("20000000-0000-0000-0000-000000000000"), - // DisplayName: to.Ptr("20000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000000"), + // DisplayName: to.Ptr("Group 1 Tenant 2"), + // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), + // Details: &armmanagementgroups.ManagementGroupDetails{ + // Parent: &armmanagementgroups.ParentGroupInfo{ + // Name: to.Ptr("20000000-0000-0000-0000-000000000000"), + // DisplayName: to.Ptr("20000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000000"), + // }, + // UpdatedBy: to.Ptr("Test"), + // UpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.00Z"); return t}()), + // Version: to.Ptr[int32](1), // }, - // UpdatedBy: to.Ptr("bd490e30-04cb-433e-b8c8-6066959a8bab"), - // UpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T02:26:49.002Z"); return t}()), - // Version: to.Ptr[int32](2), // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/PutManagementGroup.json -func ExampleClient_BeginCreateOrUpdate() { +// Generated from example definition: 2023-04-01/GetManagementGroupWithExpandAndRecurse.json +func ExampleClient_Get_getManagementGroupsWithExpandAndRecurse() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -368,49 +270,71 @@ func ExampleClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := clientFactory.NewClient().BeginCreateOrUpdate(ctx, "ChildGroup", armmanagementgroups.CreateManagementGroupRequest{ - Properties: &armmanagementgroups.CreateManagementGroupProperties{ - DisplayName: to.Ptr("ChildGroup"), - Details: &armmanagementgroups.CreateManagementGroupDetails{ - Parent: &armmanagementgroups.CreateParentGroupInfo{ - ID: to.Ptr("/providers/Microsoft.Management/managementGroups/RootGroup"), - }, - }, - }, - }, &armmanagementgroups.ClientBeginCreateOrUpdateOptions{CacheControl: to.Ptr("no-cache")}) + res, err := clientFactory.NewClient().Get(ctx, "20000000-0001-0000-0000-000000000000", &armmanagementgroups.ClientGetOptions{ + Expand: to.Ptr(armmanagementgroups.ManagementGroupExpandTypeChildren), + Recurse: to.Ptr(true), + CacheControl: to.Ptr("no-cache")}) 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.ManagementGroup = armmanagementgroups.ManagementGroup{ - // Name: to.Ptr("ChildGroup"), - // Type: to.Ptr("Microsoft.Management/managementGroups"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/ChildGroup"), - // Properties: &armmanagementgroups.ManagementGroupProperties{ - // DisplayName: to.Ptr("ChildGroup"), - // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), - // Details: &armmanagementgroups.ManagementGroupDetails{ - // Parent: &armmanagementgroups.ParentGroupInfo{ - // Name: to.Ptr("RootGroup"), - // DisplayName: to.Ptr("RootGroup"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/RootGroup"), + // res = armmanagementgroups.ClientGetResponse{ + // ManagementGroup: &armmanagementgroups.ManagementGroup{ + // Name: to.Ptr("RootGroup"), + // Type: to.Ptr("Microsoft.Management/managementGroups"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/RootGroup"), + // Properties: &armmanagementgroups.ManagementGroupProperties{ + // Children: []*armmanagementgroups.ManagementGroupChildInfo{ + // { + // Name: to.Ptr("Child"), + // Type: to.Ptr(armmanagementgroups.ManagementGroupChildTypeMicrosoftManagementManagementGroups), + // Children: []*armmanagementgroups.ManagementGroupChildInfo{ + // { + // Name: to.Ptr("Leaf"), + // Type: to.Ptr(armmanagementgroups.ManagementGroupChildTypeMicrosoftManagementManagementGroups), + // Children: []*armmanagementgroups.ManagementGroupChildInfo{ + // { + // Name: to.Ptr("728bcbe4-8d56-4510-86c2-4921b8beefbc"), + // Type: to.Ptr(armmanagementgroups.ManagementGroupChildTypeSubscriptions), + // DisplayName: to.Ptr("Pay-As-You-Go"), + // ID: to.Ptr("/subscriptions/728bcbe4-8d56-4510-86c2-4921b8beefbc"), + // }, + // }, + // DisplayName: to.Ptr("Leaf"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/Leaf"), + // }, + // }, + // DisplayName: to.Ptr("Child"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/Child"), + // }, + // { + // Name: to.Ptr("AnotherChild"), + // Type: to.Ptr(armmanagementgroups.ManagementGroupChildTypeMicrosoftManagementManagementGroups), + // DisplayName: to.Ptr("Leaf"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/AnotherChild"), + // }, + // }, + // DisplayName: to.Ptr("RootGroup"), + // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), + // Details: &armmanagementgroups.ManagementGroupDetails{ + // Parent: &armmanagementgroups.ParentGroupInfo{ + // Name: to.Ptr("20000000-0000-0000-0000-000000000000"), + // DisplayName: to.Ptr("20000000-0000-0000-0000-000000000000"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000000"), + // }, + // UpdatedBy: to.Ptr("bd490e30-04cb-433e-b8c8-6066959a8bab"), + // UpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T02:26:49.0022093Z"); return t}()), + // Version: to.Ptr[int32](2), // }, - // UpdatedBy: to.Ptr("16b8ef21-5c9f-420c-bcc9-e4f8c9f30b4b"), - // UpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.000Z"); return t}()), - // Version: to.Ptr[int32](1), // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/PatchManagementGroup.json -func ExampleClient_Update() { +// Generated from example definition: 2023-04-01/GetManagementGroupWithPath.json +func ExampleClient_Get_getManagementGroupWithPath() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -420,39 +344,50 @@ func ExampleClient_Update() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewClient().Update(ctx, "ChildGroup", armmanagementgroups.PatchManagementGroupRequest{ - DisplayName: to.Ptr("AlternateDisplayName"), - ParentGroupID: to.Ptr("/providers/Microsoft.Management/managementGroups/AlternateRootGroup"), - }, &armmanagementgroups.ClientUpdateOptions{CacheControl: to.Ptr("no-cache")}) + res, err := clientFactory.NewClient().Get(ctx, "20000000-0001-0000-0000-000000000000", &armmanagementgroups.ClientGetOptions{ + Expand: to.Ptr(armmanagementgroups.ManagementGroupExpandTypePath), + CacheControl: to.Ptr("no-cache")}) 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.ManagementGroup = armmanagementgroups.ManagementGroup{ - // Name: to.Ptr("ChildGroup"), - // Type: to.Ptr("Microsoft.Management/managementGroups"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/ChildGroup"), - // Properties: &armmanagementgroups.ManagementGroupProperties{ - // DisplayName: to.Ptr("AlternateDisplayName"), - // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), - // Details: &armmanagementgroups.ManagementGroupDetails{ - // Parent: &armmanagementgroups.ParentGroupInfo{ - // Name: to.Ptr("AlternateRootGroup"), - // DisplayName: to.Ptr("AlternateRootGroup"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/AlternateRootGroup"), + // res = armmanagementgroups.ClientGetResponse{ + // ManagementGroup: &armmanagementgroups.ManagementGroup{ + // Name: to.Ptr("20000000-0001-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Management/managementGroups"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0001-0000-0000-000000000000"), + // Properties: &armmanagementgroups.ManagementGroupProperties{ + // DisplayName: to.Ptr("Group 1 Tenant 2"), + // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), + // Details: &armmanagementgroups.ManagementGroupDetails{ + // Path: []*armmanagementgroups.ManagementGroupPathElement{ + // { + // Name: to.Ptr("20000000-0000-0000-0000-000000000000"), + // DisplayName: to.Ptr("Grandparent display name"), + // }, + // { + // Name: to.Ptr("20000000-0000-0000-0000-000000000001"), + // DisplayName: to.Ptr("Parent display name"), + // }, + // }, + // Parent: &armmanagementgroups.ParentGroupInfo{ + // Name: to.Ptr("20000000-0000-0000-0000-000000000001"), + // DisplayName: to.Ptr("Parent display name"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000001"), + // }, + // UpdatedBy: to.Ptr("Test"), + // UpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-01T00:00:00.00Z"); return t}()), + // Version: to.Ptr[int32](1), // }, - // UpdatedBy: to.Ptr("bd490e30-04cb-433e-b8c8-6066959a8bab"), - // UpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T02:46:59.054Z"); return t}()), - // Version: to.Ptr[int32](2), // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/DeleteManagementGroup.json -func ExampleClient_BeginDelete() { +// Generated from example definition: 2023-04-01/GetDescendants.json +func ExampleClient_NewGetDescendantsPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -462,18 +397,50 @@ func ExampleClient_BeginDelete() { if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := clientFactory.NewClient().BeginDelete(ctx, "GroupToDelete", &armmanagementgroups.ClientBeginDeleteOptions{CacheControl: to.Ptr("no-cache")}) - 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) + pager := clientFactory.NewClient().NewGetDescendantsPager("20000000-0000-0000-0000-000000000000", 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 = armmanagementgroups.ClientGetDescendantsResponse{ + // DescendantListResult: armmanagementgroups.DescendantListResult{ + // Value: []*armmanagementgroups.DescendantInfo{ + // { + // Name: to.Ptr("20000000-0001-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Management/managementGroups"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0001-0000-0000-000000000000"), + // Properties: &armmanagementgroups.DescendantInfoProperties{ + // DisplayName: to.Ptr("Group 1"), + // Parent: &armmanagementgroups.DescendantParentGroupInfo{ + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // { + // Name: to.Ptr("20000000-0004-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Management/managementGroups/subscriptions"), + // ID: to.Ptr("/subscriptions/20000000-0004-0000-0000-000000000000"), + // Properties: &armmanagementgroups.DescendantInfoProperties{ + // DisplayName: to.Ptr("Subscription 4"), + // Parent: &armmanagementgroups.DescendantParentGroupInfo{ + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // }, + // }, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetDescendants.json -func ExampleClient_NewGetDescendantsPager() { +// Generated from example definition: 2023-04-01/ListManagementGroups.json +func ExampleClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -483,9 +450,8 @@ func ExampleClient_NewGetDescendantsPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewClient().NewGetDescendantsPager("20000000-0000-0000-0000-000000000000", &armmanagementgroups.ClientGetDescendantsOptions{Skiptoken: nil, - Top: nil, - }) + pager := clientFactory.NewClient().NewListPager(&armmanagementgroups.ClientListOptions{ + CacheControl: to.Ptr("no-cache")}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -496,30 +462,74 @@ func ExampleClient_NewGetDescendantsPager() { _ = 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.DescendantListResult = armmanagementgroups.DescendantListResult{ - // Value: []*armmanagementgroups.DescendantInfo{ - // { - // Name: to.Ptr("20000000-0001-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Management/managementGroups"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0001-0000-0000-000000000000"), - // Properties: &armmanagementgroups.DescendantInfoProperties{ - // DisplayName: to.Ptr("Group 1"), - // Parent: &armmanagementgroups.DescendantParentGroupInfo{ - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000000"), + // page = armmanagementgroups.ClientListResponse{ + // ManagementGroupListResult: armmanagementgroups.ManagementGroupListResult{ + // Value: []*armmanagementgroups.ManagementGroupInfo{ + // { + // Name: to.Ptr("20000000-0001-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Management/managementGroups"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0001-0000-0000-000000000000"), + // Properties: &armmanagementgroups.ManagementGroupInfoProperties{ + // DisplayName: to.Ptr("Group 1 Tenant 2"), + // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), // }, // }, - // }, - // { - // Name: to.Ptr("20000000-0004-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Management/managementGroups/subscriptions"), - // ID: to.Ptr("/subscriptions/20000000-0004-0000-0000-000000000000"), - // Properties: &armmanagementgroups.DescendantInfoProperties{ - // DisplayName: to.Ptr("Subscription 4"), - // Parent: &armmanagementgroups.DescendantParentGroupInfo{ - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000000"), + // { + // Name: to.Ptr("20000000-0004-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Management/managementGroups"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0004-0000-0000-000000000000"), + // Properties: &armmanagementgroups.ManagementGroupInfoProperties{ + // DisplayName: to.Ptr("Group 4 Tenant 2"), + // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), // }, // }, - // }}, + // }, + // }, // } } } + +// Generated from example definition: 2023-04-01/PatchManagementGroup.json +func ExampleClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armmanagementgroups.NewClientFactory(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewClient().Update(ctx, "ChildGroup", armmanagementgroups.PatchManagementGroupRequest{ + DisplayName: to.Ptr("AlternateDisplayName"), + ParentGroupID: to.Ptr("/providers/Microsoft.Management/managementGroups/AlternateRootGroup"), + }, &armmanagementgroups.ClientUpdateOptions{ + CacheControl: to.Ptr("no-cache")}) + 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 = armmanagementgroups.ClientUpdateResponse{ + // ManagementGroup: &armmanagementgroups.ManagementGroup{ + // Name: to.Ptr("ChildGroup"), + // Type: to.Ptr("Microsoft.Management/managementGroups"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/ChildGroup"), + // Properties: &armmanagementgroups.ManagementGroupProperties{ + // DisplayName: to.Ptr("AlternateDisplayName"), + // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), + // Details: &armmanagementgroups.ManagementGroupDetails{ + // Parent: &armmanagementgroups.ParentGroupInfo{ + // Name: to.Ptr("AlternateRootGroup"), + // DisplayName: to.Ptr("AlternateRootGroup"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/AlternateRootGroup"), + // }, + // UpdatedBy: to.Ptr("bd490e30-04cb-433e-b8c8-6066959a8bab"), + // UpdatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-01-25T02:46:59.0545645Z"); return t}()), + // Version: to.Ptr[int32](2), + // }, + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/client_factory.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/client_factory.go index d2336e0b009b..9cf8399639dd 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/client_factory.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/client_factory.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armmanagementgroups @@ -16,8 +12,7 @@ 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 + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. @@ -25,48 +20,53 @@ type ClientFactory struct { // - 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) { - _, err := arm.NewClient(moduleName, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - credential: credential, - options: options.Clone(), + internal: internal, }, nil } // NewAPIClient creates a new instance of APIClient. func (c *ClientFactory) NewAPIClient() *APIClient { - subClient, _ := NewAPIClient(c.credential, c.options) - return subClient + return &APIClient{ + internal: c.internal, + } } // NewClient creates a new instance of Client. func (c *ClientFactory) NewClient() *Client { - subClient, _ := NewClient(c.credential, c.options) - return subClient + return &Client{ + internal: c.internal, + } } // NewEntitiesClient creates a new instance of EntitiesClient. func (c *ClientFactory) NewEntitiesClient() *EntitiesClient { - subClient, _ := NewEntitiesClient(c.credential, c.options) - return subClient + return &EntitiesClient{ + internal: c.internal, + } } // NewHierarchySettingsClient creates a new instance of HierarchySettingsClient. func (c *ClientFactory) NewHierarchySettingsClient() *HierarchySettingsClient { - subClient, _ := NewHierarchySettingsClient(c.credential, c.options) - return subClient + return &HierarchySettingsClient{ + internal: c.internal, + } } // NewManagementGroupSubscriptionsClient creates a new instance of ManagementGroupSubscriptionsClient. func (c *ClientFactory) NewManagementGroupSubscriptionsClient() *ManagementGroupSubscriptionsClient { - subClient, _ := NewManagementGroupSubscriptionsClient(c.credential, c.options) - return subClient + return &ManagementGroupSubscriptionsClient{ + internal: c.internal, + } } // NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient + return &OperationsClient{ + internal: c.internal, + } } diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/constants.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/constants.go index 2411cfb7f6f1..a018d49d0bc3 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/constants.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/constants.go @@ -1,26 +1,61 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armmanagementgroups +// ActionType - Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + // ActionTypeInternal - Actions are for internal-only APIs. + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// CreatedByType - The kind of entity that created the resource. +type CreatedByType string + const ( - moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups" - moduleVersion = "v1.2.0" + // CreatedByTypeApplication - The entity was created by an application. + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey - The entity was created by a key. + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity - The entity was created by a managed identity. + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + // CreatedByTypeUser - The entity was created by a user. + CreatedByTypeUser CreatedByType = "User" ) +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + type EntitySearchType string const ( - EntitySearchTypeAllowedChildren EntitySearchType = "AllowedChildren" - EntitySearchTypeAllowedParents EntitySearchType = "AllowedParents" - EntitySearchTypeChildrenOnly EntitySearchType = "ChildrenOnly" + // EntitySearchTypeAllowedChildren - AllowedChildren + EntitySearchTypeAllowedChildren EntitySearchType = "AllowedChildren" + // EntitySearchTypeAllowedParents - AllowedParents + EntitySearchTypeAllowedParents EntitySearchType = "AllowedParents" + // EntitySearchTypeChildrenOnly - ChildrenOnly + EntitySearchTypeChildrenOnly EntitySearchType = "ChildrenOnly" + // EntitySearchTypeParentAndFirstLevelChildren - ParentAndFirstLevelChildren EntitySearchTypeParentAndFirstLevelChildren EntitySearchType = "ParentAndFirstLevelChildren" - EntitySearchTypeParentOnly EntitySearchType = "ParentOnly" + // EntitySearchTypeParentOnly - ParentOnly + EntitySearchTypeParentOnly EntitySearchType = "ParentOnly" ) // PossibleEntitySearchTypeValues returns the possible values for the EntitySearchType const type. @@ -37,9 +72,13 @@ func PossibleEntitySearchTypeValues() []EntitySearchType { type EntityViewParameterType string const ( - EntityViewParameterTypeAudit EntityViewParameterType = "Audit" - EntityViewParameterTypeFullHierarchy EntityViewParameterType = "FullHierarchy" - EntityViewParameterTypeGroupsOnly EntityViewParameterType = "GroupsOnly" + // EntityViewParameterTypeAudit - Audit + EntityViewParameterTypeAudit EntityViewParameterType = "Audit" + // EntityViewParameterTypeFullHierarchy - FullHierarchy + EntityViewParameterTypeFullHierarchy EntityViewParameterType = "FullHierarchy" + // EntityViewParameterTypeGroupsOnly - GroupsOnly + EntityViewParameterTypeGroupsOnly EntityViewParameterType = "GroupsOnly" + // EntityViewParameterTypeSubscriptionsOnly - SubscriptionsOnly EntityViewParameterTypeSubscriptionsOnly EntityViewParameterType = "SubscriptionsOnly" ) @@ -57,8 +96,10 @@ func PossibleEntityViewParameterTypeValues() []EntityViewParameterType { type ManagementGroupChildType string const ( + // ManagementGroupChildTypeMicrosoftManagementManagementGroups - Microsoft.Management/managementGroups ManagementGroupChildTypeMicrosoftManagementManagementGroups ManagementGroupChildType = "Microsoft.Management/managementGroups" - ManagementGroupChildTypeSubscriptions ManagementGroupChildType = "/subscriptions" + // ManagementGroupChildTypeSubscriptions - /subscriptions + ManagementGroupChildTypeSubscriptions ManagementGroupChildType = "/subscriptions" ) // PossibleManagementGroupChildTypeValues returns the possible values for the ManagementGroupChildType const type. @@ -72,9 +113,12 @@ func PossibleManagementGroupChildTypeValues() []ManagementGroupChildType { type ManagementGroupExpandType string const ( + // ManagementGroupExpandTypeAncestors - ancestors ManagementGroupExpandTypeAncestors ManagementGroupExpandType = "ancestors" - ManagementGroupExpandTypeChildren ManagementGroupExpandType = "children" - ManagementGroupExpandTypePath ManagementGroupExpandType = "path" + // ManagementGroupExpandTypeChildren - children + ManagementGroupExpandTypeChildren ManagementGroupExpandType = "children" + // ManagementGroupExpandTypePath - path + ManagementGroupExpandTypePath ManagementGroupExpandType = "path" ) // PossibleManagementGroupExpandTypeValues returns the possible values for the ManagementGroupExpandType const type. @@ -86,14 +130,40 @@ func PossibleManagementGroupExpandTypeValues() []ManagementGroupExpandType { } } +// 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 - Indicates the operation is initiated by a system. + OriginSystem Origin = "system" + // OriginUser - Indicates the operation is initiated by a user. + OriginUser Origin = "user" + // OriginUserSystem - Indicates the operation is initiated by a user or system. + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + // Permissions - The users specific permissions to this item. type Permissions string const ( - PermissionsDelete Permissions = "delete" - PermissionsEdit Permissions = "edit" + // PermissionsDelete - delete + PermissionsDelete Permissions = "delete" + // PermissionsEdit - edit + PermissionsEdit Permissions = "edit" + // PermissionsNoaccess - noaccess PermissionsNoaccess Permissions = "noaccess" - PermissionsView Permissions = "view" + // PermissionsView - view + PermissionsView Permissions = "view" ) // PossiblePermissionsValues returns the possible values for the Permissions const type. @@ -107,13 +177,15 @@ func PossiblePermissionsValues() []Permissions { } // Reason - Required if nameAvailable == false. Invalid indicates the name provided does not match the resource provider's -// naming requirements (incorrect length, unsupported characters, etc.) AlreadyExists -// indicates that the name is already in use and is therefore unavailable. +// naming requirements (incorrect length, unsupported characters, etc.) AlreadyExists indicates that the name is already in +// use and is therefore unavailable. type Reason string const ( + // ReasonAlreadyExists - AlreadyExists ReasonAlreadyExists Reason = "AlreadyExists" - ReasonInvalid Reason = "Invalid" + // ReasonInvalid - Invalid + ReasonInvalid Reason = "Invalid" ) // PossibleReasonValues returns the possible values for the Reason const type. @@ -128,12 +200,18 @@ func PossibleReasonValues() []Reason { type Status string const ( - StatusCancelled Status = "Cancelled" - StatusCompleted Status = "Completed" - StatusFailed Status = "Failed" - StatusNotStarted Status = "NotStarted" + // StatusCancelled - Cancelled + StatusCancelled Status = "Cancelled" + // StatusCompleted - Completed + StatusCompleted Status = "Completed" + // StatusFailed - Failed + StatusFailed Status = "Failed" + // StatusNotStarted - NotStarted + StatusNotStarted Status = "NotStarted" + // StatusNotStartedButGroupsExist - NotStartedButGroupsExist StatusNotStartedButGroupsExist Status = "NotStartedButGroupsExist" - StatusStarted Status = "Started" + // StatusStarted - Started + StatusStarted Status = "Started" ) // PossibleStatusValues returns the possible values for the Status const type. diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/entities_client.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/entities_client.go index 235b1b464d6e..dc38c7b4de0f 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/entities_client.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/entities_client.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armmanagementgroups @@ -26,7 +22,7 @@ type EntitiesClient struct { // NewEntitiesClient creates a new instance of EntitiesClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewEntitiesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*EntitiesClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -40,7 +36,7 @@ func NewEntitiesClient(credential azcore.TokenCredential, options *arm.ClientOpt // NewListPager - List all entities (Management Groups, Subscriptions, etc.) for the authenticated user. // -// Generated from API version 2021-04-01 +// Generated from API version 2023-04-01 // - options - EntitiesClientListOptions contains the optional parameters for the EntitiesClient.NewListPager method. func (client *EntitiesClient) NewListPager(options *EntitiesClientListOptions) *runtime.Pager[EntitiesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[EntitiesClientListResponse]{ @@ -73,36 +69,36 @@ func (client *EntitiesClient) listCreateRequest(ctx context.Context, options *En return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") - if options != nil && options.Skiptoken != nil { - reqQP.Set("$skiptoken", *options.Skiptoken) - } - if options != nil && options.Skip != nil { - reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + if options != nil && options.Search != nil { + reqQP.Set("$search", string(*options.Search)) } if options != nil && options.Select != nil { reqQP.Set("$select", *options.Select) } - if options != nil && options.Search != nil { - reqQP.Set("$search", string(*options.Search)) + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatInt(int64(*options.Skip), 10)) } - if options != nil && options.Filter != nil { - reqQP.Set("$filter", *options.Filter) + if options != nil && options.Skiptoken != nil { + reqQP.Set("$skiptoken", *options.Skiptoken) + } + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } if options != nil && options.View != nil { reqQP.Set("$view", string(*options.View)) } + reqQP.Set("api-version", "2023-04-01") if options != nil && options.GroupName != nil { reqQP.Set("groupName", *options.GroupName) } req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.CacheControl != nil { req.Raw().Header["Cache-Control"] = []string{*options.CacheControl} } - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/entities_client_example_test.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/entities_client_example_test.go index 3b385f31004e..f3acb8150b65 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/entities_client_example_test.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/entities_client_example_test.go @@ -1,23 +1,17 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armmanagementgroups_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetEntities.json +// Generated from example definition: 2023-04-01/GetEntities.json func ExampleEntitiesClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -28,16 +22,7 @@ func ExampleEntitiesClient_NewListPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewEntitiesClient().NewListPager(&armmanagementgroups.EntitiesClientListOptions{Skiptoken: nil, - Skip: nil, - Top: nil, - Select: nil, - Search: nil, - Filter: nil, - View: nil, - GroupName: nil, - CacheControl: nil, - }) + pager := clientFactory.NewEntitiesClient().NewListPager(nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -48,54 +33,61 @@ func ExampleEntitiesClient_NewListPager() { _ = 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.EntityListResult = armmanagementgroups.EntityListResult{ - // Value: []*armmanagementgroups.EntityInfo{ - // { - // Name: to.Ptr("20000000-0001-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Management/managementGroups"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0001-0000-0000-000000000000"), - // Properties: &armmanagementgroups.EntityInfoProperties{ - // DisplayName: to.Ptr("Group 1 Tenant 2"), - // InheritedPermissions: to.Ptr(armmanagementgroups.PermissionsView), - // NumberOfChildGroups: to.Ptr[int32](1), - // NumberOfChildren: to.Ptr[int32](2), - // NumberOfDescendants: to.Ptr[int32](3), - // Parent: &armmanagementgroups.EntityParentGroupInfo{ - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000000"), + // page = armmanagementgroups.EntitiesClientListResponse{ + // EntityListResult: armmanagementgroups.EntityListResult{ + // Value: []*armmanagementgroups.EntityInfo{ + // { + // Name: to.Ptr("20000000-0001-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Management/managementGroups"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0001-0000-0000-000000000000"), + // Properties: &armmanagementgroups.EntityInfoProperties{ + // DisplayName: to.Ptr("Group 1 Tenant 2"), + // InheritedPermissions: to.Ptr(armmanagementgroups.PermissionsView), + // NumberOfChildGroups: to.Ptr[int32](1), + // NumberOfChildren: to.Ptr[int32](2), + // NumberOfDescendants: to.Ptr[int32](3), + // Parent: &armmanagementgroups.EntityParentGroupInfo{ + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000000"), + // }, + // ParentDisplayNameChain: []*string{ + // to.Ptr("Tenant Root Group"), + // to.Ptr("Group 1 Tenant 2 Parent"), + // }, + // ParentNameChain: []*string{ + // to.Ptr("TenantRootGroup"), + // to.Ptr("Group1Tenant2Parent"), + // }, + // Permissions: to.Ptr(armmanagementgroups.PermissionsView), + // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), // }, - // ParentDisplayNameChain: []*string{ - // to.Ptr("Tenant Root Group"), - // to.Ptr("Group 1 Tenant 2 Parent")}, + // }, + // { + // Name: to.Ptr("20000000-0004-0000-0000-000000000000"), + // Type: to.Ptr("Microsoft.Management/managementGroups"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0004-0000-0000-000000000000"), + // Properties: &armmanagementgroups.EntityInfoProperties{ + // DisplayName: to.Ptr("Group 4 Tenant 2"), + // InheritedPermissions: to.Ptr(armmanagementgroups.PermissionsDelete), + // NumberOfChildGroups: to.Ptr[int32](0), + // NumberOfChildren: to.Ptr[int32](0), + // NumberOfDescendants: to.Ptr[int32](0), + // Parent: &armmanagementgroups.EntityParentGroupInfo{ + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000000"), + // }, + // ParentDisplayNameChain: []*string{ + // to.Ptr("Tenant Root Group"), + // to.Ptr("Group 4 Tenant 2 Parent"), + // }, // ParentNameChain: []*string{ // to.Ptr("TenantRootGroup"), - // to.Ptr("Group1Tenant2Parent")}, - // Permissions: to.Ptr(armmanagementgroups.PermissionsView), - // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), + // to.Ptr("Group4 Tenant2Parent"), // }, + // Permissions: to.Ptr(armmanagementgroups.PermissionsDelete), + // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), // }, - // { - // Name: to.Ptr("20000000-0004-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Management/managementGroups"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0004-0000-0000-000000000000"), - // Properties: &armmanagementgroups.EntityInfoProperties{ - // DisplayName: to.Ptr("Group 4 Tenant 2"), - // InheritedPermissions: to.Ptr(armmanagementgroups.PermissionsDelete), - // NumberOfChildGroups: to.Ptr[int32](0), - // NumberOfChildren: to.Ptr[int32](0), - // NumberOfDescendants: to.Ptr[int32](0), - // Parent: &armmanagementgroups.EntityParentGroupInfo{ - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/20000000-0000-0000-0000-000000000000"), - // }, - // ParentDisplayNameChain: []*string{ - // to.Ptr("Tenant Root Group"), - // to.Ptr("Group 4 Tenant 2 Parent")}, - // ParentNameChain: []*string{ - // to.Ptr("TenantRootGroup"), - // to.Ptr("Group4 Tenant2Parent")}, - // Permissions: to.Ptr(armmanagementgroups.PermissionsDelete), - // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), - // }, - // }}, - // } + // }, + // }, + // }, + // } } } diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/api_server.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/api_server.go index 7ac20ef0ee26..76772fb891ef 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/api_server.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/api_server.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -15,7 +11,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups/v2" "net/http" ) @@ -23,15 +19,15 @@ import ( type APIServer struct { // CheckNameAvailability is the fake for method APIClient.CheckNameAvailability // HTTP status codes to indicate success: http.StatusOK - CheckNameAvailability func(ctx context.Context, checkNameAvailabilityRequest armmanagementgroups.CheckNameAvailabilityRequest, options *armmanagementgroups.APIClientCheckNameAvailabilityOptions) (resp azfake.Responder[armmanagementgroups.APIClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + CheckNameAvailability func(ctx context.Context, checkNameAvailabilityRequest armmanagementgroups.CheckNameAvailabilityRequest, options *armmanagementgroups.APIClientCheckNameAvailabilityOptions) (resp azfake.Responder[armmanagementgroups.APIClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) // StartTenantBackfill is the fake for method APIClient.StartTenantBackfill // HTTP status codes to indicate success: http.StatusOK - StartTenantBackfill func(ctx context.Context, options *armmanagementgroups.APIClientStartTenantBackfillOptions) (resp azfake.Responder[armmanagementgroups.APIClientStartTenantBackfillResponse], errResp azfake.ErrorResponder) + StartTenantBackfill func(ctx context.Context, options *armmanagementgroups.APIClientStartTenantBackfillOptions) (resp azfake.Responder[armmanagementgroups.APIClientStartTenantBackfillResponse], errResp azfake.ErrorResponder) // TenantBackfillStatus is the fake for method APIClient.TenantBackfillStatus // HTTP status codes to indicate success: http.StatusOK - TenantBackfillStatus func(ctx context.Context, options *armmanagementgroups.APIClientTenantBackfillStatusOptions) (resp azfake.Responder[armmanagementgroups.APIClientTenantBackfillStatusResponse], errResp azfake.ErrorResponder) + TenantBackfillStatus func(ctx context.Context, options *armmanagementgroups.APIClientTenantBackfillStatusOptions) (resp azfake.Responder[armmanagementgroups.APIClientTenantBackfillStatusResponse], errResp azfake.ErrorResponder) } // NewAPIServerTransport creates a new instance of APIServerTransport with the provided implementation. @@ -55,25 +51,44 @@ func (a *APIServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error - - switch method { - case "APIClient.CheckNameAvailability": - resp, err = a.dispatchCheckNameAvailability(req) - case "APIClient.StartTenantBackfill": - resp, err = a.dispatchStartTenantBackfill(req) - case "APIClient.TenantBackfillStatus": - resp, err = a.dispatchTenantBackfillStatus(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } + return a.dispatchToMethodFake(req, method) +} - if err != nil { - return nil, err +func (a *APIServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if apiServerTransportInterceptor != nil { + res.resp, res.err, intercepted = apiServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "APIClient.CheckNameAvailability": + res.resp, res.err = a.dispatchCheckNameAvailability(req) + case "APIClient.StartTenantBackfill": + res.resp, res.err = a.dispatchStartTenantBackfill(req) + case "APIClient.TenantBackfillStatus": + res.resp, res.err = a.dispatchTenantBackfillStatus(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err } - - return resp, nil } func (a *APIServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { @@ -136,3 +151,9 @@ func (a *APIServerTransport) dispatchTenantBackfillStatus(req *http.Request) (*h } return resp, nil } + +// set this to conditionally intercept incoming requests to APIServerTransport +var apiServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/entities_server.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/entities_server.go index 5b417ccf338c..7b0e883c7729 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/entities_server.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/entities_server.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -15,7 +11,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups/v2" "net/http" "net/url" "strconv" @@ -33,16 +29,16 @@ type EntitiesServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewEntitiesServerTransport(srv *EntitiesServer) *EntitiesServerTransport { return &EntitiesServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armmanagementgroups.EntitiesClientListResponse]](), + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armmanagementgroups.EntitiesClientListResponse]](), } } // EntitiesServerTransport connects instances of armmanagementgroups.EntitiesClient to instances of EntitiesServer. // Don't use this type directly, use NewEntitiesServerTransport instead. type EntitiesServerTransport struct { - srv *EntitiesServer - newListPager *tracker[azfake.PagerResponder[armmanagementgroups.EntitiesClientListResponse]] + srv *EntitiesServer + newListPager *tracker[azfake.PagerResponder[armmanagementgroups.EntitiesClientListResponse]] } // Do implements the policy.Transporter interface for EntitiesServerTransport. @@ -53,21 +49,40 @@ func (e *EntitiesServerTransport) Do(req *http.Request) (*http.Response, error) return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return e.dispatchToMethodFake(req, method) +} - switch method { - case "EntitiesClient.NewListPager": - resp, err = e.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (e *EntitiesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if entitiesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = entitiesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "EntitiesClient.NewListPager": + res.resp, res.err = e.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (e *EntitiesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -139,15 +154,15 @@ func (e *EntitiesServerTransport) dispatchNewListPager(req *http.Request) (*http var options *armmanagementgroups.EntitiesClientListOptions if skiptokenParam != nil || skipParam != nil || topParam != nil || selectParam != nil || searchParam != nil || filterParam != nil || viewParam != nil || groupNameParam != nil || cacheControlParam != nil { options = &armmanagementgroups.EntitiesClientListOptions{ - Skiptoken: skiptokenParam, - Skip: skipParam, - Top: topParam, - Select: selectParam, - Search: searchParam, - Filter: filterParam, - View: viewParam, - GroupName: groupNameParam, - CacheControl: cacheControlParam, + Skiptoken: skiptokenParam, + Skip: skipParam, + Top: topParam, + Select: selectParam, + Search: searchParam, + Filter: filterParam, + View: viewParam, + GroupName: groupNameParam, + CacheControl: cacheControlParam, } } resp := e.srv.NewListPager(options) @@ -170,3 +185,9 @@ func (e *EntitiesServerTransport) dispatchNewListPager(req *http.Request) (*http } return resp, nil } + +// set this to conditionally intercept incoming requests to EntitiesServerTransport +var entitiesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/hierarchysettings_server.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/hierarchysettings_server.go index a91ae6ecfc4e..aa3721a1f8ab 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/hierarchysettings_server.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/hierarchysettings_server.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -15,7 +11,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups/v2" "net/http" "net/url" "regexp" @@ -25,36 +21,40 @@ import ( type HierarchySettingsServer struct { // CreateOrUpdate is the fake for method HierarchySettingsClient.CreateOrUpdate // HTTP status codes to indicate success: http.StatusOK - CreateOrUpdate func(ctx context.Context, groupID string, createTenantSettingsRequest armmanagementgroups.CreateOrUpdateSettingsRequest, options *armmanagementgroups.HierarchySettingsClientCreateOrUpdateOptions) (resp azfake.Responder[armmanagementgroups.HierarchySettingsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + CreateOrUpdate func(ctx context.Context, groupID string, createTenantSettingsRequest armmanagementgroups.CreateOrUpdateSettingsRequest, options *armmanagementgroups.HierarchySettingsClientCreateOrUpdateOptions) (resp azfake.Responder[armmanagementgroups.HierarchySettingsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // Delete is the fake for method HierarchySettingsClient.Delete // HTTP status codes to indicate success: http.StatusOK - Delete func(ctx context.Context, groupID string, options *armmanagementgroups.HierarchySettingsClientDeleteOptions) (resp azfake.Responder[armmanagementgroups.HierarchySettingsClientDeleteResponse], errResp azfake.ErrorResponder) + Delete func(ctx context.Context, groupID string, options *armmanagementgroups.HierarchySettingsClientDeleteOptions) (resp azfake.Responder[armmanagementgroups.HierarchySettingsClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method HierarchySettingsClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, groupID string, options *armmanagementgroups.HierarchySettingsClientGetOptions) (resp azfake.Responder[armmanagementgroups.HierarchySettingsClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, groupID string, options *armmanagementgroups.HierarchySettingsClientGetOptions) (resp azfake.Responder[armmanagementgroups.HierarchySettingsClientGetResponse], errResp azfake.ErrorResponder) - // List is the fake for method HierarchySettingsClient.List + // NewListPager is the fake for method HierarchySettingsClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - List func(ctx context.Context, groupID string, options *armmanagementgroups.HierarchySettingsClientListOptions) (resp azfake.Responder[armmanagementgroups.HierarchySettingsClientListResponse], errResp azfake.ErrorResponder) + NewListPager func(groupID string, options *armmanagementgroups.HierarchySettingsClientListOptions) (resp azfake.PagerResponder[armmanagementgroups.HierarchySettingsClientListResponse]) // Update is the fake for method HierarchySettingsClient.Update // HTTP status codes to indicate success: http.StatusOK - Update func(ctx context.Context, groupID string, createTenantSettingsRequest armmanagementgroups.CreateOrUpdateSettingsRequest, options *armmanagementgroups.HierarchySettingsClientUpdateOptions) (resp azfake.Responder[armmanagementgroups.HierarchySettingsClientUpdateResponse], errResp azfake.ErrorResponder) + Update func(ctx context.Context, groupID string, createTenantSettingsRequest armmanagementgroups.CreateOrUpdateSettingsRequest, options *armmanagementgroups.HierarchySettingsClientUpdateOptions) (resp azfake.Responder[armmanagementgroups.HierarchySettingsClientUpdateResponse], errResp azfake.ErrorResponder) } // NewHierarchySettingsServerTransport creates a new instance of HierarchySettingsServerTransport with the provided implementation. // The returned HierarchySettingsServerTransport instance is connected to an instance of armmanagementgroups.HierarchySettingsClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewHierarchySettingsServerTransport(srv *HierarchySettingsServer) *HierarchySettingsServerTransport { - return &HierarchySettingsServerTransport{srv: srv} + return &HierarchySettingsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armmanagementgroups.HierarchySettingsClientListResponse]](), + } } // HierarchySettingsServerTransport connects instances of armmanagementgroups.HierarchySettingsClient to instances of HierarchySettingsServer. // Don't use this type directly, use NewHierarchySettingsServerTransport instead. type HierarchySettingsServerTransport struct { - srv *HierarchySettingsServer + srv *HierarchySettingsServer + newListPager *tracker[azfake.PagerResponder[armmanagementgroups.HierarchySettingsClientListResponse]] } // Do implements the policy.Transporter interface for HierarchySettingsServerTransport. @@ -65,29 +65,48 @@ func (h *HierarchySettingsServerTransport) Do(req *http.Request) (*http.Response return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return h.dispatchToMethodFake(req, method) +} - switch method { - case "HierarchySettingsClient.CreateOrUpdate": - resp, err = h.dispatchCreateOrUpdate(req) - case "HierarchySettingsClient.Delete": - resp, err = h.dispatchDelete(req) - case "HierarchySettingsClient.Get": - resp, err = h.dispatchGet(req) - case "HierarchySettingsClient.List": - resp, err = h.dispatchList(req) - case "HierarchySettingsClient.Update": - resp, err = h.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (h *HierarchySettingsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if hierarchySettingsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = hierarchySettingsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "HierarchySettingsClient.CreateOrUpdate": + res.resp, res.err = h.dispatchCreateOrUpdate(req) + case "HierarchySettingsClient.Delete": + res.resp, res.err = h.dispatchDelete(req) + case "HierarchySettingsClient.Get": + res.resp, res.err = h.dispatchGet(req) + case "HierarchySettingsClient.NewListPager": + res.resp, res.err = h.dispatchNewListPager(req) + case "HierarchySettingsClient.Update": + res.resp, res.err = h.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (h *HierarchySettingsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -97,7 +116,7 @@ func (h *HierarchySettingsServerTransport) dispatchCreateOrUpdate(req *http.Requ const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/settings/default` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armmanagementgroups.CreateOrUpdateSettingsRequest](req) @@ -130,7 +149,7 @@ func (h *HierarchySettingsServerTransport) dispatchDelete(req *http.Request) (*h const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/settings/default` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } groupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupId")]) @@ -159,7 +178,7 @@ func (h *HierarchySettingsServerTransport) dispatchGet(req *http.Request) (*http const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/settings/default` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } groupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupId")]) @@ -181,31 +200,36 @@ func (h *HierarchySettingsServerTransport) dispatchGet(req *http.Request) (*http return resp, nil } -func (h *HierarchySettingsServerTransport) dispatchList(req *http.Request) (*http.Response, error) { - if h.srv.List == nil { - return nil, &nonRetriableError{errors.New("fake for method List not implemented")} - } - const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/settings` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - groupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupId")]) +func (h *HierarchySettingsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if h.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := h.newListPager.get(req) + if newListPager == nil { + const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/settings` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + groupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupId")]) + if err != nil { + return nil, err + } + resp := h.srv.NewListPager(groupIDParam, nil) + newListPager = &resp + h.newListPager.add(req, newListPager) + } + resp, err := server.PagerResponderNext(newListPager, req) if err != nil { return nil, err } - respr, errRespr := h.srv.List(req.Context(), groupIDParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr + if !contains([]int{http.StatusOK}, resp.StatusCode) { + h.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).HierarchySettingsList, req) - if err != nil { - return nil, err + if !server.PagerResponderMore(newListPager) { + h.newListPager.remove(req) } return resp, nil } @@ -217,7 +241,7 @@ func (h *HierarchySettingsServerTransport) dispatchUpdate(req *http.Request) (*h const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/settings/default` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armmanagementgroups.CreateOrUpdateSettingsRequest](req) @@ -242,3 +266,9 @@ func (h *HierarchySettingsServerTransport) dispatchUpdate(req *http.Request) (*h } return resp, nil } + +// set this to conditionally intercept incoming requests to HierarchySettingsServerTransport +var hierarchySettingsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/internal.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/internal.go index c63abf57927c..d46bc9665f2e 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/internal.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/internal.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -15,6 +11,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/managementgroupsubscriptions_server.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/managementgroupsubscriptions_server.go index 0bfa9302dc7d..b38cd23f9c44 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/managementgroupsubscriptions_server.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/managementgroupsubscriptions_server.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -16,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups/v2" "net/http" "net/url" "regexp" @@ -26,19 +22,19 @@ import ( type ManagementGroupSubscriptionsServer struct { // Create is the fake for method ManagementGroupSubscriptionsClient.Create // HTTP status codes to indicate success: http.StatusOK - Create func(ctx context.Context, groupID string, subscriptionID string, options *armmanagementgroups.ManagementGroupSubscriptionsClientCreateOptions) (resp azfake.Responder[armmanagementgroups.ManagementGroupSubscriptionsClientCreateResponse], errResp azfake.ErrorResponder) + Create func(ctx context.Context, groupID string, subscriptionID string, options *armmanagementgroups.ManagementGroupSubscriptionsClientCreateOptions) (resp azfake.Responder[armmanagementgroups.ManagementGroupSubscriptionsClientCreateResponse], errResp azfake.ErrorResponder) // Delete is the fake for method ManagementGroupSubscriptionsClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, groupID string, subscriptionID string, options *armmanagementgroups.ManagementGroupSubscriptionsClientDeleteOptions) (resp azfake.Responder[armmanagementgroups.ManagementGroupSubscriptionsClientDeleteResponse], errResp azfake.ErrorResponder) + Delete func(ctx context.Context, groupID string, subscriptionID string, options *armmanagementgroups.ManagementGroupSubscriptionsClientDeleteOptions) (resp azfake.Responder[armmanagementgroups.ManagementGroupSubscriptionsClientDeleteResponse], errResp azfake.ErrorResponder) // GetSubscription is the fake for method ManagementGroupSubscriptionsClient.GetSubscription // HTTP status codes to indicate success: http.StatusOK - GetSubscription func(ctx context.Context, groupID string, subscriptionID string, options *armmanagementgroups.ManagementGroupSubscriptionsClientGetSubscriptionOptions) (resp azfake.Responder[armmanagementgroups.ManagementGroupSubscriptionsClientGetSubscriptionResponse], errResp azfake.ErrorResponder) + GetSubscription func(ctx context.Context, groupID string, subscriptionID string, options *armmanagementgroups.ManagementGroupSubscriptionsClientGetSubscriptionOptions) (resp azfake.Responder[armmanagementgroups.ManagementGroupSubscriptionsClientGetSubscriptionResponse], errResp azfake.ErrorResponder) // NewGetSubscriptionsUnderManagementGroupPager is the fake for method ManagementGroupSubscriptionsClient.NewGetSubscriptionsUnderManagementGroupPager // HTTP status codes to indicate success: http.StatusOK - NewGetSubscriptionsUnderManagementGroupPager func(groupID string, options *armmanagementgroups.ManagementGroupSubscriptionsClientGetSubscriptionsUnderManagementGroupOptions) (resp azfake.PagerResponder[armmanagementgroups.ManagementGroupSubscriptionsClientGetSubscriptionsUnderManagementGroupResponse]) + NewGetSubscriptionsUnderManagementGroupPager func(groupID string, options *armmanagementgroups.ManagementGroupSubscriptionsClientGetSubscriptionsUnderManagementGroupOptions) (resp azfake.PagerResponder[armmanagementgroups.ManagementGroupSubscriptionsClientGetSubscriptionsUnderManagementGroupResponse]) } // NewManagementGroupSubscriptionsServerTransport creates a new instance of ManagementGroupSubscriptionsServerTransport with the provided implementation. @@ -46,16 +42,16 @@ type ManagementGroupSubscriptionsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewManagementGroupSubscriptionsServerTransport(srv *ManagementGroupSubscriptionsServer) *ManagementGroupSubscriptionsServerTransport { return &ManagementGroupSubscriptionsServerTransport{ - srv: srv, - newGetSubscriptionsUnderManagementGroupPager: newTracker[azfake.PagerResponder[armmanagementgroups.ManagementGroupSubscriptionsClientGetSubscriptionsUnderManagementGroupResponse]](), + srv: srv, + newGetSubscriptionsUnderManagementGroupPager: newTracker[azfake.PagerResponder[armmanagementgroups.ManagementGroupSubscriptionsClientGetSubscriptionsUnderManagementGroupResponse]](), } } // ManagementGroupSubscriptionsServerTransport connects instances of armmanagementgroups.ManagementGroupSubscriptionsClient to instances of ManagementGroupSubscriptionsServer. // Don't use this type directly, use NewManagementGroupSubscriptionsServerTransport instead. type ManagementGroupSubscriptionsServerTransport struct { - srv *ManagementGroupSubscriptionsServer - newGetSubscriptionsUnderManagementGroupPager *tracker[azfake.PagerResponder[armmanagementgroups.ManagementGroupSubscriptionsClientGetSubscriptionsUnderManagementGroupResponse]] + srv *ManagementGroupSubscriptionsServer + newGetSubscriptionsUnderManagementGroupPager *tracker[azfake.PagerResponder[armmanagementgroups.ManagementGroupSubscriptionsClientGetSubscriptionsUnderManagementGroupResponse]] } // Do implements the policy.Transporter interface for ManagementGroupSubscriptionsServerTransport. @@ -66,27 +62,46 @@ func (m *ManagementGroupSubscriptionsServerTransport) Do(req *http.Request) (*ht return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return m.dispatchToMethodFake(req, method) +} - switch method { - case "ManagementGroupSubscriptionsClient.Create": - resp, err = m.dispatchCreate(req) - case "ManagementGroupSubscriptionsClient.Delete": - resp, err = m.dispatchDelete(req) - case "ManagementGroupSubscriptionsClient.GetSubscription": - resp, err = m.dispatchGetSubscription(req) - case "ManagementGroupSubscriptionsClient.NewGetSubscriptionsUnderManagementGroupPager": - resp, err = m.dispatchNewGetSubscriptionsUnderManagementGroupPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (m *ManagementGroupSubscriptionsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if managementGroupSubscriptionsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = managementGroupSubscriptionsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ManagementGroupSubscriptionsClient.Create": + res.resp, res.err = m.dispatchCreate(req) + case "ManagementGroupSubscriptionsClient.Delete": + res.resp, res.err = m.dispatchDelete(req) + case "ManagementGroupSubscriptionsClient.GetSubscription": + res.resp, res.err = m.dispatchGetSubscription(req) + case "ManagementGroupSubscriptionsClient.NewGetSubscriptionsUnderManagementGroupPager": + res.resp, res.err = m.dispatchNewGetSubscriptionsUnderManagementGroupPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (m *ManagementGroupSubscriptionsServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { @@ -96,7 +111,7 @@ func (m *ManagementGroupSubscriptionsServerTransport) dispatchCreate(req *http.R const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } groupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupId")]) @@ -136,7 +151,7 @@ func (m *ManagementGroupSubscriptionsServerTransport) dispatchDelete(req *http.R const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } groupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupId")]) @@ -176,7 +191,7 @@ func (m *ManagementGroupSubscriptionsServerTransport) dispatchGetSubscription(re const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } groupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupId")]) @@ -218,7 +233,7 @@ func (m *ManagementGroupSubscriptionsServerTransport) dispatchNewGetSubscription const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/subscriptions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -257,3 +272,9 @@ func (m *ManagementGroupSubscriptionsServerTransport) dispatchNewGetSubscription } return resp, nil } + +// set this to conditionally intercept incoming requests to ManagementGroupSubscriptionsServerTransport +var managementGroupSubscriptionsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/operations_server.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/operations_server.go index ed152a840e21..fa5da917f9f8 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/operations_server.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/operations_server.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -15,7 +11,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups/v2" "net/http" ) @@ -31,16 +27,16 @@ type OperationsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { return &OperationsServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armmanagementgroups.OperationsClientListResponse]](), + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armmanagementgroups.OperationsClientListResponse]](), } } // OperationsServerTransport connects instances of armmanagementgroups.OperationsClient to instances of OperationsServer. // Don't use this type directly, use NewOperationsServerTransport instead. type OperationsServerTransport struct { - srv *OperationsServer - newListPager *tracker[azfake.PagerResponder[armmanagementgroups.OperationsClientListResponse]] + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armmanagementgroups.OperationsClientListResponse]] } // Do implements the policy.Transporter interface for OperationsServerTransport. @@ -51,21 +47,40 @@ func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return o.dispatchToMethodFake(req, method) +} - switch method { - case "OperationsClient.NewListPager": - resp, err = o.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -94,3 +109,9 @@ func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*ht } return resp, nil } + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/server.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/server.go index 0450b8b74b93..b2c452d7290a 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/server.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/server.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -16,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups/v2" "net/http" "net/url" "regexp" @@ -27,27 +23,27 @@ import ( type Server struct { // BeginCreateOrUpdate is the fake for method Client.BeginCreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginCreateOrUpdate func(ctx context.Context, groupID string, createManagementGroupRequest armmanagementgroups.CreateManagementGroupRequest, options *armmanagementgroups.ClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armmanagementgroups.ClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + BeginCreateOrUpdate func(ctx context.Context, groupID string, createManagementGroupRequest armmanagementgroups.CreateManagementGroupRequest, options *armmanagementgroups.ClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armmanagementgroups.ClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // BeginDelete is the fake for method Client.BeginDelete - // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent - BeginDelete func(ctx context.Context, groupID string, options *armmanagementgroups.ClientBeginDeleteOptions) (resp azfake.PollerResponder[armmanagementgroups.ClientDeleteResponse], errResp azfake.ErrorResponder) + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, groupID string, options *armmanagementgroups.ClientBeginDeleteOptions) (resp azfake.PollerResponder[armmanagementgroups.ClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method Client.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, groupID string, options *armmanagementgroups.ClientGetOptions) (resp azfake.Responder[armmanagementgroups.ClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, groupID string, options *armmanagementgroups.ClientGetOptions) (resp azfake.Responder[armmanagementgroups.ClientGetResponse], errResp azfake.ErrorResponder) // NewGetDescendantsPager is the fake for method Client.NewGetDescendantsPager // HTTP status codes to indicate success: http.StatusOK - NewGetDescendantsPager func(groupID string, options *armmanagementgroups.ClientGetDescendantsOptions) (resp azfake.PagerResponder[armmanagementgroups.ClientGetDescendantsResponse]) + NewGetDescendantsPager func(groupID string, options *armmanagementgroups.ClientGetDescendantsOptions) (resp azfake.PagerResponder[armmanagementgroups.ClientGetDescendantsResponse]) // NewListPager is the fake for method Client.NewListPager // HTTP status codes to indicate success: http.StatusOK - NewListPager func(options *armmanagementgroups.ClientListOptions) (resp azfake.PagerResponder[armmanagementgroups.ClientListResponse]) + NewListPager func(options *armmanagementgroups.ClientListOptions) (resp azfake.PagerResponder[armmanagementgroups.ClientListResponse]) // Update is the fake for method Client.Update // HTTP status codes to indicate success: http.StatusOK - Update func(ctx context.Context, groupID string, patchGroupRequest armmanagementgroups.PatchManagementGroupRequest, options *armmanagementgroups.ClientUpdateOptions) (resp azfake.Responder[armmanagementgroups.ClientUpdateResponse], errResp azfake.ErrorResponder) + Update func(ctx context.Context, groupID string, patchGroupRequest armmanagementgroups.PatchManagementGroupRequest, options *armmanagementgroups.ClientUpdateOptions) (resp azfake.Responder[armmanagementgroups.ClientUpdateResponse], errResp azfake.ErrorResponder) } // NewServerTransport creates a new instance of ServerTransport with the provided implementation. @@ -55,22 +51,22 @@ type Server struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewServerTransport(srv *Server) *ServerTransport { return &ServerTransport{ - srv: srv, - beginCreateOrUpdate: newTracker[azfake.PollerResponder[armmanagementgroups.ClientCreateOrUpdateResponse]](), - beginDelete: newTracker[azfake.PollerResponder[armmanagementgroups.ClientDeleteResponse]](), - newGetDescendantsPager: newTracker[azfake.PagerResponder[armmanagementgroups.ClientGetDescendantsResponse]](), - newListPager: newTracker[azfake.PagerResponder[armmanagementgroups.ClientListResponse]](), + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armmanagementgroups.ClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armmanagementgroups.ClientDeleteResponse]](), + newGetDescendantsPager: newTracker[azfake.PagerResponder[armmanagementgroups.ClientGetDescendantsResponse]](), + newListPager: newTracker[azfake.PagerResponder[armmanagementgroups.ClientListResponse]](), } } // ServerTransport connects instances of armmanagementgroups.Client to instances of Server. // Don't use this type directly, use NewServerTransport instead. type ServerTransport struct { - srv *Server - beginCreateOrUpdate *tracker[azfake.PollerResponder[armmanagementgroups.ClientCreateOrUpdateResponse]] - beginDelete *tracker[azfake.PollerResponder[armmanagementgroups.ClientDeleteResponse]] - newGetDescendantsPager *tracker[azfake.PagerResponder[armmanagementgroups.ClientGetDescendantsResponse]] - newListPager *tracker[azfake.PagerResponder[armmanagementgroups.ClientListResponse]] + srv *Server + beginCreateOrUpdate *tracker[azfake.PollerResponder[armmanagementgroups.ClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armmanagementgroups.ClientDeleteResponse]] + newGetDescendantsPager *tracker[azfake.PagerResponder[armmanagementgroups.ClientGetDescendantsResponse]] + newListPager *tracker[azfake.PagerResponder[armmanagementgroups.ClientListResponse]] } // Do implements the policy.Transporter interface for ServerTransport. @@ -81,31 +77,50 @@ func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return s.dispatchToMethodFake(req, method) +} - switch method { - case "Client.BeginCreateOrUpdate": - resp, err = s.dispatchBeginCreateOrUpdate(req) - case "Client.BeginDelete": - resp, err = s.dispatchBeginDelete(req) - case "Client.Get": - resp, err = s.dispatchGet(req) - case "Client.NewGetDescendantsPager": - resp, err = s.dispatchNewGetDescendantsPager(req) - case "Client.NewListPager": - resp, err = s.dispatchNewListPager(req) - case "Client.Update": - resp, err = s.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (s *ServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if serverTransportInterceptor != nil { + res.resp, res.err, intercepted = serverTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "Client.BeginCreateOrUpdate": + res.resp, res.err = s.dispatchBeginCreateOrUpdate(req) + case "Client.BeginDelete": + res.resp, res.err = s.dispatchBeginDelete(req) + case "Client.Get": + res.resp, res.err = s.dispatchGet(req) + case "Client.NewGetDescendantsPager": + res.resp, res.err = s.dispatchNewGetDescendantsPager(req) + case "Client.NewListPager": + res.resp, res.err = s.dispatchNewListPager(req) + case "Client.Update": + res.resp, res.err = s.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *ServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -117,7 +132,7 @@ func (s *ServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http. const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armmanagementgroups.CreateManagementGroupRequest](req) @@ -168,7 +183,7 @@ func (s *ServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } groupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupId")]) @@ -195,9 +210,9 @@ func (s *ServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response return nil, err } - if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { s.beginDelete.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} } if !server.PollerResponderMore(beginDelete) { s.beginDelete.remove(req) @@ -213,7 +228,7 @@ func (s *ServerTransport) dispatchGet(req *http.Request) (*http.Response, error) const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -243,10 +258,10 @@ func (s *ServerTransport) dispatchGet(req *http.Request) (*http.Response, error) var options *armmanagementgroups.ClientGetOptions if expandParam != nil || recurseParam != nil || filterParam != nil || cacheControlParam != nil { options = &armmanagementgroups.ClientGetOptions{ - Expand: expandParam, - Recurse: recurseParam, - Filter: filterParam, - CacheControl: cacheControlParam, + Expand: expandParam, + Recurse: recurseParam, + Filter: filterParam, + CacheControl: cacheControlParam, } } respr, errRespr := s.srv.Get(req.Context(), groupIDParam, options) @@ -273,7 +288,7 @@ func (s *ServerTransport) dispatchNewGetDescendantsPager(req *http.Request) (*ht const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/descendants` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -303,8 +318,8 @@ func (s *ServerTransport) dispatchNewGetDescendantsPager(req *http.Request) (*ht var options *armmanagementgroups.ClientGetDescendantsOptions if skiptokenParam != nil || topParam != nil { options = &armmanagementgroups.ClientGetDescendantsOptions{ - Skiptoken: skiptokenParam, - Top: topParam, + Skiptoken: skiptokenParam, + Top: topParam, } } resp := s.srv.NewGetDescendantsPager(groupIDParam, options) @@ -344,8 +359,8 @@ func (s *ServerTransport) dispatchNewListPager(req *http.Request) (*http.Respons var options *armmanagementgroups.ClientListOptions if cacheControlParam != nil || skiptokenParam != nil { options = &armmanagementgroups.ClientListOptions{ - CacheControl: cacheControlParam, - Skiptoken: skiptokenParam, + CacheControl: cacheControlParam, + Skiptoken: skiptokenParam, } } resp := s.srv.NewListPager(options) @@ -376,7 +391,7 @@ func (s *ServerTransport) dispatchUpdate(req *http.Request) (*http.Response, err const regexStr = `/providers/Microsoft\.Management/managementGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armmanagementgroups.PatchManagementGroupRequest](req) @@ -408,3 +423,9 @@ func (s *ServerTransport) dispatchUpdate(req *http.Request) (*http.Response, err } return resp, nil } + +// set this to conditionally intercept incoming requests to ServerTransport +var serverTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/server_factory.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/server_factory.go index 3ea7731bbcd8..12589ded6e4d 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/server_factory.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/server_factory.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -19,12 +15,23 @@ import ( // ServerFactory is a fake server for instances of the armmanagementgroups.ClientFactory type. type ServerFactory struct { - APIServer APIServer - Server Server - EntitiesServer EntitiesServer - HierarchySettingsServer HierarchySettingsServer + // APIServer contains the fakes for client APIClient + APIServer APIServer + + // Server contains the fakes for client Client + Server Server + + // EntitiesServer contains the fakes for client EntitiesClient + EntitiesServer EntitiesServer + + // HierarchySettingsServer contains the fakes for client HierarchySettingsClient + HierarchySettingsServer HierarchySettingsServer + + // ManagementGroupSubscriptionsServer contains the fakes for client ManagementGroupSubscriptionsClient ManagementGroupSubscriptionsServer ManagementGroupSubscriptionsServer - OperationsServer OperationsServer + + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/time_rfc3339.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/time_rfc3339.go deleted file mode 100644 index b0535a7b63e6..000000000000 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/fake/time_rfc3339.go +++ /dev/null @@ -1,86 +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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" - "regexp" - "strings" - "time" -) - -// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) - -const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` -) - -type dateTimeRFC3339 time.Time - -func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalJSON() -} - -func (t dateTimeRFC3339) MarshalText() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalText() -} - -func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { - layout = dateTimeJSON - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { - layout = time.RFC3339Nano - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) Parse(layout, value string) error { - p, err := time.Parse(layout, strings.ToUpper(value)) - *t = dateTimeRFC3339(p) - return err -} - -func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { - if t == nil { - return - } else if azcore.IsNullValue(t) { - m[k] = nil - return - } else if reflect.ValueOf(t).IsNil() { - return - } - m[k] = (*dateTimeRFC3339)(t) -} - -func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { - return nil - } - var aux dateTimeRFC3339 - if err := json.Unmarshal(data, &aux); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - *t = (*time.Time)(&aux) - return nil -} diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/go.mod b/sdk/resourcemanager/managementgroups/armmanagementgroups/go.mod index 05a898dfa3e0..009453e6d864 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/go.mod +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/go.mod @@ -1,13 +1,13 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups/v2 go 1.23.0 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.1 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1 - github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 + github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 - github.com/stretchr/testify v1.10.0 + github.com/stretchr/testify v1.11.1 ) require ( @@ -19,9 +19,9 @@ require ( github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/crypto v0.40.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.34.0 // indirect - golang.org/x/text v0.27.0 // indirect + golang.org/x/crypto v0.41.0 // indirect + golang.org/x/net v0.43.0 // indirect + golang.org/x/sys v0.35.0 // indirect + golang.org/x/text v0.28.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/go.sum b/sdk/resourcemanager/managementgroups/armmanagementgroups/go.sum index 2b9951b66f05..a0aea6c2e87c 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/go.sum +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/go.sum @@ -1,15 +1,17 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.1 h1:Wc1ml6QlJs2BHQ/9Bqu1jiyggbsSjramq2oUmp5WeIo= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.1/go.mod h1:Ot/6aikWnKWi4l9QB7qVSwa8iMphQNqkWALMoNT3rzM= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0 h1:JXg2dwJUmPB9JmtVmdEB16APJ7jurfbY5jnfXpJoRMc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0/go.mod h1:YD5h/ldMsG0XiIw7PdyNhLxaM317eFh5yNLccNfGdyw= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1 h1:B+blDbyVIG3WaikNxPnhPiJ1MThR03b3vKGtER95TP4= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1/go.mod h1:JdM5psgjfBf5fo2uWOZhflPWyDBZ/O/CNAH9CtsuZE4= github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY= github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2/go.mod h1:Pa9ZNPuoNu/GztvBSKk9J1cDJW6vk/n0zLtV4mgd8N8= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 h1:FPKJS1T+clwv+OLGt13a8UjqeRuh0O4SJ3lUriThc+4= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1/go.mod h1:j2chePtV91HrC22tGoRX3sGY42uF13WzmmV80/OdVAA= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 h1:9iefClla7iYpfYWdzPCRDozdmndjTm8DXdpCzPajMgA= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2/go.mod h1:XtLgD3ZD34DAaVIIAyG3objl5DynM3CQ/vMcbBNJZGI= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 h1:PTFGRSlMKCQelWwxUyYVEUqseBJVemLyqWJjvMyt0do= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0/go.mod h1:LRr2FzBTQlONPPa5HREE5+RjSCTXl7BwOvYOaWTqCaI= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 h1:2qsIIvxVT+uE6yrNldntJKlLRgxGbZ85kgtz5SNBhMw= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0/go.mod h1:AW8VEadnhw9xox+VaVd9sP7NjzOAnaZBLRH6Tq3cJ38= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups v1.0.0 h1:pPvTJ1dY0sA35JOeFq6TsY2xj6Z85Yo23Pj4wCCvu4o= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups v1.0.0/go.mod h1:mLfWfj8v3jfWKsL9G4eoBoXVcsqcIUTapmdKy7uGOp0= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 h1:Dd+RhdJn0OTtVGaeDLZpcumkIVCtA/3/Fo42+eoYvVM= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0/go.mod h1:5kakwfW5CjC9KK+Q4wjXAg+ShuIm2mBMua0ZFj2C8PE= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= @@ -42,17 +44,17 @@ github.com/redis/go-redis/v9 v9.8.0 h1:q3nRvjrlge/6UD7eTu/DSg2uYiU2mCL0G/uzBWqhi github.com/redis/go-redis/v9 v9.8.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM= -golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4= +golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc= +golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE= +golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= -golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= +golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= +golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= +golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/hierarchysettings_client.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/hierarchysettings_client.go index fb70c2468f73..b9de4b970421 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/hierarchysettings_client.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/hierarchysettings_client.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armmanagementgroups @@ -28,7 +24,7 @@ type HierarchySettingsClient struct { // NewHierarchySettingsClient creates a new instance of HierarchySettingsClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewHierarchySettingsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*HierarchySettingsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -43,7 +39,7 @@ func NewHierarchySettingsClient(credential azcore.TokenCredential, options *arm. // CreateOrUpdate - Creates or updates the hierarchy settings defined at the Management Group level. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2023-04-01 // - groupID - Management Group ID. // - createTenantSettingsRequest - Tenant level settings request parameter. // - options - HierarchySettingsClientCreateOrUpdateOptions contains the optional parameters for the HierarchySettingsClient.CreateOrUpdate @@ -71,7 +67,7 @@ func (client *HierarchySettingsClient) CreateOrUpdate(ctx context.Context, group } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *HierarchySettingsClient) createOrUpdateCreateRequest(ctx context.Context, groupID string, createTenantSettingsRequest CreateOrUpdateSettingsRequest, options *HierarchySettingsClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *HierarchySettingsClient) createOrUpdateCreateRequest(ctx context.Context, groupID string, createTenantSettingsRequest CreateOrUpdateSettingsRequest, _ *HierarchySettingsClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default" if groupID == "" { return nil, errors.New("parameter groupID cannot be empty") @@ -82,9 +78,10 @@ func (client *HierarchySettingsClient) createOrUpdateCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, createTenantSettingsRequest); err != nil { return nil, err } @@ -103,7 +100,7 @@ func (client *HierarchySettingsClient) createOrUpdateHandleResponse(resp *http.R // Delete - Deletes the hierarchy settings defined at the Management Group level. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2023-04-01 // - groupID - Management Group ID. // - options - HierarchySettingsClientDeleteOptions contains the optional parameters for the HierarchySettingsClient.Delete // method. @@ -129,7 +126,7 @@ func (client *HierarchySettingsClient) Delete(ctx context.Context, groupID strin } // deleteCreateRequest creates the Delete request. -func (client *HierarchySettingsClient) deleteCreateRequest(ctx context.Context, groupID string, options *HierarchySettingsClientDeleteOptions) (*policy.Request, error) { +func (client *HierarchySettingsClient) deleteCreateRequest(ctx context.Context, groupID string, _ *HierarchySettingsClientDeleteOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default" if groupID == "" { return nil, errors.New("parameter groupID cannot be empty") @@ -140,9 +137,8 @@ func (client *HierarchySettingsClient) deleteCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -150,7 +146,7 @@ func (client *HierarchySettingsClient) deleteCreateRequest(ctx context.Context, // Group of the hierarchy. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2023-04-01 // - groupID - Management Group ID. // - options - HierarchySettingsClientGetOptions contains the optional parameters for the HierarchySettingsClient.Get method. func (client *HierarchySettingsClient) Get(ctx context.Context, groupID string, options *HierarchySettingsClientGetOptions) (HierarchySettingsClientGetResponse, error) { @@ -176,7 +172,7 @@ func (client *HierarchySettingsClient) Get(ctx context.Context, groupID string, } // getCreateRequest creates the Get request. -func (client *HierarchySettingsClient) getCreateRequest(ctx context.Context, groupID string, options *HierarchySettingsClientGetOptions) (*policy.Request, error) { +func (client *HierarchySettingsClient) getCreateRequest(ctx context.Context, groupID string, _ *HierarchySettingsClientGetOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default" if groupID == "" { return nil, errors.New("parameter groupID cannot be empty") @@ -187,7 +183,7 @@ func (client *HierarchySettingsClient) getCreateRequest(ctx context.Context, gro return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -202,37 +198,39 @@ func (client *HierarchySettingsClient) getHandleResponse(resp *http.Response) (H return result, nil } -// List - Gets all the hierarchy settings defined at the Management Group level. Settings can only be set on the root Management -// Group of the hierarchy. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListPager - Gets all the hierarchy settings defined at the Management Group level. Settings can only be set on the root +// Management Group of the hierarchy. // -// Generated from API version 2021-04-01 +// Generated from API version 2023-04-01 // - groupID - Management Group ID. -// - options - HierarchySettingsClientListOptions contains the optional parameters for the HierarchySettingsClient.List method. -func (client *HierarchySettingsClient) List(ctx context.Context, groupID string, options *HierarchySettingsClientListOptions) (HierarchySettingsClientListResponse, error) { - var err error - const operationName = "HierarchySettingsClient.List" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.listCreateRequest(ctx, groupID, options) - if err != nil { - return HierarchySettingsClientListResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return HierarchySettingsClientListResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return HierarchySettingsClientListResponse{}, err - } - resp, err := client.listHandleResponse(httpResp) - return resp, err +// - options - HierarchySettingsClientListOptions contains the optional parameters for the HierarchySettingsClient.NewListPager +// method. +func (client *HierarchySettingsClient) NewListPager(groupID string, options *HierarchySettingsClientListOptions) *runtime.Pager[HierarchySettingsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[HierarchySettingsClientListResponse]{ + More: func(page HierarchySettingsClientListResponse) bool { + return false + }, + Fetcher: func(ctx context.Context, page *HierarchySettingsClientListResponse) (HierarchySettingsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "HierarchySettingsClient.NewListPager") + req, err := client.listCreateRequest(ctx, groupID, options) + if err != nil { + return HierarchySettingsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return HierarchySettingsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return HierarchySettingsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) } // listCreateRequest creates the List request. -func (client *HierarchySettingsClient) listCreateRequest(ctx context.Context, groupID string, options *HierarchySettingsClientListOptions) (*policy.Request, error) { +func (client *HierarchySettingsClient) listCreateRequest(ctx context.Context, groupID string, _ *HierarchySettingsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/settings" if groupID == "" { return nil, errors.New("parameter groupID cannot be empty") @@ -243,7 +241,7 @@ func (client *HierarchySettingsClient) listCreateRequest(ctx context.Context, gr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -261,7 +259,7 @@ func (client *HierarchySettingsClient) listHandleResponse(resp *http.Response) ( // Update - Updates the hierarchy settings defined at the Management Group level. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 +// Generated from API version 2023-04-01 // - groupID - Management Group ID. // - createTenantSettingsRequest - Tenant level settings request parameter. // - options - HierarchySettingsClientUpdateOptions contains the optional parameters for the HierarchySettingsClient.Update @@ -289,7 +287,7 @@ func (client *HierarchySettingsClient) Update(ctx context.Context, groupID strin } // updateCreateRequest creates the Update request. -func (client *HierarchySettingsClient) updateCreateRequest(ctx context.Context, groupID string, createTenantSettingsRequest CreateOrUpdateSettingsRequest, options *HierarchySettingsClientUpdateOptions) (*policy.Request, error) { +func (client *HierarchySettingsClient) updateCreateRequest(ctx context.Context, groupID string, createTenantSettingsRequest CreateOrUpdateSettingsRequest, _ *HierarchySettingsClientUpdateOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{groupId}/settings/default" if groupID == "" { return nil, errors.New("parameter groupID cannot be empty") @@ -300,9 +298,10 @@ func (client *HierarchySettingsClient) updateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, createTenantSettingsRequest); err != nil { return nil, err } diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/hierarchysettings_client_example_test.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/hierarchysettings_client_example_test.go index 875aba4e1efe..89f81710dbf7 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/hierarchysettings_client_example_test.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/hierarchysettings_client_example_test.go @@ -1,25 +1,19 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armmanagementgroups_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/managementgroups/armmanagementgroups" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/ListHierarchySettings.json -func ExampleHierarchySettingsClient_List() { +// Generated from example definition: 2023-04-01/PutHierarchySettings.json +func ExampleHierarchySettingsClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -29,30 +23,34 @@ func ExampleHierarchySettingsClient_List() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewHierarchySettingsClient().List(ctx, "root", nil) + res, err := clientFactory.NewHierarchySettingsClient().CreateOrUpdate(ctx, "root", armmanagementgroups.CreateOrUpdateSettingsRequest{ + Properties: &armmanagementgroups.CreateOrUpdateSettingsProperties{ + DefaultManagementGroup: to.Ptr("/providers/Microsoft.Management/managementGroups/DefaultGroup"), + RequireAuthorizationForGroupCreation: to.Ptr(true), + }, + }, 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.HierarchySettingsList = armmanagementgroups.HierarchySettingsList{ - // Value: []*armmanagementgroups.HierarchySettingsInfo{ - // { - // Name: to.Ptr("root"), - // Type: to.Ptr("Microsoft.Management/managementGroups/settings"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/root/settings/default"), - // Properties: &armmanagementgroups.HierarchySettingsProperties{ - // DefaultManagementGroup: to.Ptr("/providers/Microsoft.Management/managementGroups/DefaultGroup"), - // RequireAuthorizationForGroupCreation: to.Ptr(true), - // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), - // }, - // }}, + // res = armmanagementgroups.HierarchySettingsClientCreateOrUpdateResponse{ + // HierarchySettings: &armmanagementgroups.HierarchySettings{ + // Name: to.Ptr("root"), + // Type: to.Ptr("Microsoft.Management/managementGroups/settings"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/root/settings/default"), + // Properties: &armmanagementgroups.HierarchySettingsProperties{ + // DefaultManagementGroup: to.Ptr("/providers/Microsoft.Management/managementGroups/DefaultGroup"), + // RequireAuthorizationForGroupCreation: to.Ptr(true), + // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), + // }, + // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetHierarchySettings.json -func ExampleHierarchySettingsClient_Get() { +// Generated from example definition: 2023-04-01/DeleteHierarchySettings.json +func ExampleHierarchySettingsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -62,27 +60,19 @@ func ExampleHierarchySettingsClient_Get() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewHierarchySettingsClient().Get(ctx, "root", nil) + res, err := clientFactory.NewHierarchySettingsClient().Delete(ctx, "root", 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.HierarchySettings = armmanagementgroups.HierarchySettings{ - // Name: to.Ptr("root"), - // Type: to.Ptr("Microsoft.Management/managementGroups/settings"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/root/settings/default"), - // Properties: &armmanagementgroups.HierarchySettingsProperties{ - // DefaultManagementGroup: to.Ptr("/providers/Microsoft.Management/managementGroups/DefaultGroup"), - // RequireAuthorizationForGroupCreation: to.Ptr(true), - // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), - // }, + // res = armmanagementgroups.HierarchySettingsClientDeleteResponse{ // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/PutHierarchySettings.json -func ExampleHierarchySettingsClient_CreateOrUpdate() { +// Generated from example definition: 2023-04-01/GetHierarchySettings.json +func ExampleHierarchySettingsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -92,32 +82,29 @@ func ExampleHierarchySettingsClient_CreateOrUpdate() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewHierarchySettingsClient().CreateOrUpdate(ctx, "root", armmanagementgroups.CreateOrUpdateSettingsRequest{ - Properties: &armmanagementgroups.CreateOrUpdateSettingsProperties{ - DefaultManagementGroup: to.Ptr("/providers/Microsoft.Management/managementGroups/DefaultGroup"), - RequireAuthorizationForGroupCreation: to.Ptr(true), - }, - }, nil) + res, err := clientFactory.NewHierarchySettingsClient().Get(ctx, "root", 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.HierarchySettings = armmanagementgroups.HierarchySettings{ - // Name: to.Ptr("root"), - // Type: to.Ptr("Microsoft.Management/managementGroups/settings"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/root/settings/default"), - // Properties: &armmanagementgroups.HierarchySettingsProperties{ - // DefaultManagementGroup: to.Ptr("/providers/Microsoft.Management/managementGroups/DefaultGroup"), - // RequireAuthorizationForGroupCreation: to.Ptr(true), - // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), + // res = armmanagementgroups.HierarchySettingsClientGetResponse{ + // HierarchySettings: &armmanagementgroups.HierarchySettings{ + // Name: to.Ptr("root"), + // Type: to.Ptr("Microsoft.Management/managementGroups/settings"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/root/settings/default"), + // Properties: &armmanagementgroups.HierarchySettingsProperties{ + // DefaultManagementGroup: to.Ptr("/providers/Microsoft.Management/managementGroups/DefaultGroup"), + // RequireAuthorizationForGroupCreation: to.Ptr(true), + // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), + // }, // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/PatchHierarchySettings.json -func ExampleHierarchySettingsClient_Update() { +// Generated from example definition: 2023-04-01/ListHierarchySettings.json +func ExampleHierarchySettingsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -127,32 +114,38 @@ func ExampleHierarchySettingsClient_Update() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewHierarchySettingsClient().Update(ctx, "root", armmanagementgroups.CreateOrUpdateSettingsRequest{ - Properties: &armmanagementgroups.CreateOrUpdateSettingsProperties{ - DefaultManagementGroup: to.Ptr("/providers/Microsoft.Management/managementGroups/DefaultGroup"), - RequireAuthorizationForGroupCreation: to.Ptr(true), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) + pager := clientFactory.NewHierarchySettingsClient().NewListPager("root", 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 = armmanagementgroups.HierarchySettingsClientListResponse{ + // HierarchySettingsList: armmanagementgroups.HierarchySettingsList{ + // Value: []*armmanagementgroups.HierarchySettingsInfo{ + // { + // Name: to.Ptr("root"), + // Type: to.Ptr("Microsoft.Management/managementGroups/settings"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/root/settings/default"), + // Properties: &armmanagementgroups.HierarchySettingsProperties{ + // DefaultManagementGroup: to.Ptr("/providers/Microsoft.Management/managementGroups/DefaultGroup"), + // RequireAuthorizationForGroupCreation: to.Ptr(true), + // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // }, + // } } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.HierarchySettings = armmanagementgroups.HierarchySettings{ - // Name: to.Ptr("root"), - // Type: to.Ptr("Microsoft.Management/managementGroups/settings"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/root/settings/default"), - // Properties: &armmanagementgroups.HierarchySettingsProperties{ - // DefaultManagementGroup: to.Ptr("/providers/Microsoft.Management/managementGroups/DefaultGroup"), - // RequireAuthorizationForGroupCreation: to.Ptr(true), - // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), - // }, - // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/DeleteHierarchySettings.json -func ExampleHierarchySettingsClient_Delete() { +// Generated from example definition: 2023-04-01/PatchHierarchySettings.json +func ExampleHierarchySettingsClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -162,8 +155,28 @@ func ExampleHierarchySettingsClient_Delete() { if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewHierarchySettingsClient().Delete(ctx, "root", nil) + res, err := clientFactory.NewHierarchySettingsClient().Update(ctx, "root", armmanagementgroups.CreateOrUpdateSettingsRequest{ + Properties: &armmanagementgroups.CreateOrUpdateSettingsProperties{ + DefaultManagementGroup: to.Ptr("/providers/Microsoft.Management/managementGroups/DefaultGroup"), + RequireAuthorizationForGroupCreation: to.Ptr(true), + }, + }, 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 = armmanagementgroups.HierarchySettingsClientUpdateResponse{ + // HierarchySettings: &armmanagementgroups.HierarchySettings{ + // Name: to.Ptr("root"), + // Type: to.Ptr("Microsoft.Management/managementGroups/settings"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/root/settings/default"), + // Properties: &armmanagementgroups.HierarchySettingsProperties{ + // DefaultManagementGroup: to.Ptr("/providers/Microsoft.Management/managementGroups/DefaultGroup"), + // RequireAuthorizationForGroupCreation: to.Ptr(true), + // TenantID: to.Ptr("20000000-0000-0000-0000-000000000000"), + // }, + // }, + // } } diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/management_live_test.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/management_live_test.go index 77c956366598..618296acd1d9 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/management_live_test.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/management_live_test.go @@ -16,20 +16,20 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups/v2" "github.com/stretchr/testify/suite" ) type ManagementTestSuite struct { suite.Suite - ctx context.Context - cred azcore.TokenCredential - options *arm.ClientOptions - groupId string - location string - resourceGroupName string - subscriptionId string + ctx context.Context + cred azcore.TokenCredential + options *arm.ClientOptions + groupId string + location string + resourceGroupName string + subscriptionId string } func (testsuite *ManagementTestSuite) SetupSuite() { @@ -64,8 +64,8 @@ func (testsuite *ManagementTestSuite) TestManagementGroups() { aPIClient, err := armmanagementgroups.NewAPIClient(testsuite.cred, testsuite.options) testsuite.Require().NoError(err) _, err = aPIClient.CheckNameAvailability(testsuite.ctx, armmanagementgroups.CheckNameAvailabilityRequest{ - Name: to.Ptr(testsuite.groupId), - Type: to.Ptr("Microsoft.Management/managementGroups"), + Name: to.Ptr(testsuite.groupId), + Type: to.Ptr("Microsoft.Management/managementGroups"), }, nil) testsuite.Require().NoError(err) @@ -85,7 +85,7 @@ func (testsuite *ManagementTestSuite) TestManagementGroups() { // From step ManagementGroups_List fmt.Println("Call operation: ManagementGroups_List") clientNewListPager := client.NewListPager(&armmanagementgroups.ClientListOptions{CacheControl: to.Ptr("no-cache"), - Skiptoken: nil, + Skiptoken: nil, }) for clientNewListPager.More() { _, err := clientNewListPager.NextPage(testsuite.ctx) @@ -96,7 +96,7 @@ func (testsuite *ManagementTestSuite) TestManagementGroups() { // From step ManagementGroups_GetDescendants fmt.Println("Call operation: ManagementGroups_GetDescendants") clientNewGetDescendantsPager := client.NewGetDescendantsPager(testsuite.groupId, &armmanagementgroups.ClientGetDescendantsOptions{Skiptoken: nil, - Top: nil, + Top: nil, }) for clientNewGetDescendantsPager.More() { _, err := clientNewGetDescendantsPager.NextPage(testsuite.ctx) @@ -107,9 +107,9 @@ func (testsuite *ManagementTestSuite) TestManagementGroups() { // From step ManagementGroups_Get fmt.Println("Call operation: ManagementGroups_Get") _, err = client.Get(testsuite.ctx, testsuite.groupId, &armmanagementgroups.ClientGetOptions{Expand: nil, - Recurse: nil, - Filter: nil, - CacheControl: to.Ptr("no-cache"), + Recurse: nil, + Filter: nil, + CacheControl: to.Ptr("no-cache"), }) testsuite.Require().NoError(err) @@ -134,14 +134,14 @@ func (testsuite *ManagementTestSuite) TestEntities() { entitiesClient, err := armmanagementgroups.NewEntitiesClient(testsuite.cred, testsuite.options) testsuite.Require().NoError(err) entitiesClientNewListPager := entitiesClient.NewListPager(&armmanagementgroups.EntitiesClientListOptions{Skiptoken: nil, - Skip: nil, - Top: nil, - Select: nil, - Search: nil, - Filter: nil, - View: nil, - GroupName: nil, - CacheControl: nil, + Skip: nil, + Top: nil, + Select: nil, + Search: nil, + Filter: nil, + View: nil, + GroupName: nil, + CacheControl: nil, }) for entitiesClientNewListPager.More() { _, err := entitiesClientNewListPager.NextPage(testsuite.ctx) diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/managementgroupsubscriptions_client.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/managementgroupsubscriptions_client.go index 28865fa26ab8..19035cb916db 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/managementgroupsubscriptions_client.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/managementgroupsubscriptions_client.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armmanagementgroups @@ -28,7 +24,7 @@ type ManagementGroupSubscriptionsClient struct { // NewManagementGroupSubscriptionsClient creates a new instance of ManagementGroupSubscriptionsClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewManagementGroupSubscriptionsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ManagementGroupSubscriptionsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -43,9 +39,9 @@ func NewManagementGroupSubscriptionsClient(credential azcore.TokenCredential, op // Create - Associates existing subscription with the management group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 -// - groupID - Management Group ID. -// - subscriptionID - Subscription ID. +// Generated from API version 2023-04-01 +// - groupID - The management group ID. +// - subscriptionID - The subscription ID. // - options - ManagementGroupSubscriptionsClientCreateOptions contains the optional parameters for the ManagementGroupSubscriptionsClient.Create // method. func (client *ManagementGroupSubscriptionsClient) Create(ctx context.Context, groupID string, subscriptionID string, options *ManagementGroupSubscriptionsClientCreateOptions) (ManagementGroupSubscriptionsClientCreateResponse, error) { @@ -86,12 +82,12 @@ func (client *ManagementGroupSubscriptionsClient) createCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.CacheControl != nil { req.Raw().Header["Cache-Control"] = []string{*options.CacheControl} } - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -107,9 +103,9 @@ func (client *ManagementGroupSubscriptionsClient) createHandleResponse(resp *htt // Delete - De-associates subscription from the management group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 -// - groupID - Management Group ID. -// - subscriptionID - Subscription ID. +// Generated from API version 2023-04-01 +// - groupID - The management group ID. +// - subscriptionID - The subscription ID. // - options - ManagementGroupSubscriptionsClientDeleteOptions contains the optional parameters for the ManagementGroupSubscriptionsClient.Delete // method. func (client *ManagementGroupSubscriptionsClient) Delete(ctx context.Context, groupID string, subscriptionID string, options *ManagementGroupSubscriptionsClientDeleteOptions) (ManagementGroupSubscriptionsClientDeleteResponse, error) { @@ -149,21 +145,20 @@ func (client *ManagementGroupSubscriptionsClient) deleteCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() if options != nil && options.CacheControl != nil { req.Raw().Header["Cache-Control"] = []string{*options.CacheControl} } - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // GetSubscription - Retrieves details about given subscription which is associated with the management group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-04-01 -// - groupID - Management Group ID. -// - subscriptionID - Subscription ID. +// Generated from API version 2023-04-01 +// - groupID - The management group ID. +// - subscriptionID - The subscription ID. // - options - ManagementGroupSubscriptionsClientGetSubscriptionOptions contains the optional parameters for the ManagementGroupSubscriptionsClient.GetSubscription // method. func (client *ManagementGroupSubscriptionsClient) GetSubscription(ctx context.Context, groupID string, subscriptionID string, options *ManagementGroupSubscriptionsClientGetSubscriptionOptions) (ManagementGroupSubscriptionsClientGetSubscriptionResponse, error) { @@ -204,12 +199,12 @@ func (client *ManagementGroupSubscriptionsClient) getSubscriptionCreateRequest(c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.CacheControl != nil { req.Raw().Header["Cache-Control"] = []string{*options.CacheControl} } - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } @@ -225,7 +220,7 @@ func (client *ManagementGroupSubscriptionsClient) getSubscriptionHandleResponse( // NewGetSubscriptionsUnderManagementGroupPager - Retrieves details about all subscriptions which are associated with the // management group. // -// Generated from API version 2021-04-01 +// Generated from API version 2023-04-01 // - groupID - Management Group ID. // - options - ManagementGroupSubscriptionsClientGetSubscriptionsUnderManagementGroupOptions contains the optional parameters // for the ManagementGroupSubscriptionsClient.NewGetSubscriptionsUnderManagementGroupPager method. @@ -264,10 +259,10 @@ func (client *ManagementGroupSubscriptionsClient) getSubscriptionsUnderManagemen return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-04-01") if options != nil && options.Skiptoken != nil { reqQP.Set("$skiptoken", *options.Skiptoken) } + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/managementgroupsubscriptions_client_example_test.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/managementgroupsubscriptions_client_example_test.go index 2d56ba63ba59..8eb63f7b1b2d 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/managementgroupsubscriptions_client_example_test.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/managementgroupsubscriptions_client_example_test.go @@ -1,24 +1,18 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armmanagementgroups_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/managementgroups/armmanagementgroups" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/AddManagementGroupSubscription.json +// Generated from example definition: 2023-04-01/AddManagementGroupSubscription.json func ExampleManagementGroupSubscriptionsClient_Create() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -29,29 +23,32 @@ func ExampleManagementGroupSubscriptionsClient_Create() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewManagementGroupSubscriptionsClient().Create(ctx, "Group", "728bcbe4-8d56-4510-86c2-4921b8beefbc", &armmanagementgroups.ManagementGroupSubscriptionsClientCreateOptions{CacheControl: to.Ptr("no-cache")}) + res, err := clientFactory.NewManagementGroupSubscriptionsClient().Create(ctx, "Group", "728bcbe4-8d56-4510-86c2-4921b8beefbc", &armmanagementgroups.ManagementGroupSubscriptionsClientCreateOptions{ + CacheControl: to.Ptr("no-cache")}) 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.SubscriptionUnderManagementGroup = armmanagementgroups.SubscriptionUnderManagementGroup{ - // Name: to.Ptr("728bcbe4-8d56-4510-86c2-4921b8beefbc"), - // Type: to.Ptr("Microsoft.Management/managementGroups/subscriptions"), - // ID: to.Ptr(" /providers/Microsoft.Management/managementGroups/Group/subscriptions/728bcbe4-8d56-4510-86c2-4921b8beefbc"), - // Properties: &armmanagementgroups.SubscriptionUnderManagementGroupProperties{ - // DisplayName: to.Ptr("Group"), - // Parent: &armmanagementgroups.DescendantParentGroupInfo{ - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/Group"), + // res = armmanagementgroups.ManagementGroupSubscriptionsClientCreateResponse{ + // SubscriptionUnderManagementGroup: &armmanagementgroups.SubscriptionUnderManagementGroup{ + // Name: to.Ptr("728bcbe4-8d56-4510-86c2-4921b8beefbc"), + // Type: to.Ptr("Microsoft.Management/managementGroups/subscriptions"), + // ID: to.Ptr(" /providers/Microsoft.Management/managementGroups/Group/subscriptions/728bcbe4-8d56-4510-86c2-4921b8beefbc"), + // Properties: &armmanagementgroups.SubscriptionUnderManagementGroupProperties{ + // DisplayName: to.Ptr("Group"), + // Parent: &armmanagementgroups.DescendantParentGroupInfo{ + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/Group"), + // }, + // State: to.Ptr("Active"), + // Tenant: to.Ptr("e751ac82-623b-4913-8d74-22637c832373"), // }, - // State: to.Ptr("Active"), - // Tenant: to.Ptr("e751ac82-623b-4913-8d74-22637c832373"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/RemoveManagementGroupSubscription.json +// Generated from example definition: 2023-04-01/RemoveManagementGroupSubscription.json func ExampleManagementGroupSubscriptionsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -62,13 +59,19 @@ func ExampleManagementGroupSubscriptionsClient_Delete() { if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewManagementGroupSubscriptionsClient().Delete(ctx, "Group", "728bcbe4-8d56-4510-86c2-4921b8beefbc", &armmanagementgroups.ManagementGroupSubscriptionsClientDeleteOptions{CacheControl: to.Ptr("no-cache")}) + res, err := clientFactory.NewManagementGroupSubscriptionsClient().Delete(ctx, "Group", "728bcbe4-8d56-4510-86c2-4921b8beefbc", &armmanagementgroups.ManagementGroupSubscriptionsClientDeleteOptions{ + CacheControl: to.Ptr("no-cache")}) 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 = armmanagementgroups.ManagementGroupSubscriptionsClientDeleteResponse{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetSubscriptionFromManagementGroup.json +// Generated from example definition: 2023-04-01/GetSubscriptionFromManagementGroup.json func ExampleManagementGroupSubscriptionsClient_GetSubscription() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -79,29 +82,32 @@ func ExampleManagementGroupSubscriptionsClient_GetSubscription() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewManagementGroupSubscriptionsClient().GetSubscription(ctx, "Group", "728bcbe4-8d56-4510-86c2-4921b8beefbc", &armmanagementgroups.ManagementGroupSubscriptionsClientGetSubscriptionOptions{CacheControl: to.Ptr("no-cache")}) + res, err := clientFactory.NewManagementGroupSubscriptionsClient().GetSubscription(ctx, "Group", "728bcbe4-8d56-4510-86c2-4921b8beefbc", &armmanagementgroups.ManagementGroupSubscriptionsClientGetSubscriptionOptions{ + CacheControl: to.Ptr("no-cache")}) 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.SubscriptionUnderManagementGroup = armmanagementgroups.SubscriptionUnderManagementGroup{ - // Name: to.Ptr("728bcbe4-8d56-4510-86c2-4921b8beefbc"), - // Type: to.Ptr("Microsoft.Management/managementGroups/subscriptions"), - // ID: to.Ptr(" /providers/Microsoft.Management/managementGroups/Group/subscriptions/728bcbe4-8d56-4510-86c2-4921b8beefbc"), - // Properties: &armmanagementgroups.SubscriptionUnderManagementGroupProperties{ - // DisplayName: to.Ptr("Group"), - // Parent: &armmanagementgroups.DescendantParentGroupInfo{ - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/Group"), + // res = armmanagementgroups.ManagementGroupSubscriptionsClientGetSubscriptionResponse{ + // SubscriptionUnderManagementGroup: &armmanagementgroups.SubscriptionUnderManagementGroup{ + // Name: to.Ptr("728bcbe4-8d56-4510-86c2-4921b8beefbc"), + // Type: to.Ptr("Microsoft.Management/managementGroups/subscriptions"), + // ID: to.Ptr(" /providers/Microsoft.Management/managementGroups/Group/subscriptions/728bcbe4-8d56-4510-86c2-4921b8beefbc"), + // Properties: &armmanagementgroups.SubscriptionUnderManagementGroupProperties{ + // DisplayName: to.Ptr("Group"), + // Parent: &armmanagementgroups.DescendantParentGroupInfo{ + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/Group"), + // }, + // State: to.Ptr("Active"), + // Tenant: to.Ptr("e751ac82-623b-4913-8d74-22637c832373"), // }, - // State: to.Ptr("Active"), - // Tenant: to.Ptr("e751ac82-623b-4913-8d74-22637c832373"), // }, // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetAllSubscriptionsFromManagementGroup.json +// Generated from example definition: 2023-04-01/GetAllSubscriptionsFromManagementGroup.json func ExampleManagementGroupSubscriptionsClient_NewGetSubscriptionsUnderManagementGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -112,7 +118,7 @@ func ExampleManagementGroupSubscriptionsClient_NewGetSubscriptionsUnderManagemen if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := clientFactory.NewManagementGroupSubscriptionsClient().NewGetSubscriptionsUnderManagementGroupPager("Group", &armmanagementgroups.ManagementGroupSubscriptionsClientGetSubscriptionsUnderManagementGroupOptions{Skiptoken: nil}) + pager := clientFactory.NewManagementGroupSubscriptionsClient().NewGetSubscriptionsUnderManagementGroupPager("Group", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -123,21 +129,24 @@ func ExampleManagementGroupSubscriptionsClient_NewGetSubscriptionsUnderManagemen _ = 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.ListSubscriptionUnderManagementGroup = armmanagementgroups.ListSubscriptionUnderManagementGroup{ - // Value: []*armmanagementgroups.SubscriptionUnderManagementGroup{ - // { - // Name: to.Ptr("728bcbe4-8d56-4510-86c2-4921b8beefbc"), - // Type: to.Ptr("Microsoft.Management/managementGroups/subscriptions"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/Group/subscriptions/728bcbe4-8d56-4510-86c2-4921b8beefbc"), - // Properties: &armmanagementgroups.SubscriptionUnderManagementGroupProperties{ - // DisplayName: to.Ptr("S5"), - // Parent: &armmanagementgroups.DescendantParentGroupInfo{ - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/Group"), + // page = armmanagementgroups.ManagementGroupSubscriptionsClientGetSubscriptionsUnderManagementGroupResponse{ + // ListSubscriptionUnderManagementGroup: armmanagementgroups.ListSubscriptionUnderManagementGroup{ + // Value: []*armmanagementgroups.SubscriptionUnderManagementGroup{ + // { + // Name: to.Ptr("728bcbe4-8d56-4510-86c2-4921b8beefbc"), + // Type: to.Ptr("Microsoft.Management/managementGroups/subscriptions"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/Group/subscriptions/728bcbe4-8d56-4510-86c2-4921b8beefbc"), + // Properties: &armmanagementgroups.SubscriptionUnderManagementGroupProperties{ + // DisplayName: to.Ptr("S5"), + // Parent: &armmanagementgroups.DescendantParentGroupInfo{ + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/Group"), + // }, + // State: to.Ptr("Active"), + // Tenant: to.Ptr("e751ac82-623b-4913-8d74-22637c832373"), // }, - // State: to.Ptr("Active"), - // Tenant: to.Ptr("e751ac82-623b-4913-8d74-22637c832373"), // }, - // }}, + // }, + // }, // } } } diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/models.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/models.go index c9377fe3913d..d1e8a41dee87 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/models.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/models.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armmanagementgroups @@ -33,45 +29,27 @@ type CheckNameAvailabilityRequest struct { // the name to check for availability Name *string - // fully qualified resource type which includes provider namespace + // FLAG; CONSTANT; fully qualified resource type which includes provider namespace + // Field has constant value "Microsoft.Management/managementGroups", any specified value is ignored. Type *string } // CheckNameAvailabilityResult - Describes the result of the request to check management group name availability. type CheckNameAvailabilityResult struct { // READ-ONLY; Required if nameAvailable == false. Localized. If reason == invalid, provide the user with the reason why the - // given name is invalid, and provide the resource naming requirements so that the user can - // select a valid name. If reason == AlreadyExists, explain that is already in use, and direct them to select a different - // name. + // given name is invalid, and provide the resource naming requirements so that the user can select a valid name. If reason + // == AlreadyExists, explain that is already in use, and direct them to select a different name. Message *string // READ-ONLY; Required. True indicates name is valid and available. False indicates the name is invalid, unavailable, or both. NameAvailable *bool // READ-ONLY; Required if nameAvailable == false. Invalid indicates the name provided does not match the resource provider's - // naming requirements (incorrect length, unsupported characters, etc.) AlreadyExists - // indicates that the name is already in use and is therefore unavailable. + // naming requirements (incorrect length, unsupported characters, etc.) AlreadyExists indicates that the name is already in + // use and is therefore unavailable. Reason *Reason } -// CreateManagementGroupChildInfo - The child information of a management group used during creation. -type CreateManagementGroupChildInfo struct { - // READ-ONLY; The list of children. - Children []*CreateManagementGroupChildInfo - - // READ-ONLY; The friendly name of the child resource. - DisplayName *string - - // READ-ONLY; The fully qualified ID for the child resource (management group or subscription). For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 - ID *string - - // READ-ONLY; The name of the child entity. - Name *string - - // READ-ONLY; The fully qualified resource type which includes provider namespace (e.g. Microsoft.Management/managementGroups) - Type *ManagementGroupChildType -} - // CreateManagementGroupDetails - The details of a management group used during creation. type CreateManagementGroupDetails struct { // (Optional) The ID of the parent management group used during creation. @@ -123,9 +101,8 @@ type CreateOrUpdateSettingsProperties struct { DefaultManagementGroup *string // Indicates whether RBAC access is required upon group creation under the root Management Group. If set to true, user will - // require Microsoft.Management/managementGroups/write action on the root - // Management Group scope in order to create new Groups directly under the root. This will prevent new users from creating - // new Management Groups, unless they are given access. + // require Microsoft.Management/managementGroups/write action on the root Management Group scope in order to create new Groups + // directly under the root. This will prevent new users from creating new Management Groups, unless they are given access. RequireAuthorizationForGroupCreation *bool } @@ -172,12 +149,12 @@ type DescendantInfoProperties struct { Parent *DescendantParentGroupInfo } -// DescendantListResult - Describes the result of the request to view descendants. +// DescendantListResult - Paged collection of DescendantInfo items type DescendantListResult struct { - // The list of descendants. + // REQUIRED; The DescendantInfo items on this page Value []*DescendantInfo - // READ-ONLY; The URL to use for getting the next set of results. + // The link to the next page of items NextLink *string } @@ -187,33 +164,6 @@ type DescendantParentGroupInfo struct { ID *string } -// EntityHierarchyItem - The management group details for the hierarchy view. -type EntityHierarchyItem struct { - // The generic properties of a management group. - Properties *EntityHierarchyItemProperties - - // READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 - ID *string - - // READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000 - Name *string - - // READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups - Type *string -} - -// EntityHierarchyItemProperties - The generic properties of a management group. -type EntityHierarchyItemProperties struct { - // The list of children. - Children []*EntityHierarchyItem - - // The friendly name of the management group. - DisplayName *string - - // The users specific permissions to this item. - Permissions *Permissions -} - // EntityInfo - The entity. type EntityInfo struct { // The generic properties of an entity. @@ -262,15 +212,12 @@ type EntityInfoProperties struct { TenantID *string } -// EntityListResult - Describes the result of the request to view entities. +// EntityListResult - Paged collection of EntityInfo items type EntityListResult struct { - // The list of entities. + // REQUIRED; The EntityInfo items on this page Value []*EntityInfo - // READ-ONLY; Total count of records that match the filter - Count *int32 - - // READ-ONLY; The URL to use for getting the next set of results. + // The link to the next page of items NextLink *string } @@ -280,36 +227,21 @@ type EntityParentGroupInfo struct { ID *string } -// ErrorDetails - The details of the error. -type ErrorDetails struct { - // One of a server-defined set of error codes. - Code *string - - // A human-readable representation of the error's details. - Details *string - - // A human-readable representation of the error. - Message *string -} - -// ErrorResponse - The error object. -type ErrorResponse struct { - // The details of the error. - Error *ErrorDetails -} - // HierarchySettings - Settings defined at the Management Group scope. type HierarchySettings struct { // The generic properties of hierarchy settings. Properties *HierarchySettingsProperties - // READ-ONLY; The fully qualified ID for the settings object. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/settings/default. + // 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 object. In this case, default. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups/settings. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -343,9 +275,8 @@ type HierarchySettingsProperties struct { DefaultManagementGroup *string // Indicates whether RBAC access is required upon group creation under the root Management Group. If set to true, user will - // require Microsoft.Management/managementGroups/write action on the root - // Management Group scope in order to create new Groups directly under the root. This will prevent new users from creating - // new Management Groups, unless they are given access. + // require Microsoft.Management/managementGroups/write action on the root Management Group scope in order to create new Groups + // directly under the root. This will prevent new users from creating new Management Groups, unless they are given access. RequireAuthorizationForGroupCreation *bool // The AAD Tenant ID associated with the hierarchy settings. For example, 00000000-0000-0000-0000-000000000000 @@ -354,10 +285,10 @@ type HierarchySettingsProperties struct { // ListSubscriptionUnderManagementGroup - The details of all subscriptions under management group. type ListSubscriptionUnderManagementGroup struct { - // The list of subscriptions. + // REQUIRED; The SubscriptionUnderManagementGroup items on this page Value []*SubscriptionUnderManagementGroup - // READ-ONLY; The URL to use for getting the next set of results. + // The link to the next page of items NextLink *string } @@ -366,13 +297,16 @@ type ManagementGroup struct { // The generic properties of a management group. Properties *ManagementGroupProperties - // READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + // 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 management group. For example, 00000000-0000-0000-0000-000000000000 + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -475,52 +409,55 @@ type ManagementGroupProperties struct { TenantID *string } -// Operation supported by the Microsoft.Management resource provider. +// Operation - REST API Operation +// +// Details of a REST API operation, returned from the Resource Provider Operations API type Operation struct { - // The object that represents the operation. - Display *OperationDisplayProperties + // Localized display information for this particular operation. + Display *OperationDisplay + + // READ-ONLY; Extensible 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 Azure + // Resource Manager/control-plane operations. + IsDataAction *bool - // READ-ONLY; Operation name: {provider}/{resource}/{operation}. + // 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 } -// OperationDisplayProperties - The object that represents the operation. -type OperationDisplayProperties struct { - // READ-ONLY; Operation description. +// OperationDisplay - Localized display information for and 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 operation that can be performed. + // 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 name of the provider. + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". Provider *string - // READ-ONLY; The resource on which the operation is performed. + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". Resource *string } -// OperationListResult - Describes the result of the request to list Microsoft.Management operations. +// 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 { - // READ-ONLY; URL to get the next set of operation list results if there are any. - NextLink *string - - // READ-ONLY; List of operations supported by the Microsoft.Management resource provider. + // REQUIRED; The Operation items on this page Value []*Operation -} -// OperationResults - The results of an asynchronous operation. -type OperationResults struct { - // The generic properties of a management group. - Properties *ManagementGroupInfoProperties - - // READ-ONLY; The fully qualified ID for the management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 - ID *string - - // READ-ONLY; The name of the management group. For example, 00000000-0000-0000-0000-000000000000 - Name *string - - // READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups - Type *string + // The link to the next page of items + NextLink *string } // ParentGroupInfo - (Optional) The ID of the parent management group. @@ -549,13 +486,16 @@ type SubscriptionUnderManagementGroup struct { // The generic properties of subscription under a management group. Properties *SubscriptionUnderManagementGroupProperties - // READ-ONLY; The fully qualified ID for the subscription. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/subscriptions/0000000-0000-0000-0000-000000000001 + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY; The stringified id of the subscription. For example, 00000000-0000-0000-0000-000000000000 + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; The type of the resource. For example, Microsoft.Management/managementGroups/subscriptions + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -574,6 +514,27 @@ type SubscriptionUnderManagementGroupProperties struct { Tenant *string } +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} + // TenantBackfillStatusResult - The tenant backfill status type TenantBackfillStatusResult struct { // READ-ONLY; The status of the Tenant Backfill diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/models_serde.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/models_serde.go index 891f210ffff6..080e49f9faaa 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/models_serde.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/models_serde.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armmanagementgroups @@ -62,7 +58,9 @@ func (a *AzureAsyncOperationResults) UnmarshalJSON(data []byte) error { func (c CheckNameAvailabilityRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "name", c.Name) - objectMap["type"] = "Microsoft.Management/managementGroups" + if c.Type != nil { + objectMap["type"] = "Microsoft.Management/managementGroups" + } return json.Marshal(objectMap) } @@ -124,49 +122,6 @@ func (c *CheckNameAvailabilityResult) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type CreateManagementGroupChildInfo. -func (c CreateManagementGroupChildInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "children", c.Children) - populate(objectMap, "displayName", c.DisplayName) - populate(objectMap, "id", c.ID) - populate(objectMap, "name", c.Name) - populate(objectMap, "type", c.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type CreateManagementGroupChildInfo. -func (c *CreateManagementGroupChildInfo) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "children": - err = unpopulate(val, "Children", &c.Children) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &c.DisplayName) - delete(rawMsg, key) - case "id": - err = unpopulate(val, "ID", &c.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &c.Name) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &c.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type CreateManagementGroupDetails. func (c CreateManagementGroupDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -505,80 +460,6 @@ func (d *DescendantParentGroupInfo) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type EntityHierarchyItem. -func (e EntityHierarchyItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", e.ID) - populate(objectMap, "name", e.Name) - populate(objectMap, "properties", e.Properties) - populate(objectMap, "type", e.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type EntityHierarchyItem. -func (e *EntityHierarchyItem) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &e.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &e.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &e.Properties) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &e.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type EntityHierarchyItemProperties. -func (e EntityHierarchyItemProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "children", e.Children) - populate(objectMap, "displayName", e.DisplayName) - populate(objectMap, "permissions", e.Permissions) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type EntityHierarchyItemProperties. -func (e *EntityHierarchyItemProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "children": - err = unpopulate(val, "Children", &e.Children) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &e.DisplayName) - delete(rawMsg, key) - case "permissions": - err = unpopulate(val, "Permissions", &e.Permissions) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type EntityInfo. func (e EntityInfo) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -684,7 +565,6 @@ func (e *EntityInfoProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EntityListResult. func (e EntityListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "count", e.Count) populate(objectMap, "nextLink", e.NextLink) populate(objectMap, "value", e.Value) return json.Marshal(objectMap) @@ -699,9 +579,6 @@ func (e *EntityListResult) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "count": - err = unpopulate(val, "Count", &e.Count) - delete(rawMsg, key) case "nextLink": err = unpopulate(val, "NextLink", &e.NextLink) delete(rawMsg, key) @@ -743,74 +620,13 @@ func (e *EntityParentGroupInfo) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ErrorDetails. -func (e ErrorDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "code", e.Code) - populate(objectMap, "details", e.Details) - populate(objectMap, "message", e.Message) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetails. -func (e *ErrorDetails) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "code": - err = unpopulate(val, "Code", &e.Code) - delete(rawMsg, key) - case "details": - err = unpopulate(val, "Details", &e.Details) - delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &e.Message) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. -func (e ErrorResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "error", e.Error) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. -func (e *ErrorResponse) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "error": - err = unpopulate(val, "Error", &e.Error) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type HierarchySettings. func (h HierarchySettings) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "id", h.ID) populate(objectMap, "name", h.Name) populate(objectMap, "properties", h.Properties) + populate(objectMap, "systemData", h.SystemData) populate(objectMap, "type", h.Type) return json.Marshal(objectMap) } @@ -833,6 +649,9 @@ func (h *HierarchySettings) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &h.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &h.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &h.Type) delete(rawMsg, key) @@ -886,7 +705,7 @@ func (h *HierarchySettingsInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type HierarchySettingsList. func (h HierarchySettingsList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", h.NextLink) + populate(objectMap, "@nextLink", h.NextLink) populate(objectMap, "value", h.Value) return json.Marshal(objectMap) } @@ -900,7 +719,7 @@ func (h *HierarchySettingsList) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "nextLink": + case "@nextLink": err = unpopulate(val, "NextLink", &h.NextLink) delete(rawMsg, key) case "value": @@ -986,6 +805,7 @@ func (m ManagementGroup) MarshalJSON() ([]byte, error) { populate(objectMap, "id", m.ID) populate(objectMap, "name", m.Name) populate(objectMap, "properties", m.Properties) + populate(objectMap, "systemData", m.SystemData) populate(objectMap, "type", m.Type) return json.Marshal(objectMap) } @@ -1008,6 +828,9 @@ func (m *ManagementGroup) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &m.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &m.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &m.Type) delete(rawMsg, key) @@ -1186,7 +1009,7 @@ func (m *ManagementGroupInfoProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ManagementGroupListResult. func (m ManagementGroupListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", m.NextLink) + populate(objectMap, "@nextLink", m.NextLink) populate(objectMap, "value", m.Value) return json.Marshal(objectMap) } @@ -1200,7 +1023,7 @@ func (m *ManagementGroupListResult) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "nextLink": + case "@nextLink": err = unpopulate(val, "NextLink", &m.NextLink) delete(rawMsg, key) case "value": @@ -1287,8 +1110,11 @@ func (m *ManagementGroupProperties) 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) } @@ -1301,12 +1127,21 @@ 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) @@ -1315,8 +1150,8 @@ func (o *Operation) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type OperationDisplayProperties. -func (o OperationDisplayProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "description", o.Description) populate(objectMap, "operation", o.Operation) @@ -1325,8 +1160,8 @@ func (o OperationDisplayProperties) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplayProperties. -func (o *OperationDisplayProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", o, err) @@ -1385,45 +1220,6 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type OperationResults. -func (o OperationResults) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "id", o.ID) - populate(objectMap, "name", o.Name) - populate(objectMap, "properties", o.Properties) - populate(objectMap, "type", o.Type) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationResults. -func (o *OperationResults) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "id": - err = unpopulate(val, "ID", &o.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &o.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &o.Properties) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &o.Type) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type ParentGroupInfo. func (p ParentGroupInfo) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1496,6 +1292,7 @@ func (s SubscriptionUnderManagementGroup) MarshalJSON() ([]byte, error) { populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) populate(objectMap, "type", s.Type) return json.Marshal(objectMap) } @@ -1518,6 +1315,9 @@ func (s *SubscriptionUnderManagementGroup) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &s.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &s.Type) delete(rawMsg, key) @@ -1568,6 +1368,53 @@ func (s *SubscriptionUnderManagementGroupProperties) UnmarshalJSON(data []byte) return nil } +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type TenantBackfillStatusResult. func (t TenantBackfillStatusResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1610,7 +1457,7 @@ func populate(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/operations_client.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/operations_client.go index 23187f2a10c7..a54e69b9e8c9 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/operations_client.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/operations_client.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armmanagementgroups @@ -25,7 +21,7 @@ type OperationsClient struct { // 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. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -37,9 +33,9 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO return client, nil } -// NewListPager - Lists all of the available Management REST API operations. +// NewListPager - List the operations for the provider // -// Generated from API version 2021-04-01 +// Generated from API version 2023-04-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]{ @@ -65,14 +61,14 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption } // listCreateRequest creates the List request. -func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/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", "2021-04-01") + reqQP.Set("api-version", "2023-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/operations_client_example_test.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/operations_client_example_test.go index 69167c290455..d5a964e846cb 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/operations_client_example_test.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/operations_client_example_test.go @@ -1,23 +1,17 @@ -//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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armmanagementgroups_test import ( "context" - "log" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups/v2" + "log" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/ListOperations.json +// Generated from example definition: 2023-04-01/ListOperations.json func ExampleOperationsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -39,17 +33,21 @@ func ExampleOperationsClient_NewListPager() { _ = v } // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationListResult = armmanagementgroups.OperationListResult{ - // Value: []*armmanagementgroups.Operation{ - // { - // Name: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), - // Display: &armmanagementgroups.OperationDisplayProperties{ - // Description: to.Ptr("aaaaaaaaaaaaaaaaaaaaaa"), - // Operation: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), - // Provider: to.Ptr("aaaaaaaaaaaaaaaaaaaaa"), - // Resource: to.Ptr("aaaaaaaaaaaaa"), + // page = armmanagementgroups.OperationsClientListResponse{ + // OperationListResult: armmanagementgroups.OperationListResult{ + // NextLink: to.Ptr("aaaaaaaaaaaaaaaaaaa"), + // Value: []*armmanagementgroups.Operation{ + // { + // Name: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Display: &armmanagementgroups.OperationDisplay{ + // Description: to.Ptr("aaaaaaaaaaaaaaaaaaaaaa"), + // Operation: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Provider: to.Ptr("aaaaaaaaaaaaaaaaaaaaa"), + // Resource: to.Ptr("aaaaaaaaaaaaa"), + // }, // }, - // }}, + // }, + // }, // } } } diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/options.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/options.go index 69c9adccccae..c8aafc8707ee 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/options.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/options.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armmanagementgroups @@ -28,7 +24,7 @@ type ClientBeginCreateOrUpdateOptions struct { // Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. CacheControl *string - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -37,15 +33,15 @@ type ClientBeginDeleteOptions struct { // Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. CacheControl *string - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // ClientGetDescendantsOptions contains the optional parameters for the Client.NewGetDescendantsPager method. type ClientGetDescendantsOptions struct { - // Page continuation token is only used if a previous operation returned a partial result. If a previous response contains - // a nextLink element, the value of the nextLink element will include a token - // parameter that specifies a starting point to use for subsequent calls. + // Page continuation token is only used if a previous operation returned a partial result. + // If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that + // specifies a starting point to use for subsequent calls. Skiptoken *string // Number of elements to return when retrieving results. Passing this in will override $skipToken. @@ -58,8 +54,8 @@ type ClientGetOptions struct { CacheControl *string // The $expand=children query string parameter allows clients to request inclusion of children in the response payload. $expand=path - // includes the path from the root group to the current group. - // $expand=ancestors includes the ancestor Ids of the current group. + // includes the path from the root group to the current group. $expand=ancestors includes the ancestor Ids of the current + // group. Expand *ManagementGroupExpandType // A filter which allows the exclusion of subscriptions from results (i.e. '$filter=children.childType ne Subscription') @@ -75,9 +71,9 @@ type ClientListOptions struct { // Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. CacheControl *string - // Page continuation token is only used if a previous operation returned a partial result. If a previous response contains - // a nextLink element, the value of the nextLink element will include a token - // parameter that specifies a starting point to use for subsequent calls. + // Page continuation token is only used if a previous operation returned a partial result. + // If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that + // specifies a starting point to use for subsequent calls. Skiptoken *string } @@ -93,40 +89,39 @@ type EntitiesClientListOptions struct { CacheControl *string // The filter parameter allows you to filter on the the name or display name fields. You can check for equality on the name - // field (e.g. name eq '{entityName}') and you can check for substrings on either - // the name or display name fields(e.g. contains(name, '{substringToSearch}'), contains(displayName, '{substringToSearch')). - // Note that the '{entityName}' and '{substringToSearch}' fields are checked case - // insensitively. + // field (e.g. name eq '{entityName}') and you can check for substrings on either the name or display name fields(e.g. contains(name, + // '{substringToSearch}'), contains(displayName, '{substringToSearch')). Note that the '{entityName}' and '{substringToSearch}' + // fields are checked case insensitively. Filter *string // A filter which allows the get entities call to focus on a particular group (i.e. "$filter=name eq 'groupName'") GroupName *string // The $search parameter is used in conjunction with the $filter parameter to return three different outputs depending on - // the parameter passed in. With $search=AllowedParents the API will return the - // entity info of all groups that the requested entity will be able to reparent to as determined by the user's permissions. - // With $search=AllowedChildren the API will return the entity info of all - // entities that can be added as children of the requested entity. With $search=ParentAndFirstLevelChildren the API will return - // the parent and first level of children that the user has either direct - // access to or indirect access via one of their descendants. With $search=ParentOnly the API will return only the group if - // the user has access to at least one of the descendants of the group. With - // $search=ChildrenOnly the API will return only the first level of children of the group entity info specified in $filter. - // The user must have direct access to the children entities or one of it's - // descendants for it to show up in the results. + // the parameter passed in. + // With $search=AllowedParents the API will return the entity info of all groups that the requested entity will be able to + // reparent to as determined by the user's permissions. + // With $search=AllowedChildren the API will return the entity info of all entities that can be added as children of the requested + // entity. + // With $search=ParentAndFirstLevelChildren the API will return the parent and first level of children that the user has either + // direct access to or indirect access via one of their descendants. + // With $search=ParentOnly the API will return only the group if the user has access to at least one of the descendants of + // the group. + // With $search=ChildrenOnly the API will return only the first level of children of the group entity info specified in $filter. + // The user must have direct access to the children entities or one of it's descendants for it to show up in the results. Search *EntitySearchType // This parameter specifies the fields to include in the response. Can include any combination of Name,DisplayName,Type,ParentDisplayNameChain,ParentChain, - // e.g. - // '$select=Name,DisplayName,Type,ParentDisplayNameChain,ParentNameChain'. When specified the $select parameter can override + // e.g. '$select=Name,DisplayName,Type,ParentDisplayNameChain,ParentNameChain'. When specified the $select parameter can override // select in $skipToken. Select *string // Number of entities to skip over when retrieving results. Passing this in will override $skipToken. Skip *int32 - // Page continuation token is only used if a previous operation returned a partial result. If a previous response contains - // a nextLink element, the value of the nextLink element will include a token - // parameter that specifies a starting point to use for subsequent calls. + // Page continuation token is only used if a previous operation returned a partial result. + // If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that + // specifies a starting point to use for subsequent calls. Skiptoken *string // Number of elements to return when retrieving results. Passing this in will override $skipToken. @@ -152,7 +147,7 @@ type HierarchySettingsClientGetOptions struct { // placeholder for future optional parameters } -// HierarchySettingsClientListOptions contains the optional parameters for the HierarchySettingsClient.List method. +// HierarchySettingsClientListOptions contains the optional parameters for the HierarchySettingsClient.NewListPager method. type HierarchySettingsClientListOptions struct { // placeholder for future optional parameters } @@ -186,9 +181,9 @@ type ManagementGroupSubscriptionsClientGetSubscriptionOptions struct { // ManagementGroupSubscriptionsClientGetSubscriptionsUnderManagementGroupOptions contains the optional parameters for the // ManagementGroupSubscriptionsClient.NewGetSubscriptionsUnderManagementGroupPager method. type ManagementGroupSubscriptionsClientGetSubscriptionsUnderManagementGroupOptions struct { - // Page continuation token is only used if a previous operation returned a partial result. If a previous response contains - // a nextLink element, the value of the nextLink element will include a token - // parameter that specifies a starting point to use for subsequent calls. + // Page continuation token is only used if a previous operation returned a partial result. + // If a previous response contains a nextLink element, the value of the nextLink element will include a token parameter that + // specifies a starting point to use for subsequent calls. Skiptoken *string } diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/response_types.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/responses.go similarity index 91% rename from sdk/resourcemanager/managementgroups/armmanagementgroups/response_types.go rename to sdk/resourcemanager/managementgroups/armmanagementgroups/responses.go index 0f39d4b6bd88..76048daff142 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/response_types.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/responses.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armmanagementgroups @@ -40,7 +36,7 @@ type ClientDeleteResponse struct { // ClientGetDescendantsResponse contains the response from method Client.NewGetDescendantsPager. type ClientGetDescendantsResponse struct { - // Describes the result of the request to view descendants. + // Paged collection of DescendantInfo items DescendantListResult } @@ -64,7 +60,7 @@ type ClientUpdateResponse struct { // EntitiesClientListResponse contains the response from method EntitiesClient.NewListPager. type EntitiesClientListResponse struct { - // Describes the result of the request to view entities. + // Paged collection of EntityInfo items EntityListResult } @@ -85,7 +81,7 @@ type HierarchySettingsClientGetResponse struct { HierarchySettings } -// HierarchySettingsClientListResponse contains the response from method HierarchySettingsClient.List. +// HierarchySettingsClientListResponse contains the response from method HierarchySettingsClient.NewListPager. type HierarchySettingsClientListResponse struct { // Lists all hierarchy settings. HierarchySettingsList @@ -122,6 +118,6 @@ type ManagementGroupSubscriptionsClientGetSubscriptionsUnderManagementGroupRespo // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { - // Describes the result of the request to list Microsoft.Management operations. + // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. OperationListResult } diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/testdata/_metadata.json b/sdk/resourcemanager/managementgroups/armmanagementgroups/testdata/_metadata.json new file mode 100644 index 000000000000..bfd1633c5fac --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/testdata/_metadata.json @@ -0,0 +1,4 @@ +{ + "apiVersion": "2023-04-01", + "emitterVersion": "0.8.5" +} \ No newline at end of file diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/time_rfc3339.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/time_rfc3339.go index 34e99137825f..a9ab4322682d 100644 --- a/sdk/resourcemanager/managementgroups/armmanagementgroups/time_rfc3339.go +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/time_rfc3339.go @@ -1,10 +1,6 @@ -//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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armmanagementgroups @@ -19,12 +15,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +40,36 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +80,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +97,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/tsp-location.yaml b/sdk/resourcemanager/managementgroups/armmanagementgroups/tsp-location.yaml new file mode 100644 index 000000000000..f0bbd4b0d7ed --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/managementgroups/ManagementGroups.Management +commit: cb874a8952d6d5db8ffc0d9e60cdeb5a165c23a7 +repo: i-specs +additionalDirectories: diff --git a/sdk/resourcemanager/managementgroups/armmanagementgroups/version.go b/sdk/resourcemanager/managementgroups/armmanagementgroups/version.go new file mode 100644 index 000000000000..8dfa18dbca2a --- /dev/null +++ b/sdk/resourcemanager/managementgroups/armmanagementgroups/version.go @@ -0,0 +1,10 @@ +// 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) Go Code Generator. + +package armmanagementgroups + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups" + moduleVersion = "v2.0.0" +)