diff --git a/sdk/resourcemanager/maintenance/armmaintenance/CHANGELOG.md b/sdk/resourcemanager/maintenance/armmaintenance/CHANGELOG.md index 65cbd89b8964..9d7f5d48d1aa 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/CHANGELOG.md +++ b/sdk/resourcemanager/maintenance/armmaintenance/CHANGELOG.md @@ -1,5 +1,36 @@ # Release History +## 1.4.0-beta.2 (2025-05-08) +### Breaking Changes + +- Type of `Operation.Display` has been changed from `*OperationInfo` to `*OperationDisplay` +- Type of `Operation.Origin` has been changed from `*string` to `*Origin` +- Function `*ConfigurationAssignmentsClient.NewListPager` has been removed +- Operation `*UpdatesClient.NewListPager` does not support pagination anymore, use `*UpdatesClient.List` instead. +- Operation `*UpdatesClient.NewListParentPager` does not support pagination anymore, use `*UpdatesClient.ListParent` instead. +- Struct `OperationInfo` has been removed +- Struct `OperationsListResult` has been removed +- Field `Properties` of struct `Operation` has been removed +- Field `OperationsListResult` of struct `OperationsClientListResponse` has been removed + +### Features Added + +- New enum type `ActionType` with values `ActionTypeInternal` +- New enum type `Origin` with values `OriginSystem`, `OriginUser`, `OriginUserSystem` +- New struct `ErrorAdditionalInfo` +- New struct `ErrorDetail` +- New struct `ErrorResponse` +- New struct `OperationDisplay` +- New struct `OperationListResult` +- New struct `ProxyResource` +- New struct `TrackedResource` +- New field `NextLink` in struct `ListApplyUpdate` +- New field `NextLink` in struct `ListConfigurationAssignmentsResult` +- New field `NextLink` in struct `ListMaintenanceConfigurationsResult` +- New field `ActionType` in struct `Operation` +- New anonymous field `OperationListResult` in struct `OperationsClientListResponse` + + ## 1.4.0-beta.1 (2024-05-24) ### Features Added diff --git a/sdk/resourcemanager/maintenance/armmaintenance/applyupdateforresourcegroup_client.go b/sdk/resourcemanager/maintenance/armmaintenance/applyupdateforresourcegroup_client.go index 0244a5cfefb1..34c24e07877b 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/applyupdateforresourcegroup_client.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/applyupdateforresourcegroup_client.go @@ -1,6 +1,3 @@ -//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. @@ -46,27 +43,26 @@ func NewApplyUpdateForResourceGroupClient(subscriptionID string, credential azco // NewListPager - Get Configuration records within a subscription and resource group // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource Group Name +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ApplyUpdateForResourceGroupClientListOptions contains the optional parameters for the ApplyUpdateForResourceGroupClient.NewListPager // method. func (client *ApplyUpdateForResourceGroupClient) NewListPager(resourceGroupName string, options *ApplyUpdateForResourceGroupClientListOptions) *runtime.Pager[ApplyUpdateForResourceGroupClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ApplyUpdateForResourceGroupClientListResponse]{ More: func(page ApplyUpdateForResourceGroupClientListResponse) bool { - return false + return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ApplyUpdateForResourceGroupClientListResponse) (ApplyUpdateForResourceGroupClientListResponse, error) { ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ApplyUpdateForResourceGroupClient.NewListPager") - req, err := client.listCreateRequest(ctx, resourceGroupName, options) - if err != nil { - return ApplyUpdateForResourceGroupClientListResponse{}, err + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, options) + }, nil) if err != nil { return ApplyUpdateForResourceGroupClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ApplyUpdateForResourceGroupClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, Tracer: client.internal.Tracer(), @@ -74,7 +70,7 @@ func (client *ApplyUpdateForResourceGroupClient) NewListPager(resourceGroupName } // listCreateRequest creates the List request. -func (client *ApplyUpdateForResourceGroupClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *ApplyUpdateForResourceGroupClientListOptions) (*policy.Request, error) { +func (client *ApplyUpdateForResourceGroupClient) listCreateRequest(ctx context.Context, resourceGroupName string, _ *ApplyUpdateForResourceGroupClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/applyUpdates" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") diff --git a/sdk/resourcemanager/maintenance/armmaintenance/applyupdateforresourcegroup_client_example_test.go b/sdk/resourcemanager/maintenance/armmaintenance/applyupdateforresourcegroup_client_example_test.go deleted file mode 100644 index 938c38b24809..000000000000 --- a/sdk/resourcemanager/maintenance/armmaintenance/applyupdateforresourcegroup_client_example_test.go +++ /dev/null @@ -1,55 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armmaintenance_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdatesResourceGroup_List.json -func ExampleApplyUpdateForResourceGroupClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewApplyUpdateForResourceGroupClient().NewListPager("examplerg", 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.ListApplyUpdate = armmaintenance.ListApplyUpdate{ - // Value: []*armmaintenance.ApplyUpdate{ - // { - // Name: to.Ptr("e9b9685d-78e4-44c4-a81c-64a14f9b87b6"), - // Type: to.Ptr("Microsoft.Maintenance/applyUpdates"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/providers/Microsoft.Maintenance/applyUpdates/e9b9685d-78e4-44c4-a81c-64a14f9b87b6"), - // Properties: &armmaintenance.ApplyUpdateProperties{ - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1"), - // Status: to.Ptr(armmaintenance.UpdateStatusCompleted), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/maintenance/armmaintenance/applyupdates_client.go b/sdk/resourcemanager/maintenance/armmaintenance/applyupdates_client.go index dcecf9a55276..467ed57635be 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/applyupdates_client.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/applyupdates_client.go @@ -1,6 +1,3 @@ -//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. @@ -47,7 +44,7 @@ func NewApplyUpdatesClient(subscriptionID string, credential azcore.TokenCredent // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource group name +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - providerName - Resource provider name // - resourceType - Resource type // - resourceName - Resource identifier @@ -67,7 +64,7 @@ func (client *ApplyUpdatesClient) CreateOrUpdate(ctx context.Context, resourceGr if err != nil { return ApplyUpdatesClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) return ApplyUpdatesClientCreateOrUpdateResponse{}, err } @@ -76,7 +73,7 @@ func (client *ApplyUpdatesClient) CreateOrUpdate(ctx context.Context, resourceGr } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ApplyUpdatesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, options *ApplyUpdatesClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ApplyUpdatesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, _ *ApplyUpdatesClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -122,21 +119,18 @@ func (client *ApplyUpdatesClient) createOrUpdateHandleResponse(resp *http.Respon // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource group name -// - providerName - Resource provider name -// - resourceType - Resource type -// - resourceName - Resource identifier -// - applyUpdateName - ApplyUpdate name -// - applyUpdate - The ApplyUpdate +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - applyUpdateName - The name of the ApplyUpdate +// - resource - The ApplyUpdate // - options - ApplyUpdatesClientCreateOrUpdateOrCancelOptions contains the optional parameters for the ApplyUpdatesClient.CreateOrUpdateOrCancel // method. -func (client *ApplyUpdatesClient) CreateOrUpdateOrCancel(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, applyUpdateName string, applyUpdate ApplyUpdate, options *ApplyUpdatesClientCreateOrUpdateOrCancelOptions) (ApplyUpdatesClientCreateOrUpdateOrCancelResponse, error) { +func (client *ApplyUpdatesClient) CreateOrUpdateOrCancel(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, applyUpdateName string, resource ApplyUpdate, options *ApplyUpdatesClientCreateOrUpdateOrCancelOptions) (ApplyUpdatesClientCreateOrUpdateOrCancelResponse, error) { var err error const operationName = "ApplyUpdatesClient.CreateOrUpdateOrCancel" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateOrCancelCreateRequest(ctx, resourceGroupName, providerName, resourceType, resourceName, applyUpdateName, applyUpdate, options) + req, err := client.createOrUpdateOrCancelCreateRequest(ctx, resourceGroupName, providerName, resourceType, resourceName, applyUpdateName, resource, options) if err != nil { return ApplyUpdatesClientCreateOrUpdateOrCancelResponse{}, err } @@ -153,8 +147,8 @@ func (client *ApplyUpdatesClient) CreateOrUpdateOrCancel(ctx context.Context, re } // createOrUpdateOrCancelCreateRequest creates the CreateOrUpdateOrCancel request. -func (client *ApplyUpdatesClient) createOrUpdateOrCancelCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, applyUpdateName string, applyUpdate ApplyUpdate, options *ApplyUpdatesClientCreateOrUpdateOrCancelOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}" +func (client *ApplyUpdatesClient) createOrUpdateOrCancelCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, applyUpdateName string, resource ApplyUpdate, _ *ApplyUpdatesClientCreateOrUpdateOrCancelOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -187,7 +181,7 @@ func (client *ApplyUpdatesClient) createOrUpdateOrCancelCreateRequest(ctx contex reqQP.Set("api-version", "2023-10-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, applyUpdate); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil @@ -206,7 +200,7 @@ func (client *ApplyUpdatesClient) createOrUpdateOrCancelHandleResponse(resp *htt // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource group name +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - providerName - Resource provider name // - resourceParentType - Resource parent type // - resourceParentName - Resource parent identifier @@ -228,7 +222,7 @@ func (client *ApplyUpdatesClient) CreateOrUpdateParent(ctx context.Context, reso if err != nil { return ApplyUpdatesClientCreateOrUpdateParentResponse{}, err } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) return ApplyUpdatesClientCreateOrUpdateParentResponse{}, err } @@ -237,7 +231,7 @@ func (client *ApplyUpdatesClient) CreateOrUpdateParent(ctx context.Context, reso } // createOrUpdateParentCreateRequest creates the CreateOrUpdateParent request. -func (client *ApplyUpdatesClient) createOrUpdateParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, options *ApplyUpdatesClientCreateOrUpdateParentOptions) (*policy.Request, error) { +func (client *ApplyUpdatesClient) createOrUpdateParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, _ *ApplyUpdatesClientCreateOrUpdateParentOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -291,11 +285,8 @@ func (client *ApplyUpdatesClient) createOrUpdateParentHandleResponse(resp *http. // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource group name -// - providerName - Resource provider name -// - resourceType - Resource type -// - resourceName - Resource identifier -// - applyUpdateName - applyUpdate Id +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - applyUpdateName - The name of the ApplyUpdate // - options - ApplyUpdatesClientGetOptions contains the optional parameters for the ApplyUpdatesClient.Get method. func (client *ApplyUpdatesClient) Get(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, applyUpdateName string, options *ApplyUpdatesClientGetOptions) (ApplyUpdatesClientGetResponse, error) { var err error @@ -320,8 +311,8 @@ func (client *ApplyUpdatesClient) Get(ctx context.Context, resourceGroupName str } // getCreateRequest creates the Get request. -func (client *ApplyUpdatesClient) getCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, applyUpdateName string, options *ApplyUpdatesClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}" +func (client *ApplyUpdatesClient) getCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, applyUpdateName string, _ *ApplyUpdatesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -370,13 +361,8 @@ func (client *ApplyUpdatesClient) getHandleResponse(resp *http.Response) (ApplyU // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource group name -// - providerName - Resource provider name -// - resourceParentType - Resource parent type -// - resourceParentName - Resource parent identifier -// - resourceType - Resource type -// - resourceName - Resource identifier -// - applyUpdateName - applyUpdate Id +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - applyUpdateName - The name of the ApplyUpdate // - options - ApplyUpdatesClientGetParentOptions contains the optional parameters for the ApplyUpdatesClient.GetParent method. func (client *ApplyUpdatesClient) GetParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, applyUpdateName string, options *ApplyUpdatesClientGetParentOptions) (ApplyUpdatesClientGetParentResponse, error) { var err error @@ -401,8 +387,8 @@ func (client *ApplyUpdatesClient) GetParent(ctx context.Context, resourceGroupNa } // getParentCreateRequest creates the GetParent request. -func (client *ApplyUpdatesClient) getParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, applyUpdateName string, options *ApplyUpdatesClientGetParentOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}" +func (client *ApplyUpdatesClient) getParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, applyUpdateName string, _ *ApplyUpdatesClientGetParentOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -462,21 +448,20 @@ func (client *ApplyUpdatesClient) getParentHandleResponse(resp *http.Response) ( func (client *ApplyUpdatesClient) NewListPager(options *ApplyUpdatesClientListOptions) *runtime.Pager[ApplyUpdatesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ApplyUpdatesClientListResponse]{ More: func(page ApplyUpdatesClientListResponse) bool { - return false + return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ApplyUpdatesClientListResponse) (ApplyUpdatesClientListResponse, error) { ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ApplyUpdatesClient.NewListPager") - req, err := client.listCreateRequest(ctx, options) - if err != nil { - return ApplyUpdatesClientListResponse{}, err + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) if err != nil { return ApplyUpdatesClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ApplyUpdatesClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, Tracer: client.internal.Tracer(), @@ -484,7 +469,7 @@ func (client *ApplyUpdatesClient) NewListPager(options *ApplyUpdatesClientListOp } // listCreateRequest creates the List request. -func (client *ApplyUpdatesClient) listCreateRequest(ctx context.Context, options *ApplyUpdatesClientListOptions) (*policy.Request, error) { +func (client *ApplyUpdatesClient) listCreateRequest(ctx context.Context, _ *ApplyUpdatesClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/applyUpdates" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") diff --git a/sdk/resourcemanager/maintenance/armmaintenance/applyupdates_client_example_test.go b/sdk/resourcemanager/maintenance/armmaintenance/applyupdates_client_example_test.go deleted file mode 100644 index 78b49575409c..000000000000 --- a/sdk/resourcemanager/maintenance/armmaintenance/applyupdates_client_example_test.go +++ /dev/null @@ -1,234 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armmaintenance_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/maintenance/armmaintenance" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_GetParent.json -func ExampleApplyUpdatesClient_GetParent() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewApplyUpdatesClient().GetParent(ctx, "examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", "virtualMachines", "smdvm1", "e9b9685d-78e4-44c4-a81c-64a14f9b87b6", 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.ApplyUpdate = armmaintenance.ApplyUpdate{ - // Name: to.Ptr("e9b9685d-78e4-44c4-a81c-64a14f9b87b6"), - // Type: to.Ptr("Microsoft.Maintenance/applyUpdates"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/virtualMachines/smdvm1/providers/Microsoft.Maintenance/applyUpdates/e9b9685d-78e4-44c4-a81c-64a14f9b87b6"), - // Properties: &armmaintenance.ApplyUpdateProperties{ - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/virtualMachines/smdvm1"), - // Status: to.Ptr(armmaintenance.UpdateStatusCompleted), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_Get.json -func ExampleApplyUpdatesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewApplyUpdatesClient().Get(ctx, "examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", "e9b9685d-78e4-44c4-a81c-64a14f9b87b6", 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.ApplyUpdate = armmaintenance.ApplyUpdate{ - // Name: to.Ptr("e9b9685d-78e4-44c4-a81c-64a14f9b87b6"), - // Type: to.Ptr("Microsoft.Maintenance/applyUpdates"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/providers/Microsoft.Maintenance/applyUpdates/e9b9685d-78e4-44c4-a81c-64a14f9b87b6"), - // Properties: &armmaintenance.ApplyUpdateProperties{ - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1"), - // Status: to.Ptr(armmaintenance.UpdateStatusCompleted), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_CreateOrUpdateOnly_NoCancellation.json -func ExampleApplyUpdatesClient_CreateOrUpdateOrCancel_applyUpdatesCreateOrUpdateOnlyNoCancellation() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewApplyUpdatesClient().CreateOrUpdateOrCancel(ctx, "examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", "20230901121200", armmaintenance.ApplyUpdate{}, 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.ApplyUpdate = armmaintenance.ApplyUpdate{ - // Name: to.Ptr("e9b9685d-78e4-44c4-a81c-64a14f9b87b6"), - // Type: to.Ptr("Microsoft.Maintenance/applyUpdates"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/providers/Microsoft.Maintenance/applyUpdates/e9b9685d-78e4-44c4-a81c-64a14f9b87b6"), - // Properties: &armmaintenance.ApplyUpdateProperties{ - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1"), - // Status: to.Ptr(armmaintenance.UpdateStatusPending), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_CreateOrUpdate_CancelMaintenance.json -func ExampleApplyUpdatesClient_CreateOrUpdateOrCancel_applyUpdatesCreateOrUpdateOrCancel() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewApplyUpdatesClient().CreateOrUpdateOrCancel(ctx, "examplerg", "Microsoft.Maintenance", "maintenanceConfigurations", "maintenanceConfig1", "20230901121200", armmaintenance.ApplyUpdate{ - Properties: &armmaintenance.ApplyUpdateProperties{ - Status: to.Ptr(armmaintenance.UpdateStatusCancel), - }, - }, 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.ApplyUpdate = armmaintenance.ApplyUpdate{ - // Name: to.Ptr("maintenanceConfig1"), - // Type: to.Ptr("Microsoft.Maintenance/applyUpdates"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/microsoft.maintenance/maintenanceconfigurations/maintenanceconfig1/providers/microsoft.maintenance/applyupdates/20230901121200"), - // Properties: &armmaintenance.ApplyUpdateProperties{ - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/microsoft.maintenance/maintenanceconfigurations/maintenanceconfig1"), - // Status: to.Ptr(armmaintenance.UpdateStatusCancelled), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_CreateOrUpdateParent.json -func ExampleApplyUpdatesClient_CreateOrUpdateParent() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewApplyUpdatesClient().CreateOrUpdateParent(ctx, "examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", "virtualMachines", "smdvm1", 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.ApplyUpdate = armmaintenance.ApplyUpdate{ - // Name: to.Ptr("e9b9685d-78e4-44c4-a81c-64a14f9b87b6"), - // Type: to.Ptr("Microsoft.Maintenance/applyUpdates"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/virtualMachines/smdvm1/providers/Microsoft.Maintenance/applyUpdates/e9b9685d-78e4-44c4-a81c-64a14f9b87b6"), - // Properties: &armmaintenance.ApplyUpdateProperties{ - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/virtualMachines/smdvm1"), - // Status: to.Ptr(armmaintenance.UpdateStatusPending), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_CreateOrUpdate.json -func ExampleApplyUpdatesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewApplyUpdatesClient().CreateOrUpdate(ctx, "examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", 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.ApplyUpdate = armmaintenance.ApplyUpdate{ - // Name: to.Ptr("e9b9685d-78e4-44c4-a81c-64a14f9b87b6"), - // Type: to.Ptr("Microsoft.Maintenance/applyUpdates"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/providers/Microsoft.Maintenance/applyUpdates/e9b9685d-78e4-44c4-a81c-64a14f9b87b6"), - // Properties: &armmaintenance.ApplyUpdateProperties{ - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1"), - // Status: to.Ptr(armmaintenance.UpdateStatusPending), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_List.json -func ExampleApplyUpdatesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewApplyUpdatesClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ListApplyUpdate = armmaintenance.ListApplyUpdate{ - // Value: []*armmaintenance.ApplyUpdate{ - // { - // Name: to.Ptr("e9b9685d-78e4-44c4-a81c-64a14f9b87b6"), - // Type: to.Ptr("Microsoft.Maintenance/applyUpdates"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/providers/Microsoft.Maintenance/applyUpdates/e9b9685d-78e4-44c4-a81c-64a14f9b87b6"), - // Properties: &armmaintenance.ApplyUpdateProperties{ - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1"), - // Status: to.Ptr(armmaintenance.UpdateStatusCompleted), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/maintenance/armmaintenance/autorest.md b/sdk/resourcemanager/maintenance/armmaintenance/autorest.md index 4dae02563813..854fb62eb155 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/autorest.md +++ b/sdk/resourcemanager/maintenance/armmaintenance/autorest.md @@ -5,9 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/maintenance/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/maintenance/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.4.0-beta.1 -tag: package-preview-2023-10 +module-version: 1.4.0-beta.2 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/maintenance/armmaintenance/client_factory.go b/sdk/resourcemanager/maintenance/armmaintenance/client_factory.go index f37860b6aba3..158525285198 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/client_factory.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/client_factory.go @@ -1,6 +1,3 @@ -//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. diff --git a/sdk/resourcemanager/maintenance/armmaintenance/configurationassignments_client.go b/sdk/resourcemanager/maintenance/armmaintenance/configurationassignments_client.go index 39460ab1ed2d..9a2a412e5360 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/configurationassignments_client.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/configurationassignments_client.go @@ -1,6 +1,3 @@ -//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. @@ -47,21 +44,18 @@ func NewConfigurationAssignmentsClient(subscriptionID string, credential azcore. // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource group name -// - providerName - Resource provider name -// - resourceType - Resource type -// - resourceName - Resource identifier -// - configurationAssignmentName - Configuration assignment name -// - configurationAssignment - The configurationAssignment +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - configurationAssignmentName - The name of the ConfigurationAssignment +// - resource - The configurationAssignment // - options - ConfigurationAssignmentsClientCreateOrUpdateOptions contains the optional parameters for the ConfigurationAssignmentsClient.CreateOrUpdate // method. -func (client *ConfigurationAssignmentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment, options *ConfigurationAssignmentsClientCreateOrUpdateOptions) (ConfigurationAssignmentsClientCreateOrUpdateResponse, error) { +func (client *ConfigurationAssignmentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, resource ConfigurationAssignment, options *ConfigurationAssignmentsClientCreateOrUpdateOptions) (ConfigurationAssignmentsClientCreateOrUpdateResponse, error) { var err error const operationName = "ConfigurationAssignmentsClient.CreateOrUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, providerName, resourceType, resourceName, configurationAssignmentName, configurationAssignment, options) + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, providerName, resourceType, resourceName, configurationAssignmentName, resource, options) if err != nil { return ConfigurationAssignmentsClientCreateOrUpdateResponse{}, err } @@ -78,8 +72,8 @@ func (client *ConfigurationAssignmentsClient) CreateOrUpdate(ctx context.Context } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ConfigurationAssignmentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment, options *ConfigurationAssignmentsClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" +func (client *ConfigurationAssignmentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, resource ConfigurationAssignment, _ *ConfigurationAssignmentsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -112,7 +106,7 @@ func (client *ConfigurationAssignmentsClient) createOrUpdateCreateRequest(ctx co reqQP.Set("api-version", "2023-10-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, configurationAssignment); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil @@ -131,23 +125,18 @@ func (client *ConfigurationAssignmentsClient) createOrUpdateHandleResponse(resp // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource group name -// - providerName - Resource provider name -// - resourceParentType - Resource parent type -// - resourceParentName - Resource parent identifier -// - resourceType - Resource type -// - resourceName - Resource identifier -// - configurationAssignmentName - Configuration assignment name -// - configurationAssignment - The configurationAssignment +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - configurationAssignmentName - The name of the ConfigurationAssignment +// - resource - The configurationAssignment // - options - ConfigurationAssignmentsClientCreateOrUpdateParentOptions contains the optional parameters for the ConfigurationAssignmentsClient.CreateOrUpdateParent // method. -func (client *ConfigurationAssignmentsClient) CreateOrUpdateParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment, options *ConfigurationAssignmentsClientCreateOrUpdateParentOptions) (ConfigurationAssignmentsClientCreateOrUpdateParentResponse, error) { +func (client *ConfigurationAssignmentsClient) CreateOrUpdateParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, resource ConfigurationAssignment, options *ConfigurationAssignmentsClientCreateOrUpdateParentOptions) (ConfigurationAssignmentsClientCreateOrUpdateParentResponse, error) { var err error const operationName = "ConfigurationAssignmentsClient.CreateOrUpdateParent" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateParentCreateRequest(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName, configurationAssignmentName, configurationAssignment, options) + req, err := client.createOrUpdateParentCreateRequest(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName, configurationAssignmentName, resource, options) if err != nil { return ConfigurationAssignmentsClientCreateOrUpdateParentResponse{}, err } @@ -164,8 +153,8 @@ func (client *ConfigurationAssignmentsClient) CreateOrUpdateParent(ctx context.C } // createOrUpdateParentCreateRequest creates the CreateOrUpdateParent request. -func (client *ConfigurationAssignmentsClient) createOrUpdateParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment, options *ConfigurationAssignmentsClientCreateOrUpdateParentOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" +func (client *ConfigurationAssignmentsClient) createOrUpdateParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, resource ConfigurationAssignment, _ *ConfigurationAssignmentsClientCreateOrUpdateParentOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -206,7 +195,7 @@ func (client *ConfigurationAssignmentsClient) createOrUpdateParentCreateRequest( reqQP.Set("api-version", "2023-10-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, configurationAssignment); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil @@ -225,11 +214,8 @@ func (client *ConfigurationAssignmentsClient) createOrUpdateParentHandleResponse // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource group name -// - providerName - Resource provider name -// - resourceType - Resource type -// - resourceName - Resource identifier -// - configurationAssignmentName - Unique configuration assignment name +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - configurationAssignmentName - The name of the ConfigurationAssignment // - options - ConfigurationAssignmentsClientDeleteOptions contains the optional parameters for the ConfigurationAssignmentsClient.Delete // method. func (client *ConfigurationAssignmentsClient) Delete(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, options *ConfigurationAssignmentsClientDeleteOptions) (ConfigurationAssignmentsClientDeleteResponse, error) { @@ -255,8 +241,8 @@ func (client *ConfigurationAssignmentsClient) Delete(ctx context.Context, resour } // deleteCreateRequest creates the Delete request. -func (client *ConfigurationAssignmentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, options *ConfigurationAssignmentsClientDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" +func (client *ConfigurationAssignmentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, _ *ConfigurationAssignmentsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -305,13 +291,8 @@ func (client *ConfigurationAssignmentsClient) deleteHandleResponse(resp *http.Re // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource group name -// - providerName - Resource provider name -// - resourceParentType - Resource parent type -// - resourceParentName - Resource parent identifier -// - resourceType - Resource type -// - resourceName - Resource identifier -// - configurationAssignmentName - Unique configuration assignment name +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - configurationAssignmentName - The name of the ConfigurationAssignment // - options - ConfigurationAssignmentsClientDeleteParentOptions contains the optional parameters for the ConfigurationAssignmentsClient.DeleteParent // method. func (client *ConfigurationAssignmentsClient) DeleteParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, options *ConfigurationAssignmentsClientDeleteParentOptions) (ConfigurationAssignmentsClientDeleteParentResponse, error) { @@ -337,8 +318,8 @@ func (client *ConfigurationAssignmentsClient) DeleteParent(ctx context.Context, } // deleteParentCreateRequest creates the DeleteParent request. -func (client *ConfigurationAssignmentsClient) deleteParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, options *ConfigurationAssignmentsClientDeleteParentOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" +func (client *ConfigurationAssignmentsClient) deleteParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, _ *ConfigurationAssignmentsClientDeleteParentOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -395,11 +376,8 @@ func (client *ConfigurationAssignmentsClient) deleteParentHandleResponse(resp *h // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource group name -// - providerName - Resource provider name -// - resourceType - Resource type -// - resourceName - Resource identifier -// - configurationAssignmentName - Configuration assignment name +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - configurationAssignmentName - The name of the ConfigurationAssignment // - options - ConfigurationAssignmentsClientGetOptions contains the optional parameters for the ConfigurationAssignmentsClient.Get // method. func (client *ConfigurationAssignmentsClient) Get(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, options *ConfigurationAssignmentsClientGetOptions) (ConfigurationAssignmentsClientGetResponse, error) { @@ -425,8 +403,8 @@ func (client *ConfigurationAssignmentsClient) Get(ctx context.Context, resourceG } // getCreateRequest creates the Get request. -func (client *ConfigurationAssignmentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, options *ConfigurationAssignmentsClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" +func (client *ConfigurationAssignmentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, _ *ConfigurationAssignmentsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -475,13 +453,8 @@ func (client *ConfigurationAssignmentsClient) getHandleResponse(resp *http.Respo // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource group name -// - providerName - Resource provider name -// - resourceParentType - Resource parent type -// - resourceParentName - Resource parent identifier -// - resourceType - Resource type -// - resourceName - Resource identifier -// - configurationAssignmentName - Configuration assignment name +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - configurationAssignmentName - The name of the ConfigurationAssignment // - options - ConfigurationAssignmentsClientGetParentOptions contains the optional parameters for the ConfigurationAssignmentsClient.GetParent // method. func (client *ConfigurationAssignmentsClient) GetParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, options *ConfigurationAssignmentsClientGetParentOptions) (ConfigurationAssignmentsClientGetParentResponse, error) { @@ -507,8 +480,8 @@ func (client *ConfigurationAssignmentsClient) GetParent(ctx context.Context, res } // getParentCreateRequest creates the GetParent request. -func (client *ConfigurationAssignmentsClient) getParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, options *ConfigurationAssignmentsClientGetParentOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" +func (client *ConfigurationAssignmentsClient) getParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, _ *ConfigurationAssignmentsClientGetParentOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -561,111 +534,29 @@ func (client *ConfigurationAssignmentsClient) getParentHandleResponse(resp *http return result, nil } -// NewListPager - List configurationAssignments for resource. -// -// Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource group name -// - providerName - Resource provider name -// - resourceType - Resource type -// - resourceName - Resource identifier -// - options - ConfigurationAssignmentsClientListOptions contains the optional parameters for the ConfigurationAssignmentsClient.NewListPager -// method. -func (client *ConfigurationAssignmentsClient) NewListPager(resourceGroupName string, providerName string, resourceType string, resourceName string, options *ConfigurationAssignmentsClientListOptions) *runtime.Pager[ConfigurationAssignmentsClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[ConfigurationAssignmentsClientListResponse]{ - More: func(page ConfigurationAssignmentsClientListResponse) bool { - return false - }, - Fetcher: func(ctx context.Context, page *ConfigurationAssignmentsClientListResponse) (ConfigurationAssignmentsClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ConfigurationAssignmentsClient.NewListPager") - req, err := client.listCreateRequest(ctx, resourceGroupName, providerName, resourceType, resourceName, options) - if err != nil { - return ConfigurationAssignmentsClientListResponse{}, err - } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ConfigurationAssignmentsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ConfigurationAssignmentsClientListResponse{}, runtime.NewResponseError(resp) - } - return client.listHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listCreateRequest creates the List request. -func (client *ConfigurationAssignmentsClient) listCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, options *ConfigurationAssignmentsClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if providerName == "" { - return nil, errors.New("parameter providerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{providerName}", url.PathEscape(providerName)) - if resourceType == "" { - return nil, errors.New("parameter resourceType cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceType}", url.PathEscape(resourceType)) - if resourceName == "" { - return nil, errors.New("parameter resourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-10-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listHandleResponse handles the List response. -func (client *ConfigurationAssignmentsClient) listHandleResponse(resp *http.Response) (ConfigurationAssignmentsClientListResponse, error) { - result := ConfigurationAssignmentsClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ListConfigurationAssignmentsResult); err != nil { - return ConfigurationAssignmentsClientListResponse{}, err - } - return result, nil -} - // NewListParentPager - List configurationAssignments for resource. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource group name -// - providerName - Resource provider name -// - resourceParentType - Resource parent type -// - resourceParentName - Resource parent identifier -// - resourceType - Resource type -// - resourceName - Resource identifier +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ConfigurationAssignmentsClientListParentOptions contains the optional parameters for the ConfigurationAssignmentsClient.NewListParentPager // method. func (client *ConfigurationAssignmentsClient) NewListParentPager(resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, options *ConfigurationAssignmentsClientListParentOptions) *runtime.Pager[ConfigurationAssignmentsClientListParentResponse] { return runtime.NewPager(runtime.PagingHandler[ConfigurationAssignmentsClientListParentResponse]{ More: func(page ConfigurationAssignmentsClientListParentResponse) bool { - return false + return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ConfigurationAssignmentsClientListParentResponse) (ConfigurationAssignmentsClientListParentResponse, error) { ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ConfigurationAssignmentsClient.NewListParentPager") - req, err := client.listParentCreateRequest(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName, options) - if err != nil { - return ConfigurationAssignmentsClientListParentResponse{}, err + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listParentCreateRequest(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName, options) + }, nil) if err != nil { return ConfigurationAssignmentsClientListParentResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ConfigurationAssignmentsClientListParentResponse{}, runtime.NewResponseError(resp) - } return client.listParentHandleResponse(resp) }, Tracer: client.internal.Tracer(), @@ -673,8 +564,8 @@ func (client *ConfigurationAssignmentsClient) NewListParentPager(resourceGroupNa } // listParentCreateRequest creates the ListParent request. -func (client *ConfigurationAssignmentsClient) listParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, options *ConfigurationAssignmentsClientListParentOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments" +func (client *ConfigurationAssignmentsClient) listParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, _ *ConfigurationAssignmentsClientListParentOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } diff --git a/sdk/resourcemanager/maintenance/armmaintenance/configurationassignments_client_example_test.go b/sdk/resourcemanager/maintenance/armmaintenance/configurationassignments_client_example_test.go deleted file mode 100644 index 13b7ddc230d8..000000000000 --- a/sdk/resourcemanager/maintenance/armmaintenance/configurationassignments_client_example_test.go +++ /dev/null @@ -1,267 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armmaintenance_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/maintenance/armmaintenance" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ConfigurationAssignments_GetParent.json -func ExampleConfigurationAssignmentsClient_GetParent() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationAssignmentsClient().GetParent(ctx, "examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", "virtualMachines", "smdvm1", "workervmPolicy", 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.ConfigurationAssignment = armmaintenance.ConfigurationAssignment{ - // Name: to.Ptr("workervmPolicy"), - // Type: to.Ptr("Microsoft.Maintenance/configurationAssignments"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/virtualMachines/smdvm1/providers/Microsoft.Maintenance/configurationAssignments/workervmPolicy"), - // Properties: &armmaintenance.ConfigurationAssignmentProperties{ - // MaintenanceConfigurationID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/policy1"), - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/virtualMachines/smdvm1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ConfigurationAssignments_CreateOrUpdateParent.json -func ExampleConfigurationAssignmentsClient_CreateOrUpdateParent() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationAssignmentsClient().CreateOrUpdateParent(ctx, "examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", "virtualMachines", "smdvm1", "workervmPolicy", armmaintenance.ConfigurationAssignment{ - Properties: &armmaintenance.ConfigurationAssignmentProperties{ - MaintenanceConfigurationID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/policy1"), - }, - }, 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.ConfigurationAssignment = armmaintenance.ConfigurationAssignment{ - // Name: to.Ptr("workervmPolicy"), - // Type: to.Ptr("Microsoft.Maintenance/configurationAssignments"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/virtualMachines/smdvm1/providers/Microsoft.Maintenance/configurationAssignments/workervmPolicy"), - // Properties: &armmaintenance.ConfigurationAssignmentProperties{ - // MaintenanceConfigurationID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/policy1"), - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/virtualMachines/smdvm1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ConfigurationAssignments_DeleteParent.json -func ExampleConfigurationAssignmentsClient_DeleteParent() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationAssignmentsClient().DeleteParent(ctx, "examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", "virtualMachines", "smdvm1", "workervmConfiguration", 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.ConfigurationAssignment = armmaintenance.ConfigurationAssignment{ - // Name: to.Ptr("workervmConfiguration"), - // Type: to.Ptr("Microsoft.Maintenance/configurationAssignments"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/providers/Microsoft.Maintenance/configurationAssignments/workervmConfiguration"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ConfigurationAssignments_Get.json -func ExampleConfigurationAssignmentsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationAssignmentsClient().Get(ctx, "examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", "workervmConfiguration", 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.ConfigurationAssignment = armmaintenance.ConfigurationAssignment{ - // Name: to.Ptr("workervmConfiguration"), - // Type: to.Ptr("Microsoft.Maintenance/configurationAssignments"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/providers/Microsoft.Maintenance/configurationAssignments/workervmConfiguration"), - // Properties: &armmaintenance.ConfigurationAssignmentProperties{ - // MaintenanceConfigurationID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ConfigurationAssignments_CreateOrUpdate.json -func ExampleConfigurationAssignmentsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationAssignmentsClient().CreateOrUpdate(ctx, "examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", "workervmConfiguration", armmaintenance.ConfigurationAssignment{ - Properties: &armmaintenance.ConfigurationAssignmentProperties{ - MaintenanceConfigurationID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - }, - }, 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.ConfigurationAssignment = armmaintenance.ConfigurationAssignment{ - // Name: to.Ptr("workervmConfiguration"), - // Type: to.Ptr("Microsoft.Maintenance/configurationAssignments"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/providers/Microsoft.Maintenance/configurationAssignments/workervmConfiguration"), - // Properties: &armmaintenance.ConfigurationAssignmentProperties{ - // MaintenanceConfigurationID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ConfigurationAssignments_Delete.json -func ExampleConfigurationAssignmentsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationAssignmentsClient().Delete(ctx, "examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", "workervmConfiguration", 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.ConfigurationAssignment = armmaintenance.ConfigurationAssignment{ - // Name: to.Ptr("workervmConfiguration"), - // Type: to.Ptr("Microsoft.Maintenance/configurationAssignments"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/providers/Microsoft.Maintenance/configurationAssignments/workervmConfiguration"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ConfigurationAssignments_ListParent.json -func ExampleConfigurationAssignmentsClient_NewListParentPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewConfigurationAssignmentsClient().NewListParentPager("examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", "virtualMachines", "smdtestvm1", 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.ListConfigurationAssignmentsResult = armmaintenance.ListConfigurationAssignmentsResult{ - // Value: []*armmaintenance.ConfigurationAssignment{ - // { - // Name: to.Ptr("workervmPolicy"), - // Type: to.Ptr("Microsoft.Maintenance/configurationAssignments"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/virtualMachines/smdtestvm1/providers/Microsoft.Maintenance/configurationAssignments/workervmPolicy"), - // Properties: &armmaintenance.ConfigurationAssignmentProperties{ - // MaintenanceConfigurationID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/policy1"), - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/virtualMachines/smdtestvm1"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ConfigurationAssignments_List.json -func ExampleConfigurationAssignmentsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewConfigurationAssignmentsClient().NewListPager("examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", 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.ListConfigurationAssignmentsResult = armmaintenance.ListConfigurationAssignmentsResult{ - // Value: []*armmaintenance.ConfigurationAssignment{ - // { - // Name: to.Ptr("workervmConfiguration"), - // Type: to.Ptr("Microsoft.Maintenance/configurationAssignments"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/providers/Microsoft.Maintenance/configurationAssignments/workervmConfiguration"), - // Properties: &armmaintenance.ConfigurationAssignmentProperties{ - // MaintenanceConfigurationID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentsforresourcegroup_client.go b/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentsforresourcegroup_client.go index 7c590fe9eccd..b629a14c2111 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentsforresourcegroup_client.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentsforresourcegroup_client.go @@ -1,6 +1,3 @@ -//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. @@ -47,18 +44,18 @@ func NewConfigurationAssignmentsForResourceGroupClient(subscriptionID string, cr // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource group name -// - configurationAssignmentName - Configuration assignment name -// - configurationAssignment - The configurationAssignment +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - configurationAssignmentName - The name of the ConfigurationAssignment +// - resource - The configurationAssignment // - options - ConfigurationAssignmentsForResourceGroupClientCreateOrUpdateOptions contains the optional parameters for the // ConfigurationAssignmentsForResourceGroupClient.CreateOrUpdate method. -func (client *ConfigurationAssignmentsForResourceGroupClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment, options *ConfigurationAssignmentsForResourceGroupClientCreateOrUpdateOptions) (ConfigurationAssignmentsForResourceGroupClientCreateOrUpdateResponse, error) { +func (client *ConfigurationAssignmentsForResourceGroupClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, configurationAssignmentName string, resource ConfigurationAssignment, options *ConfigurationAssignmentsForResourceGroupClientCreateOrUpdateOptions) (ConfigurationAssignmentsForResourceGroupClientCreateOrUpdateResponse, error) { var err error const operationName = "ConfigurationAssignmentsForResourceGroupClient.CreateOrUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, configurationAssignmentName, configurationAssignment, options) + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, configurationAssignmentName, resource, options) if err != nil { return ConfigurationAssignmentsForResourceGroupClientCreateOrUpdateResponse{}, err } @@ -75,8 +72,8 @@ func (client *ConfigurationAssignmentsForResourceGroupClient) CreateOrUpdate(ctx } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ConfigurationAssignmentsForResourceGroupClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment, options *ConfigurationAssignmentsForResourceGroupClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" +func (client *ConfigurationAssignmentsForResourceGroupClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, configurationAssignmentName string, resource ConfigurationAssignment, _ *ConfigurationAssignmentsForResourceGroupClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -97,7 +94,7 @@ func (client *ConfigurationAssignmentsForResourceGroupClient) createOrUpdateCrea reqQP.Set("api-version", "2023-10-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, configurationAssignment); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil @@ -116,8 +113,8 @@ func (client *ConfigurationAssignmentsForResourceGroupClient) createOrUpdateHand // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource group name -// - configurationAssignmentName - Unique configuration assignment name +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - configurationAssignmentName - The name of the ConfigurationAssignment // - options - ConfigurationAssignmentsForResourceGroupClientDeleteOptions contains the optional parameters for the ConfigurationAssignmentsForResourceGroupClient.Delete // method. func (client *ConfigurationAssignmentsForResourceGroupClient) Delete(ctx context.Context, resourceGroupName string, configurationAssignmentName string, options *ConfigurationAssignmentsForResourceGroupClientDeleteOptions) (ConfigurationAssignmentsForResourceGroupClientDeleteResponse, error) { @@ -143,8 +140,8 @@ func (client *ConfigurationAssignmentsForResourceGroupClient) Delete(ctx context } // deleteCreateRequest creates the Delete request. -func (client *ConfigurationAssignmentsForResourceGroupClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, configurationAssignmentName string, options *ConfigurationAssignmentsForResourceGroupClientDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" +func (client *ConfigurationAssignmentsForResourceGroupClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, configurationAssignmentName string, _ *ConfigurationAssignmentsForResourceGroupClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -181,8 +178,8 @@ func (client *ConfigurationAssignmentsForResourceGroupClient) deleteHandleRespon // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource group name -// - configurationAssignmentName - Configuration assignment name +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - configurationAssignmentName - The name of the ConfigurationAssignment // - options - ConfigurationAssignmentsForResourceGroupClientGetOptions contains the optional parameters for the ConfigurationAssignmentsForResourceGroupClient.Get // method. func (client *ConfigurationAssignmentsForResourceGroupClient) Get(ctx context.Context, resourceGroupName string, configurationAssignmentName string, options *ConfigurationAssignmentsForResourceGroupClientGetOptions) (ConfigurationAssignmentsForResourceGroupClientGetResponse, error) { @@ -208,8 +205,8 @@ func (client *ConfigurationAssignmentsForResourceGroupClient) Get(ctx context.Co } // getCreateRequest creates the Get request. -func (client *ConfigurationAssignmentsForResourceGroupClient) getCreateRequest(ctx context.Context, resourceGroupName string, configurationAssignmentName string, options *ConfigurationAssignmentsForResourceGroupClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" +func (client *ConfigurationAssignmentsForResourceGroupClient) getCreateRequest(ctx context.Context, resourceGroupName string, configurationAssignmentName string, _ *ConfigurationAssignmentsForResourceGroupClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -246,18 +243,18 @@ func (client *ConfigurationAssignmentsForResourceGroupClient) getHandleResponse( // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource group name -// - configurationAssignmentName - Configuration assignment name -// - configurationAssignment - The configurationAssignment +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - configurationAssignmentName - The name of the ConfigurationAssignment +// - properties - The configurationAssignment // - options - ConfigurationAssignmentsForResourceGroupClientUpdateOptions contains the optional parameters for the ConfigurationAssignmentsForResourceGroupClient.Update // method. -func (client *ConfigurationAssignmentsForResourceGroupClient) Update(ctx context.Context, resourceGroupName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment, options *ConfigurationAssignmentsForResourceGroupClientUpdateOptions) (ConfigurationAssignmentsForResourceGroupClientUpdateResponse, error) { +func (client *ConfigurationAssignmentsForResourceGroupClient) Update(ctx context.Context, resourceGroupName string, configurationAssignmentName string, properties ConfigurationAssignment, options *ConfigurationAssignmentsForResourceGroupClientUpdateOptions) (ConfigurationAssignmentsForResourceGroupClientUpdateResponse, error) { var err error const operationName = "ConfigurationAssignmentsForResourceGroupClient.Update" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.updateCreateRequest(ctx, resourceGroupName, configurationAssignmentName, configurationAssignment, options) + req, err := client.updateCreateRequest(ctx, resourceGroupName, configurationAssignmentName, properties, options) if err != nil { return ConfigurationAssignmentsForResourceGroupClientUpdateResponse{}, err } @@ -274,8 +271,8 @@ func (client *ConfigurationAssignmentsForResourceGroupClient) Update(ctx context } // updateCreateRequest creates the Update request. -func (client *ConfigurationAssignmentsForResourceGroupClient) updateCreateRequest(ctx context.Context, resourceGroupName string, configurationAssignmentName string, configurationAssignment ConfigurationAssignment, options *ConfigurationAssignmentsForResourceGroupClientUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" +func (client *ConfigurationAssignmentsForResourceGroupClient) updateCreateRequest(ctx context.Context, resourceGroupName string, configurationAssignmentName string, properties ConfigurationAssignment, _ *ConfigurationAssignmentsForResourceGroupClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -296,7 +293,7 @@ func (client *ConfigurationAssignmentsForResourceGroupClient) updateCreateReques reqQP.Set("api-version", "2023-10-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, configurationAssignment); err != nil { + if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } return req, nil diff --git a/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentsforresourcegroup_client_example_test.go b/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentsforresourcegroup_client_example_test.go deleted file mode 100644 index fb8c57b6c447..000000000000 --- a/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentsforresourcegroup_client_example_test.go +++ /dev/null @@ -1,247 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armmaintenance_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/maintenance/armmaintenance" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ConfigurationAssignmentsForResourceGroup_Get.json -func ExampleConfigurationAssignmentsForResourceGroupClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationAssignmentsForResourceGroupClient().Get(ctx, "examplerg", "workervmConfiguration", 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.ConfigurationAssignment = armmaintenance.ConfigurationAssignment{ - // Name: to.Ptr("workervmConfiguration"), - // Type: to.Ptr("Microsoft.Maintenance/configurationAssignments"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/configurationAssignments/workervmConfiguration"), - // Properties: &armmaintenance.ConfigurationAssignmentProperties{ - // Filter: &armmaintenance.ConfigurationAssignmentFilterProperties{ - // Locations: []*string{ - // to.Ptr("Japan East"), - // to.Ptr("UK South")}, - // ResourceTypes: []*string{ - // to.Ptr("Microsoft.HybridCompute/machines"), - // to.Ptr("Microsoft.Compute/virtualMachines")}, - // TagSettings: &armmaintenance.TagSettingsProperties{ - // FilterOperator: to.Ptr(armmaintenance.TagOperatorsAll), - // Tags: map[string][]*string{ - // "tag1": []*string{ - // to.Ptr("tag1Value1"), - // to.Ptr("tag1Value2"), - // to.Ptr("tag1Value3")}, - // "tag2": []*string{ - // to.Ptr("tag2Value1"), - // to.Ptr("tag2Value2"), - // to.Ptr("tag2Value3")}, - // }, - // }, - // }, - // MaintenanceConfigurationID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ConfigurationAssignmentsForResourceGroup_CreateOrUpdate.json -func ExampleConfigurationAssignmentsForResourceGroupClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationAssignmentsForResourceGroupClient().CreateOrUpdate(ctx, "examplerg", "workervmConfiguration", armmaintenance.ConfigurationAssignment{ - Properties: &armmaintenance.ConfigurationAssignmentProperties{ - Filter: &armmaintenance.ConfigurationAssignmentFilterProperties{ - Locations: []*string{ - to.Ptr("Japan East"), - to.Ptr("UK South")}, - ResourceTypes: []*string{ - to.Ptr("Microsoft.HybridCompute/machines"), - to.Ptr("Microsoft.Compute/virtualMachines")}, - TagSettings: &armmaintenance.TagSettingsProperties{ - FilterOperator: to.Ptr(armmaintenance.TagOperatorsAny), - Tags: map[string][]*string{ - "tag1": { - to.Ptr("tag1Value1"), - to.Ptr("tag1Value2"), - to.Ptr("tag1Value3")}, - "tag2": { - to.Ptr("tag2Value1"), - to.Ptr("tag2Value2"), - to.Ptr("tag2Value3")}, - }, - }, - }, - MaintenanceConfigurationID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - }, - }, 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.ConfigurationAssignment = armmaintenance.ConfigurationAssignment{ - // Name: to.Ptr("workervmConfiguration"), - // Type: to.Ptr("Microsoft.Maintenance/configurationAssignments"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/configurationAssignments/workervmConfiguration"), - // Properties: &armmaintenance.ConfigurationAssignmentProperties{ - // Filter: &armmaintenance.ConfigurationAssignmentFilterProperties{ - // Locations: []*string{ - // to.Ptr("Japan East"), - // to.Ptr("UK South")}, - // OSTypes: []*string{ - // to.Ptr("Windows"), - // to.Ptr("Linux")}, - // ResourceTypes: []*string{ - // to.Ptr("Microsoft.HybridCompute/machines"), - // to.Ptr("Microsoft.Compute/virtualMachines")}, - // TagSettings: &armmaintenance.TagSettingsProperties{ - // FilterOperator: to.Ptr(armmaintenance.TagOperatorsAny), - // Tags: map[string][]*string{ - // "tag1": []*string{ - // to.Ptr("tag1Value1"), - // to.Ptr("tag1Value2"), - // to.Ptr("tag1Value3")}, - // "tag2": []*string{ - // to.Ptr("tag2Value1"), - // to.Ptr("tag2Value2"), - // to.Ptr("tag2Value3")}, - // }, - // }, - // }, - // MaintenanceConfigurationID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ConfigurationAssignmentsForResourceGroup_UpdateForResource.json -func ExampleConfigurationAssignmentsForResourceGroupClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationAssignmentsForResourceGroupClient().Update(ctx, "examplerg", "workervmConfiguration", armmaintenance.ConfigurationAssignment{ - Properties: &armmaintenance.ConfigurationAssignmentProperties{ - Filter: &armmaintenance.ConfigurationAssignmentFilterProperties{ - Locations: []*string{ - to.Ptr("Japan East"), - to.Ptr("UK South")}, - ResourceTypes: []*string{ - to.Ptr("Microsoft.HybridCompute/machines"), - to.Ptr("Microsoft.Compute/virtualMachines")}, - TagSettings: &armmaintenance.TagSettingsProperties{ - FilterOperator: to.Ptr(armmaintenance.TagOperatorsAny), - Tags: map[string][]*string{ - "tag1": { - to.Ptr("tag1Value1"), - to.Ptr("tag1Value2"), - to.Ptr("tag1Value3")}, - "tag2": { - to.Ptr("tag2Value1"), - to.Ptr("tag2Value2"), - to.Ptr("tag2Value3")}, - }, - }, - }, - MaintenanceConfigurationID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - }, - }, 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.ConfigurationAssignment = armmaintenance.ConfigurationAssignment{ - // Name: to.Ptr("workervmConfiguration"), - // Type: to.Ptr("Microsoft.Maintenance/configurationAssignments"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/configurationAssignments/workervmConfiguration"), - // Properties: &armmaintenance.ConfigurationAssignmentProperties{ - // Filter: &armmaintenance.ConfigurationAssignmentFilterProperties{ - // Locations: []*string{ - // to.Ptr("Japan East"), - // to.Ptr("UK South")}, - // ResourceTypes: []*string{ - // to.Ptr("Microsoft.HybridCompute/machines"), - // to.Ptr("Microsoft.Compute/virtualMachines")}, - // TagSettings: &armmaintenance.TagSettingsProperties{ - // FilterOperator: to.Ptr(armmaintenance.TagOperatorsAny), - // Tags: map[string][]*string{ - // "tag1": []*string{ - // to.Ptr("tag1Value1"), - // to.Ptr("tag1Value2"), - // to.Ptr("tag1Value3")}, - // "tag2": []*string{ - // to.Ptr("tag2Value1"), - // to.Ptr("tag2Value2"), - // to.Ptr("tag2Value3")}, - // }, - // }, - // }, - // MaintenanceConfigurationID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ConfigurationAssignmentsForResourceGroup_Delete.json -func ExampleConfigurationAssignmentsForResourceGroupClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationAssignmentsForResourceGroupClient().Delete(ctx, "examplerg", "workervmConfiguration", 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.ConfigurationAssignment = armmaintenance.ConfigurationAssignment{ - // Name: to.Ptr("workervmConfiguration"), - // Type: to.Ptr("Microsoft.Maintenance/configurationAssignments"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/configurationAssignments/workervmConfiguration"), - // } -} diff --git a/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentsforsubscriptions_client.go b/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentsforsubscriptions_client.go index 3444c4511f93..ee5bab546c1b 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentsforsubscriptions_client.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentsforsubscriptions_client.go @@ -1,6 +1,3 @@ -//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. @@ -47,17 +44,17 @@ func NewConfigurationAssignmentsForSubscriptionsClient(subscriptionID string, cr // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - configurationAssignmentName - Configuration assignment name -// - configurationAssignment - The configurationAssignment +// - configurationAssignmentName - The name of the ConfigurationAssignment +// - resource - The configurationAssignment // - options - ConfigurationAssignmentsForSubscriptionsClientCreateOrUpdateOptions contains the optional parameters for the // ConfigurationAssignmentsForSubscriptionsClient.CreateOrUpdate method. -func (client *ConfigurationAssignmentsForSubscriptionsClient) CreateOrUpdate(ctx context.Context, configurationAssignmentName string, configurationAssignment ConfigurationAssignment, options *ConfigurationAssignmentsForSubscriptionsClientCreateOrUpdateOptions) (ConfigurationAssignmentsForSubscriptionsClientCreateOrUpdateResponse, error) { +func (client *ConfigurationAssignmentsForSubscriptionsClient) CreateOrUpdate(ctx context.Context, configurationAssignmentName string, resource ConfigurationAssignment, options *ConfigurationAssignmentsForSubscriptionsClientCreateOrUpdateOptions) (ConfigurationAssignmentsForSubscriptionsClientCreateOrUpdateResponse, error) { var err error const operationName = "ConfigurationAssignmentsForSubscriptionsClient.CreateOrUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, configurationAssignmentName, configurationAssignment, options) + req, err := client.createOrUpdateCreateRequest(ctx, configurationAssignmentName, resource, options) if err != nil { return ConfigurationAssignmentsForSubscriptionsClientCreateOrUpdateResponse{}, err } @@ -74,7 +71,7 @@ func (client *ConfigurationAssignmentsForSubscriptionsClient) CreateOrUpdate(ctx } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ConfigurationAssignmentsForSubscriptionsClient) createOrUpdateCreateRequest(ctx context.Context, configurationAssignmentName string, configurationAssignment ConfigurationAssignment, options *ConfigurationAssignmentsForSubscriptionsClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ConfigurationAssignmentsForSubscriptionsClient) createOrUpdateCreateRequest(ctx context.Context, configurationAssignmentName string, resource ConfigurationAssignment, _ *ConfigurationAssignmentsForSubscriptionsClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -92,7 +89,7 @@ func (client *ConfigurationAssignmentsForSubscriptionsClient) createOrUpdateCrea reqQP.Set("api-version", "2023-10-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, configurationAssignment); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil @@ -111,7 +108,7 @@ func (client *ConfigurationAssignmentsForSubscriptionsClient) createOrUpdateHand // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - configurationAssignmentName - Unique configuration assignment name +// - configurationAssignmentName - The name of the ConfigurationAssignment // - options - ConfigurationAssignmentsForSubscriptionsClientDeleteOptions contains the optional parameters for the ConfigurationAssignmentsForSubscriptionsClient.Delete // method. func (client *ConfigurationAssignmentsForSubscriptionsClient) Delete(ctx context.Context, configurationAssignmentName string, options *ConfigurationAssignmentsForSubscriptionsClientDeleteOptions) (ConfigurationAssignmentsForSubscriptionsClientDeleteResponse, error) { @@ -137,7 +134,7 @@ func (client *ConfigurationAssignmentsForSubscriptionsClient) Delete(ctx context } // deleteCreateRequest creates the Delete request. -func (client *ConfigurationAssignmentsForSubscriptionsClient) deleteCreateRequest(ctx context.Context, configurationAssignmentName string, options *ConfigurationAssignmentsForSubscriptionsClientDeleteOptions) (*policy.Request, error) { +func (client *ConfigurationAssignmentsForSubscriptionsClient) deleteCreateRequest(ctx context.Context, configurationAssignmentName string, _ *ConfigurationAssignmentsForSubscriptionsClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -167,11 +164,11 @@ func (client *ConfigurationAssignmentsForSubscriptionsClient) deleteHandleRespon return result, nil } -// Get - Get configuration assignment for resource.. +// Get - Get configuration assignment for resource. // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - configurationAssignmentName - Configuration assignment name +// - configurationAssignmentName - The name of the ConfigurationAssignment // - options - ConfigurationAssignmentsForSubscriptionsClientGetOptions contains the optional parameters for the ConfigurationAssignmentsForSubscriptionsClient.Get // method. func (client *ConfigurationAssignmentsForSubscriptionsClient) Get(ctx context.Context, configurationAssignmentName string, options *ConfigurationAssignmentsForSubscriptionsClientGetOptions) (ConfigurationAssignmentsForSubscriptionsClientGetResponse, error) { @@ -197,7 +194,7 @@ func (client *ConfigurationAssignmentsForSubscriptionsClient) Get(ctx context.Co } // getCreateRequest creates the Get request. -func (client *ConfigurationAssignmentsForSubscriptionsClient) getCreateRequest(ctx context.Context, configurationAssignmentName string, options *ConfigurationAssignmentsForSubscriptionsClientGetOptions) (*policy.Request, error) { +func (client *ConfigurationAssignmentsForSubscriptionsClient) getCreateRequest(ctx context.Context, configurationAssignmentName string, _ *ConfigurationAssignmentsForSubscriptionsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -231,17 +228,17 @@ func (client *ConfigurationAssignmentsForSubscriptionsClient) getHandleResponse( // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - configurationAssignmentName - Configuration assignment name -// - configurationAssignment - The configurationAssignment +// - configurationAssignmentName - The name of the ConfigurationAssignment +// - properties - The configurationAssignment // - options - ConfigurationAssignmentsForSubscriptionsClientUpdateOptions contains the optional parameters for the ConfigurationAssignmentsForSubscriptionsClient.Update // method. -func (client *ConfigurationAssignmentsForSubscriptionsClient) Update(ctx context.Context, configurationAssignmentName string, configurationAssignment ConfigurationAssignment, options *ConfigurationAssignmentsForSubscriptionsClientUpdateOptions) (ConfigurationAssignmentsForSubscriptionsClientUpdateResponse, error) { +func (client *ConfigurationAssignmentsForSubscriptionsClient) Update(ctx context.Context, configurationAssignmentName string, properties ConfigurationAssignment, options *ConfigurationAssignmentsForSubscriptionsClientUpdateOptions) (ConfigurationAssignmentsForSubscriptionsClientUpdateResponse, error) { var err error const operationName = "ConfigurationAssignmentsForSubscriptionsClient.Update" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.updateCreateRequest(ctx, configurationAssignmentName, configurationAssignment, options) + req, err := client.updateCreateRequest(ctx, configurationAssignmentName, properties, options) if err != nil { return ConfigurationAssignmentsForSubscriptionsClientUpdateResponse{}, err } @@ -258,7 +255,7 @@ func (client *ConfigurationAssignmentsForSubscriptionsClient) Update(ctx context } // updateCreateRequest creates the Update request. -func (client *ConfigurationAssignmentsForSubscriptionsClient) updateCreateRequest(ctx context.Context, configurationAssignmentName string, configurationAssignment ConfigurationAssignment, options *ConfigurationAssignmentsForSubscriptionsClientUpdateOptions) (*policy.Request, error) { +func (client *ConfigurationAssignmentsForSubscriptionsClient) updateCreateRequest(ctx context.Context, configurationAssignmentName string, properties ConfigurationAssignment, _ *ConfigurationAssignmentsForSubscriptionsClientUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -276,7 +273,7 @@ func (client *ConfigurationAssignmentsForSubscriptionsClient) updateCreateReques reqQP.Set("api-version", "2023-10-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, configurationAssignment); err != nil { + if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } return req, nil diff --git a/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentsforsubscriptions_client_example_test.go b/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentsforsubscriptions_client_example_test.go deleted file mode 100644 index 920c67af0864..000000000000 --- a/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentsforsubscriptions_client_example_test.go +++ /dev/null @@ -1,256 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armmaintenance_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/maintenance/armmaintenance" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ConfigurationAssignmentsForSubscriptions_Get.json -func ExampleConfigurationAssignmentsForSubscriptionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationAssignmentsForSubscriptionsClient().Get(ctx, "workervmConfiguration", 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.ConfigurationAssignment = armmaintenance.ConfigurationAssignment{ - // Name: to.Ptr("workervmConfiguration"), - // Type: to.Ptr("Microsoft.Maintenance/configurationAssignments"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/providers/Microsoft.Maintenance/configurationAssignments/workervmConfiguration"), - // Properties: &armmaintenance.ConfigurationAssignmentProperties{ - // Filter: &armmaintenance.ConfigurationAssignmentFilterProperties{ - // Locations: []*string{ - // to.Ptr("Japan East"), - // to.Ptr("UK South")}, - // ResourceTypes: []*string{ - // to.Ptr("Microsoft.HybridCompute/machines"), - // to.Ptr("Microsoft.Compute/virtualMachines")}, - // TagSettings: &armmaintenance.TagSettingsProperties{ - // FilterOperator: to.Ptr(armmaintenance.TagOperatorsAll), - // Tags: map[string][]*string{ - // "tag1": []*string{ - // to.Ptr("tag1Value1"), - // to.Ptr("tag1Value2"), - // to.Ptr("tag1Value3")}, - // "tag2": []*string{ - // to.Ptr("tag2Value1"), - // to.Ptr("tag2Value2"), - // to.Ptr("tag2Value3")}, - // }, - // }, - // }, - // MaintenanceConfigurationID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ConfigurationAssignmentsForSubscriptions_CreateOrUpdate.json -func ExampleConfigurationAssignmentsForSubscriptionsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationAssignmentsForSubscriptionsClient().CreateOrUpdate(ctx, "workervmConfiguration", armmaintenance.ConfigurationAssignment{ - Properties: &armmaintenance.ConfigurationAssignmentProperties{ - Filter: &armmaintenance.ConfigurationAssignmentFilterProperties{ - Locations: []*string{ - to.Ptr("Japan East"), - to.Ptr("UK South")}, - ResourceGroups: []*string{ - to.Ptr("RG1"), - to.Ptr("RG2")}, - ResourceTypes: []*string{ - to.Ptr("Microsoft.HybridCompute/machines"), - to.Ptr("Microsoft.Compute/virtualMachines")}, - TagSettings: &armmaintenance.TagSettingsProperties{ - FilterOperator: to.Ptr(armmaintenance.TagOperatorsAny), - Tags: map[string][]*string{ - "tag1": { - to.Ptr("tag1Value1"), - to.Ptr("tag1Value2"), - to.Ptr("tag1Value3")}, - "tag2": { - to.Ptr("tag2Value1"), - to.Ptr("tag2Value2"), - to.Ptr("tag2Value3")}, - }, - }, - }, - MaintenanceConfigurationID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - }, - }, 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.ConfigurationAssignment = armmaintenance.ConfigurationAssignment{ - // Name: to.Ptr("workervmConfiguration"), - // Type: to.Ptr("Microsoft.Maintenance/configurationAssignments"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/providers/Microsoft.Maintenance/configurationAssignments/workervmConfiguration"), - // Properties: &armmaintenance.ConfigurationAssignmentProperties{ - // Filter: &armmaintenance.ConfigurationAssignmentFilterProperties{ - // Locations: []*string{ - // to.Ptr("Japan East"), - // to.Ptr("UK South")}, - // ResourceGroups: []*string{ - // to.Ptr("RG1"), - // to.Ptr("RG2")}, - // ResourceTypes: []*string{ - // to.Ptr("Microsoft.HybridCompute/machines"), - // to.Ptr("Microsoft.Compute/virtualMachines")}, - // TagSettings: &armmaintenance.TagSettingsProperties{ - // FilterOperator: to.Ptr(armmaintenance.TagOperatorsAny), - // Tags: map[string][]*string{ - // "tag1": []*string{ - // to.Ptr("tag1Value1"), - // to.Ptr("tag1Value2"), - // to.Ptr("tag1Value3")}, - // "tag2": []*string{ - // to.Ptr("tag2Value1"), - // to.Ptr("tag2Value2"), - // to.Ptr("tag2Value3")}, - // }, - // }, - // }, - // MaintenanceConfigurationID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ConfigurationAssignmentsForSubscriptions_UpdateForResource.json -func ExampleConfigurationAssignmentsForSubscriptionsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationAssignmentsForSubscriptionsClient().Update(ctx, "workervmConfiguration", armmaintenance.ConfigurationAssignment{ - Properties: &armmaintenance.ConfigurationAssignmentProperties{ - Filter: &armmaintenance.ConfigurationAssignmentFilterProperties{ - Locations: []*string{ - to.Ptr("Japan East"), - to.Ptr("UK South")}, - ResourceGroups: []*string{ - to.Ptr("RG1"), - to.Ptr("RG2")}, - ResourceTypes: []*string{ - to.Ptr("Microsoft.HybridCompute/machines"), - to.Ptr("Microsoft.Compute/virtualMachines")}, - TagSettings: &armmaintenance.TagSettingsProperties{ - FilterOperator: to.Ptr(armmaintenance.TagOperatorsAny), - Tags: map[string][]*string{ - "tag1": { - to.Ptr("tag1Value1"), - to.Ptr("tag1Value2"), - to.Ptr("tag1Value3")}, - "tag2": { - to.Ptr("tag2Value1"), - to.Ptr("tag2Value2"), - to.Ptr("tag2Value3")}, - }, - }, - }, - MaintenanceConfigurationID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - }, - }, 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.ConfigurationAssignment = armmaintenance.ConfigurationAssignment{ - // Name: to.Ptr("workervmConfiguration"), - // Type: to.Ptr("Microsoft.Maintenance/configurationAssignments"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/providers/Microsoft.Maintenance/configurationAssignments/workervmConfiguration"), - // Properties: &armmaintenance.ConfigurationAssignmentProperties{ - // Filter: &armmaintenance.ConfigurationAssignmentFilterProperties{ - // Locations: []*string{ - // to.Ptr("Japan East"), - // to.Ptr("UK South")}, - // ResourceGroups: []*string{ - // to.Ptr("RG1"), - // to.Ptr("RG2")}, - // ResourceTypes: []*string{ - // to.Ptr("Microsoft.HybridCompute/machines"), - // to.Ptr("Microsoft.Compute/virtualMachines")}, - // TagSettings: &armmaintenance.TagSettingsProperties{ - // FilterOperator: to.Ptr(armmaintenance.TagOperatorsAny), - // Tags: map[string][]*string{ - // "tag1": []*string{ - // to.Ptr("tag1Value1"), - // to.Ptr("tag1Value2"), - // to.Ptr("tag1Value3")}, - // "tag2": []*string{ - // to.Ptr("tag2Value1"), - // to.Ptr("tag2Value2"), - // to.Ptr("tag2Value3")}, - // }, - // }, - // }, - // MaintenanceConfigurationID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ConfigurationAssignmentsForSubscriptions_Delete.json -func ExampleConfigurationAssignmentsForSubscriptionsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationAssignmentsForSubscriptionsClient().Delete(ctx, "workervmConfiguration", 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.ConfigurationAssignment = armmaintenance.ConfigurationAssignment{ - // Name: to.Ptr("workervmConfiguration"), - // Type: to.Ptr("Microsoft.Maintenance/configurationAssignments"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/providers/Microsoft.Maintenance/configurationAssignments/workervmConfiguration"), - // } -} diff --git a/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentswithinsubscription_client.go b/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentswithinsubscription_client.go index 478fef415a12..65d90e9cf2b5 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentswithinsubscription_client.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentswithinsubscription_client.go @@ -1,6 +1,3 @@ -//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. @@ -20,7 +17,8 @@ import ( "strings" ) -// ConfigurationAssignmentsWithinSubscriptionClient contains the methods for the ConfigurationAssignmentsWithinSubscription group. +// ConfigurationAssignmentsWithinSubscriptionClient contains the methods for the ConfigurationAssignmentsWithinSubscription +// group. // Don't use this type directly, use NewConfigurationAssignmentsWithinSubscriptionClient() instead. type ConfigurationAssignmentsWithinSubscriptionClient struct { internal *arm.Client @@ -43,7 +41,7 @@ func NewConfigurationAssignmentsWithinSubscriptionClient(subscriptionID string, return client, nil } -// NewListPager - Get configuration assignment within a subscription +// NewListPager - [UNSUPPORTED] Get configuration assignment within a subscription. This API is not implemented yet. // // Generated from API version 2023-10-01-preview // - options - ConfigurationAssignmentsWithinSubscriptionClientListOptions contains the optional parameters for the ConfigurationAssignmentsWithinSubscriptionClient.NewListPager @@ -51,21 +49,20 @@ func NewConfigurationAssignmentsWithinSubscriptionClient(subscriptionID string, func (client *ConfigurationAssignmentsWithinSubscriptionClient) NewListPager(options *ConfigurationAssignmentsWithinSubscriptionClientListOptions) *runtime.Pager[ConfigurationAssignmentsWithinSubscriptionClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ConfigurationAssignmentsWithinSubscriptionClientListResponse]{ More: func(page ConfigurationAssignmentsWithinSubscriptionClientListResponse) bool { - return false + return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ConfigurationAssignmentsWithinSubscriptionClientListResponse) (ConfigurationAssignmentsWithinSubscriptionClientListResponse, error) { ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ConfigurationAssignmentsWithinSubscriptionClient.NewListPager") - req, err := client.listCreateRequest(ctx, options) - if err != nil { - return ConfigurationAssignmentsWithinSubscriptionClientListResponse{}, err + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) if err != nil { return ConfigurationAssignmentsWithinSubscriptionClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ConfigurationAssignmentsWithinSubscriptionClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, Tracer: client.internal.Tracer(), @@ -73,7 +70,7 @@ func (client *ConfigurationAssignmentsWithinSubscriptionClient) NewListPager(opt } // listCreateRequest creates the List request. -func (client *ConfigurationAssignmentsWithinSubscriptionClient) listCreateRequest(ctx context.Context, options *ConfigurationAssignmentsWithinSubscriptionClientListOptions) (*policy.Request, error) { +func (client *ConfigurationAssignmentsWithinSubscriptionClient) listCreateRequest(ctx context.Context, _ *ConfigurationAssignmentsWithinSubscriptionClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") diff --git a/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentswithinsubscription_client_example_test.go b/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentswithinsubscription_client_example_test.go deleted file mode 100644 index ab227233dea0..000000000000 --- a/sdk/resourcemanager/maintenance/armmaintenance/configurationassignmentswithinsubscription_client_example_test.go +++ /dev/null @@ -1,55 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armmaintenance_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ConfigurationAssignmentsResultWithinSubscription_List.json -func ExampleConfigurationAssignmentsWithinSubscriptionClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewConfigurationAssignmentsWithinSubscriptionClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ListConfigurationAssignmentsResult = armmaintenance.ListConfigurationAssignmentsResult{ - // Value: []*armmaintenance.ConfigurationAssignment{ - // { - // Name: to.Ptr("workervmConfiguration"), - // Type: to.Ptr("Microsoft.Maintenance/configurationAssignments"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/providers/Microsoft.Maintenance/configurationAssignments/workervmConfiguration"), - // Properties: &armmaintenance.ConfigurationAssignmentProperties{ - // MaintenanceConfigurationID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/maintenance/armmaintenance/configurations_client.go b/sdk/resourcemanager/maintenance/armmaintenance/configurations_client.go index f34f8fdb3985..72625658f33a 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/configurations_client.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/configurations_client.go @@ -1,6 +1,3 @@ -//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. @@ -47,18 +44,18 @@ func NewConfigurationsClient(subscriptionID string, credential azcore.TokenCrede // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource Group Name -// - resourceName - Maintenance Configuration Name -// - configuration - The configuration +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - The name of the MaintenanceConfiguration +// - resource - The configuration // - options - ConfigurationsClientCreateOrUpdateOptions contains the optional parameters for the ConfigurationsClient.CreateOrUpdate // method. -func (client *ConfigurationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, configuration Configuration, options *ConfigurationsClientCreateOrUpdateOptions) (ConfigurationsClientCreateOrUpdateResponse, error) { +func (client *ConfigurationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, resource Configuration, options *ConfigurationsClientCreateOrUpdateOptions) (ConfigurationsClientCreateOrUpdateResponse, error) { var err error const operationName = "ConfigurationsClient.CreateOrUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, resourceName, configuration, options) + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, resourceName, resource, options) if err != nil { return ConfigurationsClientCreateOrUpdateResponse{}, err } @@ -75,8 +72,8 @@ func (client *ConfigurationsClient) CreateOrUpdate(ctx context.Context, resource } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ConfigurationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, configuration Configuration, options *ConfigurationsClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}" +func (client *ConfigurationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, resource Configuration, _ *ConfigurationsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -97,7 +94,7 @@ func (client *ConfigurationsClient) createOrUpdateCreateRequest(ctx context.Cont reqQP.Set("api-version", "2023-10-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, configuration); err != nil { + if err := runtime.MarshalAsJSON(req, resource); err != nil { return nil, err } return req, nil @@ -116,8 +113,8 @@ func (client *ConfigurationsClient) createOrUpdateHandleResponse(resp *http.Resp // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource Group Name -// - resourceName - Maintenance Configuration Name +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - The name of the MaintenanceConfiguration // - options - ConfigurationsClientDeleteOptions contains the optional parameters for the ConfigurationsClient.Delete method. func (client *ConfigurationsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, options *ConfigurationsClientDeleteOptions) (ConfigurationsClientDeleteResponse, error) { var err error @@ -142,8 +139,8 @@ func (client *ConfigurationsClient) Delete(ctx context.Context, resourceGroupNam } // deleteCreateRequest creates the Delete request. -func (client *ConfigurationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *ConfigurationsClientDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}" +func (client *ConfigurationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *ConfigurationsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -180,8 +177,8 @@ func (client *ConfigurationsClient) deleteHandleResponse(resp *http.Response) (C // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource Group Name -// - resourceName - Maintenance Configuration Name +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - The name of the MaintenanceConfiguration // - options - ConfigurationsClientGetOptions contains the optional parameters for the ConfigurationsClient.Get method. func (client *ConfigurationsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, options *ConfigurationsClientGetOptions) (ConfigurationsClientGetResponse, error) { var err error @@ -206,8 +203,8 @@ func (client *ConfigurationsClient) Get(ctx context.Context, resourceGroupName s } // getCreateRequest creates the Get request. -func (client *ConfigurationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *ConfigurationsClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}" +func (client *ConfigurationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, _ *ConfigurationsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -247,21 +244,20 @@ func (client *ConfigurationsClient) getHandleResponse(resp *http.Response) (Conf func (client *ConfigurationsClient) NewListPager(options *ConfigurationsClientListOptions) *runtime.Pager[ConfigurationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ConfigurationsClientListResponse]{ More: func(page ConfigurationsClientListResponse) bool { - return false + return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ConfigurationsClientListResponse) (ConfigurationsClientListResponse, error) { ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ConfigurationsClient.NewListPager") - req, err := client.listCreateRequest(ctx, options) - if err != nil { - return ConfigurationsClientListResponse{}, err + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) if err != nil { return ConfigurationsClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ConfigurationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, Tracer: client.internal.Tracer(), @@ -269,7 +265,7 @@ func (client *ConfigurationsClient) NewListPager(options *ConfigurationsClientLi } // listCreateRequest creates the List request. -func (client *ConfigurationsClient) listCreateRequest(ctx context.Context, options *ConfigurationsClientListOptions) (*policy.Request, error) { +func (client *ConfigurationsClient) listCreateRequest(ctx context.Context, _ *ConfigurationsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/maintenanceConfigurations" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -299,17 +295,17 @@ func (client *ConfigurationsClient) listHandleResponse(resp *http.Response) (Con // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource Group Name -// - resourceName - Maintenance Configuration Name -// - configuration - The configuration +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - The name of the MaintenanceConfiguration +// - properties - The configuration // - options - ConfigurationsClientUpdateOptions contains the optional parameters for the ConfigurationsClient.Update method. -func (client *ConfigurationsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, configuration Configuration, options *ConfigurationsClientUpdateOptions) (ConfigurationsClientUpdateResponse, error) { +func (client *ConfigurationsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, properties Configuration, options *ConfigurationsClientUpdateOptions) (ConfigurationsClientUpdateResponse, error) { var err error const operationName = "ConfigurationsClient.Update" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.updateCreateRequest(ctx, resourceGroupName, resourceName, configuration, options) + req, err := client.updateCreateRequest(ctx, resourceGroupName, resourceName, properties, options) if err != nil { return ConfigurationsClientUpdateResponse{}, err } @@ -326,8 +322,8 @@ func (client *ConfigurationsClient) Update(ctx context.Context, resourceGroupNam } // updateCreateRequest creates the Update request. -func (client *ConfigurationsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, configuration Configuration, options *ConfigurationsClientUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}" +func (client *ConfigurationsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, properties Configuration, _ *ConfigurationsClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -348,7 +344,7 @@ func (client *ConfigurationsClient) updateCreateRequest(ctx context.Context, res reqQP.Set("api-version", "2023-10-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, configuration); err != nil { + if err := runtime.MarshalAsJSON(req, properties); err != nil { return nil, err } return req, nil diff --git a/sdk/resourcemanager/maintenance/armmaintenance/configurations_client_example_test.go b/sdk/resourcemanager/maintenance/armmaintenance/configurations_client_example_test.go deleted file mode 100644 index 53ca67dd18c8..000000000000 --- a/sdk/resourcemanager/maintenance/armmaintenance/configurations_client_example_test.go +++ /dev/null @@ -1,330 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armmaintenance_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/maintenance/armmaintenance" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_GetForResource.json -func ExampleConfigurationsClient_Get_maintenanceConfigurationsGetForResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationsClient().Get(ctx, "examplerg", "configuration1", 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.Configuration = armmaintenance.Configuration{ - // Name: to.Ptr("configuration1"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - // Location: to.Ptr("westus2"), - // Properties: &armmaintenance.ConfigurationProperties{ - // MaintenanceScope: to.Ptr(armmaintenance.MaintenanceScopeOSImage), - // MaintenanceWindow: &armmaintenance.Window{ - // Duration: to.Ptr("05:00"), - // ExpirationDateTime: to.Ptr("9999-12-31 00:00"), - // RecurEvery: to.Ptr("5Days"), - // StartDateTime: to.Ptr("2020-04-30 08:00"), - // TimeZone: to.Ptr("Pacific Standard Time"), - // }, - // Namespace: to.Ptr("Microsoft.Maintenance"), - // Visibility: to.Ptr(armmaintenance.VisibilityCustom), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_GetForResource_GuestOSPatchLinux.json -func ExampleConfigurationsClient_Get_maintenanceConfigurationsGetForResourceGuestOsPatchLinux() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationsClient().Get(ctx, "examplerg", "configuration1", 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.Configuration = armmaintenance.Configuration{ - // Name: to.Ptr("configuration1"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - // Location: to.Ptr("westus2"), - // Properties: &armmaintenance.ConfigurationProperties{ - // InstallPatches: &armmaintenance.InputPatchConfiguration{ - // LinuxParameters: &armmaintenance.InputLinuxParameters{ - // ClassificationsToInclude: []*string{ - // to.Ptr("Critical")}, - // PackageNameMasksToExclude: []*string{ - // to.Ptr("apt"), - // to.Ptr("http")}, - // PackageNameMasksToInclude: []*string{ - // to.Ptr("binutils"), - // to.Ptr("bin")}, - // }, - // RebootSetting: to.Ptr(armmaintenance.RebootOptionsAlways), - // }, - // MaintenanceScope: to.Ptr(armmaintenance.MaintenanceScopeInGuestPatch), - // MaintenanceWindow: &armmaintenance.Window{ - // Duration: to.Ptr("05:00"), - // ExpirationDateTime: to.Ptr("9999-12-31 00:00"), - // RecurEvery: to.Ptr("5Days"), - // StartDateTime: to.Ptr("2020-04-30 08:00"), - // TimeZone: to.Ptr("Pacific Standard Time"), - // }, - // Namespace: to.Ptr("Microsoft.Maintenance"), - // Visibility: to.Ptr(armmaintenance.VisibilityCustom), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_GetForResource_GuestOSPatchWindows.json -func ExampleConfigurationsClient_Get_maintenanceConfigurationsGetForResourceGuestOsPatchWindows() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationsClient().Get(ctx, "examplerg", "configuration1", 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.Configuration = armmaintenance.Configuration{ - // Name: to.Ptr("configuration1"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - // Location: to.Ptr("westus2"), - // Properties: &armmaintenance.ConfigurationProperties{ - // InstallPatches: &armmaintenance.InputPatchConfiguration{ - // RebootSetting: to.Ptr(armmaintenance.RebootOptionsAlways), - // WindowsParameters: &armmaintenance.InputWindowsParameters{ - // ClassificationsToInclude: []*string{ - // to.Ptr("Security")}, - // ExcludeKbsRequiringReboot: to.Ptr(false), - // KbNumbersToExclude: []*string{ - // to.Ptr("KB234567")}, - // KbNumbersToInclude: []*string{ - // to.Ptr("KB123456")}, - // }, - // }, - // MaintenanceScope: to.Ptr(armmaintenance.MaintenanceScopeInGuestPatch), - // MaintenanceWindow: &armmaintenance.Window{ - // Duration: to.Ptr("05:00"), - // ExpirationDateTime: to.Ptr("9999-12-31 00:00"), - // RecurEvery: to.Ptr("5Days"), - // StartDateTime: to.Ptr("2020-04-30 08:00"), - // TimeZone: to.Ptr("Pacific Standard Time"), - // }, - // Namespace: to.Ptr("Microsoft.Maintenance"), - // Visibility: to.Ptr(armmaintenance.VisibilityCustom), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_CreateOrUpdateForResource.json -func ExampleConfigurationsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationsClient().CreateOrUpdate(ctx, "examplerg", "configuration1", armmaintenance.Configuration{ - Location: to.Ptr("westus2"), - Properties: &armmaintenance.ConfigurationProperties{ - MaintenanceScope: to.Ptr(armmaintenance.MaintenanceScopeOSImage), - MaintenanceWindow: &armmaintenance.Window{ - Duration: to.Ptr("05:00"), - ExpirationDateTime: to.Ptr("9999-12-31 00:00"), - RecurEvery: to.Ptr("Day"), - StartDateTime: to.Ptr("2020-04-30 08:00"), - TimeZone: to.Ptr("Pacific Standard Time"), - }, - Namespace: to.Ptr("Microsoft.Maintenance"), - Visibility: to.Ptr(armmaintenance.VisibilityCustom), - }, - }, 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.Configuration = armmaintenance.Configuration{ - // Name: to.Ptr("configuration1"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourceGroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - // Location: to.Ptr("westus2"), - // Properties: &armmaintenance.ConfigurationProperties{ - // MaintenanceScope: to.Ptr(armmaintenance.MaintenanceScopeOSImage), - // MaintenanceWindow: &armmaintenance.Window{ - // Duration: to.Ptr("05:00"), - // ExpirationDateTime: to.Ptr("9999-12-31 00:00"), - // RecurEvery: to.Ptr("Day"), - // StartDateTime: to.Ptr("2020-04-30 08:00"), - // TimeZone: to.Ptr("Pacific Standard Time"), - // }, - // Namespace: to.Ptr("Microsoft.Maintenance"), - // Visibility: to.Ptr(armmaintenance.VisibilityCustom), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_DeleteForResource.json -func ExampleConfigurationsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationsClient().Delete(ctx, "examplerg", "example1", 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.Configuration = armmaintenance.Configuration{ - // Name: to.Ptr("configuration1"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - // Location: to.Ptr("westus2"), - // Properties: &armmaintenance.ConfigurationProperties{ - // Namespace: to.Ptr("Microsoft.Maintenance"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_UpdateForResource.json -func ExampleConfigurationsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewConfigurationsClient().Update(ctx, "examplerg", "configuration1", armmaintenance.Configuration{ - Location: to.Ptr("westus2"), - Properties: &armmaintenance.ConfigurationProperties{ - MaintenanceScope: to.Ptr(armmaintenance.MaintenanceScopeOSImage), - MaintenanceWindow: &armmaintenance.Window{ - Duration: to.Ptr("05:00"), - ExpirationDateTime: to.Ptr("9999-12-31 00:00"), - RecurEvery: to.Ptr("Month Third Sunday"), - StartDateTime: to.Ptr("2020-04-30 08:00"), - TimeZone: to.Ptr("Pacific Standard Time"), - }, - Namespace: to.Ptr("Microsoft.Maintenance"), - Visibility: to.Ptr(armmaintenance.VisibilityCustom), - }, - }, 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.Configuration = armmaintenance.Configuration{ - // Name: to.Ptr("configuration1"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - // Location: to.Ptr("westus2"), - // Properties: &armmaintenance.ConfigurationProperties{ - // MaintenanceScope: to.Ptr(armmaintenance.MaintenanceScopeOSImage), - // MaintenanceWindow: &armmaintenance.Window{ - // Duration: to.Ptr("05:00"), - // ExpirationDateTime: to.Ptr("9999-12-31 00:00"), - // RecurEvery: to.Ptr("Month Third Sunday"), - // StartDateTime: to.Ptr("2020-04-30 08:00"), - // TimeZone: to.Ptr("Pacific Standard Time"), - // }, - // Namespace: to.Ptr("Microsoft.Maintenance"), - // Visibility: to.Ptr(armmaintenance.VisibilityCustom), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_List.json -func ExampleConfigurationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewConfigurationsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ListMaintenanceConfigurationsResult = armmaintenance.ListMaintenanceConfigurationsResult{ - // Value: []*armmaintenance.Configuration{ - // { - // Name: to.Ptr("configuration1"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - // Location: to.Ptr("westus2"), - // Properties: &armmaintenance.ConfigurationProperties{ - // MaintenanceScope: to.Ptr(armmaintenance.MaintenanceScopeOSImage), - // MaintenanceWindow: &armmaintenance.Window{ - // Duration: to.Ptr("05:00"), - // ExpirationDateTime: to.Ptr("9999-12-31 00:00"), - // RecurEvery: to.Ptr("Week Saturday,Sunday"), - // StartDateTime: to.Ptr("2020-04-30 08:00"), - // TimeZone: to.Ptr("Pacific Standard Time"), - // }, - // Namespace: to.Ptr("Microsoft.Maintenance"), - // Visibility: to.Ptr(armmaintenance.VisibilityCustom), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/maintenance/armmaintenance/configurationsforresourcegroup_client.go b/sdk/resourcemanager/maintenance/armmaintenance/configurationsforresourcegroup_client.go index 80329d123a0c..271ce575c756 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/configurationsforresourcegroup_client.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/configurationsforresourcegroup_client.go @@ -1,6 +1,3 @@ -//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. @@ -46,27 +43,26 @@ func NewConfigurationsForResourceGroupClient(subscriptionID string, credential a // NewListPager - Get Configuration records within a subscription and resource group // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource Group Name +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ConfigurationsForResourceGroupClientListOptions contains the optional parameters for the ConfigurationsForResourceGroupClient.NewListPager // method. func (client *ConfigurationsForResourceGroupClient) NewListPager(resourceGroupName string, options *ConfigurationsForResourceGroupClientListOptions) *runtime.Pager[ConfigurationsForResourceGroupClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ConfigurationsForResourceGroupClientListResponse]{ More: func(page ConfigurationsForResourceGroupClientListResponse) bool { - return false + return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ConfigurationsForResourceGroupClientListResponse) (ConfigurationsForResourceGroupClientListResponse, error) { ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ConfigurationsForResourceGroupClient.NewListPager") - req, err := client.listCreateRequest(ctx, resourceGroupName, options) - if err != nil { - return ConfigurationsForResourceGroupClientListResponse{}, err + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, options) + }, nil) if err != nil { return ConfigurationsForResourceGroupClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ConfigurationsForResourceGroupClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, Tracer: client.internal.Tracer(), @@ -74,8 +70,8 @@ func (client *ConfigurationsForResourceGroupClient) NewListPager(resourceGroupNa } // listCreateRequest creates the List request. -func (client *ConfigurationsForResourceGroupClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *ConfigurationsForResourceGroupClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations" +func (client *ConfigurationsForResourceGroupClient) listCreateRequest(ctx context.Context, resourceGroupName string, _ *ConfigurationsForResourceGroupClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } diff --git a/sdk/resourcemanager/maintenance/armmaintenance/configurationsforresourcegroup_client_example_test.go b/sdk/resourcemanager/maintenance/armmaintenance/configurationsforresourcegroup_client_example_test.go deleted file mode 100644 index 2322f581f9ce..000000000000 --- a/sdk/resourcemanager/maintenance/armmaintenance/configurationsforresourcegroup_client_example_test.go +++ /dev/null @@ -1,63 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armmaintenance_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurationsResourceGroup_List.json -func ExampleConfigurationsForResourceGroupClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewConfigurationsForResourceGroupClient().NewListPager("examplerg", 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.ListMaintenanceConfigurationsResult = armmaintenance.ListMaintenanceConfigurationsResult{ - // Value: []*armmaintenance.Configuration{ - // { - // Name: to.Ptr("configuration1"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - // Location: to.Ptr("westus2"), - // Properties: &armmaintenance.ConfigurationProperties{ - // MaintenanceScope: to.Ptr(armmaintenance.MaintenanceScopeOSImage), - // MaintenanceWindow: &armmaintenance.Window{ - // Duration: to.Ptr("05:00"), - // ExpirationDateTime: to.Ptr("9999-12-31 00:00"), - // RecurEvery: to.Ptr("Week Saturday,Sunday"), - // StartDateTime: to.Ptr("2020-04-30 08:00"), - // TimeZone: to.Ptr("Pacific Standard Time"), - // }, - // Namespace: to.Ptr("Microsoft.Maintenance"), - // Visibility: to.Ptr(armmaintenance.VisibilityCustom), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/maintenance/armmaintenance/constants.go b/sdk/resourcemanager/maintenance/armmaintenance/constants.go index 0e854eee464a..14f0014443a5 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/constants.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/constants.go @@ -1,6 +1,3 @@ -//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. @@ -10,9 +7,23 @@ package armmaintenance const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance" - moduleVersion = "v1.4.0-beta.1" + moduleVersion = "v1.4.0-beta.2" +) + +// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + ActionTypeInternal ActionType = "Internal" ) +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + // CreatedByType - The type of identity that created the resource. type CreatedByType string @@ -91,6 +102,25 @@ func PossibleMaintenanceScopeValues() []MaintenanceScope { } } +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" +type Origin string + +const ( + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + // RebootOptions - Possible reboot preference as defined by the user based on which it would be decided to reboot the machine // or not after the patch operation is completed. type RebootOptions string diff --git a/sdk/resourcemanager/maintenance/armmaintenance/fake/applyupdateforresourcegroup_server.go b/sdk/resourcemanager/maintenance/armmaintenance/fake/applyupdateforresourcegroup_server.go index f207952037e4..7f8b81c16b60 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/fake/applyupdateforresourcegroup_server.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/fake/applyupdateforresourcegroup_server.go @@ -1,6 +1,3 @@ -//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. @@ -14,6 +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/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance" "net/http" "net/url" @@ -52,21 +50,40 @@ func (a *ApplyUpdateForResourceGroupServerTransport) Do(req *http.Request) (*htt return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "ApplyUpdateForResourceGroupClient.NewListPager": - resp, err = a.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *ApplyUpdateForResourceGroupServerTransport) 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 applyUpdateForResourceGroupServerTransportInterceptor != nil { + res.resp, res.err, intercepted = applyUpdateForResourceGroupServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ApplyUpdateForResourceGroupClient.NewListPager": + res.resp, res.err = a.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 (a *ApplyUpdateForResourceGroupServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -88,6 +105,9 @@ func (a *ApplyUpdateForResourceGroupServerTransport) dispatchNewListPager(req *h resp := a.srv.NewListPager(resourceGroupNameParam, nil) newListPager = &resp a.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armmaintenance.ApplyUpdateForResourceGroupClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) } resp, err := server.PagerResponderNext(newListPager, req) if err != nil { @@ -102,3 +122,9 @@ func (a *ApplyUpdateForResourceGroupServerTransport) dispatchNewListPager(req *h } return resp, nil } + +// set this to conditionally intercept incoming requests to ApplyUpdateForResourceGroupServerTransport +var applyUpdateForResourceGroupServerTransportInterceptor 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/maintenance/armmaintenance/fake/applyupdates_server.go b/sdk/resourcemanager/maintenance/armmaintenance/fake/applyupdates_server.go index 32ec1ff2a620..4a11e4b7c948 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/fake/applyupdates_server.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/fake/applyupdates_server.go @@ -1,6 +1,3 @@ -//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. @@ -15,6 +12,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/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance" "net/http" "net/url" @@ -24,15 +22,15 @@ import ( // ApplyUpdatesServer is a fake server for instances of the armmaintenance.ApplyUpdatesClient type. type ApplyUpdatesServer struct { // CreateOrUpdate is the fake for method ApplyUpdatesClient.CreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + // HTTP status codes to indicate success: http.StatusOK CreateOrUpdate func(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, options *armmaintenance.ApplyUpdatesClientCreateOrUpdateOptions) (resp azfake.Responder[armmaintenance.ApplyUpdatesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // CreateOrUpdateOrCancel is the fake for method ApplyUpdatesClient.CreateOrUpdateOrCancel // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdateOrCancel func(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, applyUpdateName string, applyUpdate armmaintenance.ApplyUpdate, options *armmaintenance.ApplyUpdatesClientCreateOrUpdateOrCancelOptions) (resp azfake.Responder[armmaintenance.ApplyUpdatesClientCreateOrUpdateOrCancelResponse], errResp azfake.ErrorResponder) + CreateOrUpdateOrCancel func(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, applyUpdateName string, resource armmaintenance.ApplyUpdate, options *armmaintenance.ApplyUpdatesClientCreateOrUpdateOrCancelOptions) (resp azfake.Responder[armmaintenance.ApplyUpdatesClientCreateOrUpdateOrCancelResponse], errResp azfake.ErrorResponder) // CreateOrUpdateParent is the fake for method ApplyUpdatesClient.CreateOrUpdateParent - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + // HTTP status codes to indicate success: http.StatusOK CreateOrUpdateParent func(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, options *armmaintenance.ApplyUpdatesClientCreateOrUpdateParentOptions) (resp azfake.Responder[armmaintenance.ApplyUpdatesClientCreateOrUpdateParentResponse], errResp azfake.ErrorResponder) // Get is the fake for method ApplyUpdatesClient.Get @@ -73,31 +71,50 @@ func (a *ApplyUpdatesServerTransport) Do(req *http.Request) (*http.Response, err return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "ApplyUpdatesClient.CreateOrUpdate": - resp, err = a.dispatchCreateOrUpdate(req) - case "ApplyUpdatesClient.CreateOrUpdateOrCancel": - resp, err = a.dispatchCreateOrUpdateOrCancel(req) - case "ApplyUpdatesClient.CreateOrUpdateParent": - resp, err = a.dispatchCreateOrUpdateParent(req) - case "ApplyUpdatesClient.Get": - resp, err = a.dispatchGet(req) - case "ApplyUpdatesClient.GetParent": - resp, err = a.dispatchGetParent(req) - case "ApplyUpdatesClient.NewListPager": - resp, err = a.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *ApplyUpdatesServerTransport) 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 applyUpdatesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = applyUpdatesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ApplyUpdatesClient.CreateOrUpdate": + res.resp, res.err = a.dispatchCreateOrUpdate(req) + case "ApplyUpdatesClient.CreateOrUpdateOrCancel": + res.resp, res.err = a.dispatchCreateOrUpdateOrCancel(req) + case "ApplyUpdatesClient.CreateOrUpdateParent": + res.resp, res.err = a.dispatchCreateOrUpdateParent(req) + case "ApplyUpdatesClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "ApplyUpdatesClient.GetParent": + res.resp, res.err = a.dispatchGetParent(req) + case "ApplyUpdatesClient.NewListPager": + res.resp, res.err = a.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 (a *ApplyUpdatesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -131,8 +148,8 @@ func (a *ApplyUpdatesServerTransport) dispatchCreateOrUpdate(req *http.Request) return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + 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).ApplyUpdate, req) if err != nil { @@ -145,7 +162,7 @@ func (a *ApplyUpdatesServerTransport) dispatchCreateOrUpdateOrCancel(req *http.R if a.srv.CreateOrUpdateOrCancel == nil { return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdateOrCancel not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/applyUpdates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/applyUpdates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 6 { @@ -229,8 +246,8 @@ func (a *ApplyUpdatesServerTransport) dispatchCreateOrUpdateParent(req *http.Req return nil, respErr } respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + 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).ApplyUpdate, req) if err != nil { @@ -243,7 +260,7 @@ func (a *ApplyUpdatesServerTransport) dispatchGet(req *http.Request) (*http.Resp if a.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/applyUpdates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/applyUpdates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 6 { @@ -288,7 +305,7 @@ func (a *ApplyUpdatesServerTransport) dispatchGetParent(req *http.Request) (*htt if a.srv.GetParent == nil { return nil, &nonRetriableError{errors.New("fake for method GetParent not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/applyUpdates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/applyUpdates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 8 { @@ -352,6 +369,9 @@ func (a *ApplyUpdatesServerTransport) dispatchNewListPager(req *http.Request) (* resp := a.srv.NewListPager(nil) newListPager = &resp a.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armmaintenance.ApplyUpdatesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) } resp, err := server.PagerResponderNext(newListPager, req) if err != nil { @@ -366,3 +386,9 @@ func (a *ApplyUpdatesServerTransport) dispatchNewListPager(req *http.Request) (* } return resp, nil } + +// set this to conditionally intercept incoming requests to ApplyUpdatesServerTransport +var applyUpdatesServerTransportInterceptor 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/maintenance/armmaintenance/fake/configurationassignments_server.go b/sdk/resourcemanager/maintenance/armmaintenance/fake/configurationassignments_server.go index 9be2efe15a00..a095d8ea897d 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/fake/configurationassignments_server.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/fake/configurationassignments_server.go @@ -1,6 +1,3 @@ -//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. @@ -15,6 +12,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/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance" "net/http" "net/url" @@ -25,11 +23,11 @@ import ( type ConfigurationAssignmentsServer struct { // CreateOrUpdate is the fake for method ConfigurationAssignmentsClient.CreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdate func(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment armmaintenance.ConfigurationAssignment, options *armmaintenance.ConfigurationAssignmentsClientCreateOrUpdateOptions) (resp azfake.Responder[armmaintenance.ConfigurationAssignmentsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + CreateOrUpdate func(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, configurationAssignmentName string, resource armmaintenance.ConfigurationAssignment, options *armmaintenance.ConfigurationAssignmentsClientCreateOrUpdateOptions) (resp azfake.Responder[armmaintenance.ConfigurationAssignmentsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // CreateOrUpdateParent is the fake for method ConfigurationAssignmentsClient.CreateOrUpdateParent // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdateParent func(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, configurationAssignment armmaintenance.ConfigurationAssignment, options *armmaintenance.ConfigurationAssignmentsClientCreateOrUpdateParentOptions) (resp azfake.Responder[armmaintenance.ConfigurationAssignmentsClientCreateOrUpdateParentResponse], errResp azfake.ErrorResponder) + CreateOrUpdateParent func(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, resource armmaintenance.ConfigurationAssignment, options *armmaintenance.ConfigurationAssignmentsClientCreateOrUpdateParentOptions) (resp azfake.Responder[armmaintenance.ConfigurationAssignmentsClientCreateOrUpdateParentResponse], errResp azfake.ErrorResponder) // Delete is the fake for method ConfigurationAssignmentsClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent @@ -47,10 +45,6 @@ type ConfigurationAssignmentsServer struct { // HTTP status codes to indicate success: http.StatusOK GetParent func(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, configurationAssignmentName string, options *armmaintenance.ConfigurationAssignmentsClientGetParentOptions) (resp azfake.Responder[armmaintenance.ConfigurationAssignmentsClientGetParentResponse], errResp azfake.ErrorResponder) - // NewListPager is the fake for method ConfigurationAssignmentsClient.NewListPager - // HTTP status codes to indicate success: http.StatusOK - NewListPager func(resourceGroupName string, providerName string, resourceType string, resourceName string, options *armmaintenance.ConfigurationAssignmentsClientListOptions) (resp azfake.PagerResponder[armmaintenance.ConfigurationAssignmentsClientListResponse]) - // NewListParentPager is the fake for method ConfigurationAssignmentsClient.NewListParentPager // HTTP status codes to indicate success: http.StatusOK NewListParentPager func(resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, options *armmaintenance.ConfigurationAssignmentsClientListParentOptions) (resp azfake.PagerResponder[armmaintenance.ConfigurationAssignmentsClientListParentResponse]) @@ -62,7 +56,6 @@ type ConfigurationAssignmentsServer struct { func NewConfigurationAssignmentsServerTransport(srv *ConfigurationAssignmentsServer) *ConfigurationAssignmentsServerTransport { return &ConfigurationAssignmentsServerTransport{ srv: srv, - newListPager: newTracker[azfake.PagerResponder[armmaintenance.ConfigurationAssignmentsClientListResponse]](), newListParentPager: newTracker[azfake.PagerResponder[armmaintenance.ConfigurationAssignmentsClientListParentResponse]](), } } @@ -71,7 +64,6 @@ func NewConfigurationAssignmentsServerTransport(srv *ConfigurationAssignmentsSer // Don't use this type directly, use NewConfigurationAssignmentsServerTransport instead. type ConfigurationAssignmentsServerTransport struct { srv *ConfigurationAssignmentsServer - newListPager *tracker[azfake.PagerResponder[armmaintenance.ConfigurationAssignmentsClientListResponse]] newListParentPager *tracker[azfake.PagerResponder[armmaintenance.ConfigurationAssignmentsClientListParentResponse]] } @@ -83,42 +75,59 @@ func (c *ConfigurationAssignmentsServerTransport) Do(req *http.Request) (*http.R return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return c.dispatchToMethodFake(req, method) +} - switch method { - case "ConfigurationAssignmentsClient.CreateOrUpdate": - resp, err = c.dispatchCreateOrUpdate(req) - case "ConfigurationAssignmentsClient.CreateOrUpdateParent": - resp, err = c.dispatchCreateOrUpdateParent(req) - case "ConfigurationAssignmentsClient.Delete": - resp, err = c.dispatchDelete(req) - case "ConfigurationAssignmentsClient.DeleteParent": - resp, err = c.dispatchDeleteParent(req) - case "ConfigurationAssignmentsClient.Get": - resp, err = c.dispatchGet(req) - case "ConfigurationAssignmentsClient.GetParent": - resp, err = c.dispatchGetParent(req) - case "ConfigurationAssignmentsClient.NewListPager": - resp, err = c.dispatchNewListPager(req) - case "ConfigurationAssignmentsClient.NewListParentPager": - resp, err = c.dispatchNewListParentPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (c *ConfigurationAssignmentsServerTransport) 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 configurationAssignmentsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = configurationAssignmentsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ConfigurationAssignmentsClient.CreateOrUpdate": + res.resp, res.err = c.dispatchCreateOrUpdate(req) + case "ConfigurationAssignmentsClient.CreateOrUpdateParent": + res.resp, res.err = c.dispatchCreateOrUpdateParent(req) + case "ConfigurationAssignmentsClient.Delete": + res.resp, res.err = c.dispatchDelete(req) + case "ConfigurationAssignmentsClient.DeleteParent": + res.resp, res.err = c.dispatchDeleteParent(req) + case "ConfigurationAssignmentsClient.Get": + res.resp, res.err = c.dispatchGet(req) + case "ConfigurationAssignmentsClient.GetParent": + res.resp, res.err = c.dispatchGetParent(req) + case "ConfigurationAssignmentsClient.NewListParentPager": + res.resp, res.err = c.dispatchNewListParentPager(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 (c *ConfigurationAssignmentsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { if c.srv.CreateOrUpdate == nil { return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 6 { @@ -167,7 +176,7 @@ func (c *ConfigurationAssignmentsServerTransport) dispatchCreateOrUpdateParent(r if c.srv.CreateOrUpdateParent == nil { return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdateParent not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 8 { @@ -224,7 +233,7 @@ func (c *ConfigurationAssignmentsServerTransport) dispatchDelete(req *http.Reque if c.srv.Delete == nil { return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 6 { @@ -269,7 +278,7 @@ func (c *ConfigurationAssignmentsServerTransport) dispatchDeleteParent(req *http if c.srv.DeleteParent == nil { return nil, &nonRetriableError{errors.New("fake for method DeleteParent not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 8 { @@ -322,7 +331,7 @@ func (c *ConfigurationAssignmentsServerTransport) dispatchGet(req *http.Request) if c.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 6 { @@ -367,7 +376,7 @@ func (c *ConfigurationAssignmentsServerTransport) dispatchGetParent(req *http.Re if c.srv.GetParent == nil { return nil, &nonRetriableError{errors.New("fake for method GetParent not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 8 { @@ -416,59 +425,13 @@ func (c *ConfigurationAssignmentsServerTransport) dispatchGetParent(req *http.Re return resp, nil } -func (c *ConfigurationAssignmentsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { - if c.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} - } - newListPager := c.newListPager.get(req) - if newListPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 5 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - providerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("providerName")]) - if err != nil { - return nil, err - } - resourceTypeParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceType")]) - if err != nil { - return nil, err - } - resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) - if err != nil { - return nil, err - } - resp := c.srv.NewListPager(resourceGroupNameParam, providerNameParam, resourceTypeParam, resourceNameParam, nil) - newListPager = &resp - c.newListPager.add(req, newListPager) - } - resp, err := server.PagerResponderNext(newListPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - c.newListPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListPager) { - c.newListPager.remove(req) - } - return resp, nil -} - func (c *ConfigurationAssignmentsServerTransport) dispatchNewListParentPager(req *http.Request) (*http.Response, error) { if c.srv.NewListParentPager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListParentPager not implemented")} } newListParentPager := c.newListParentPager.get(req) if newListParentPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 7 { @@ -501,6 +464,9 @@ func (c *ConfigurationAssignmentsServerTransport) dispatchNewListParentPager(req resp := c.srv.NewListParentPager(resourceGroupNameParam, providerNameParam, resourceParentTypeParam, resourceParentNameParam, resourceTypeParam, resourceNameParam, nil) newListParentPager = &resp c.newListParentPager.add(req, newListParentPager) + server.PagerResponderInjectNextLinks(newListParentPager, req, func(page *armmaintenance.ConfigurationAssignmentsClientListParentResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) } resp, err := server.PagerResponderNext(newListParentPager, req) if err != nil { @@ -515,3 +481,9 @@ func (c *ConfigurationAssignmentsServerTransport) dispatchNewListParentPager(req } return resp, nil } + +// set this to conditionally intercept incoming requests to ConfigurationAssignmentsServerTransport +var configurationAssignmentsServerTransportInterceptor 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/maintenance/armmaintenance/fake/configurationassignmentsforresourcegroup_server.go b/sdk/resourcemanager/maintenance/armmaintenance/fake/configurationassignmentsforresourcegroup_server.go index 2cf21c952ae9..5abedae1e120 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/fake/configurationassignmentsforresourcegroup_server.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/fake/configurationassignmentsforresourcegroup_server.go @@ -1,6 +1,3 @@ -//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. @@ -25,7 +22,7 @@ import ( type ConfigurationAssignmentsForResourceGroupServer struct { // CreateOrUpdate is the fake for method ConfigurationAssignmentsForResourceGroupClient.CreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdate func(ctx context.Context, resourceGroupName string, configurationAssignmentName string, configurationAssignment armmaintenance.ConfigurationAssignment, options *armmaintenance.ConfigurationAssignmentsForResourceGroupClientCreateOrUpdateOptions) (resp azfake.Responder[armmaintenance.ConfigurationAssignmentsForResourceGroupClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + CreateOrUpdate func(ctx context.Context, resourceGroupName string, configurationAssignmentName string, resource armmaintenance.ConfigurationAssignment, options *armmaintenance.ConfigurationAssignmentsForResourceGroupClientCreateOrUpdateOptions) (resp azfake.Responder[armmaintenance.ConfigurationAssignmentsForResourceGroupClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // Delete is the fake for method ConfigurationAssignmentsForResourceGroupClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent @@ -37,7 +34,7 @@ type ConfigurationAssignmentsForResourceGroupServer struct { // Update is the fake for method ConfigurationAssignmentsForResourceGroupClient.Update // HTTP status codes to indicate success: http.StatusOK - Update func(ctx context.Context, resourceGroupName string, configurationAssignmentName string, configurationAssignment armmaintenance.ConfigurationAssignment, options *armmaintenance.ConfigurationAssignmentsForResourceGroupClientUpdateOptions) (resp azfake.Responder[armmaintenance.ConfigurationAssignmentsForResourceGroupClientUpdateResponse], errResp azfake.ErrorResponder) + Update func(ctx context.Context, resourceGroupName string, configurationAssignmentName string, properties armmaintenance.ConfigurationAssignment, options *armmaintenance.ConfigurationAssignmentsForResourceGroupClientUpdateOptions) (resp azfake.Responder[armmaintenance.ConfigurationAssignmentsForResourceGroupClientUpdateResponse], errResp azfake.ErrorResponder) } // NewConfigurationAssignmentsForResourceGroupServerTransport creates a new instance of ConfigurationAssignmentsForResourceGroupServerTransport with the provided implementation. @@ -61,34 +58,53 @@ func (c *ConfigurationAssignmentsForResourceGroupServerTransport) Do(req *http.R return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error - - switch method { - case "ConfigurationAssignmentsForResourceGroupClient.CreateOrUpdate": - resp, err = c.dispatchCreateOrUpdate(req) - case "ConfigurationAssignmentsForResourceGroupClient.Delete": - resp, err = c.dispatchDelete(req) - case "ConfigurationAssignmentsForResourceGroupClient.Get": - resp, err = c.dispatchGet(req) - case "ConfigurationAssignmentsForResourceGroupClient.Update": - resp, err = c.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } + return c.dispatchToMethodFake(req, method) +} - if err != nil { - return nil, err +func (c *ConfigurationAssignmentsForResourceGroupServerTransport) 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 configurationAssignmentsForResourceGroupServerTransportInterceptor != nil { + res.resp, res.err, intercepted = configurationAssignmentsForResourceGroupServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ConfigurationAssignmentsForResourceGroupClient.CreateOrUpdate": + res.resp, res.err = c.dispatchCreateOrUpdate(req) + case "ConfigurationAssignmentsForResourceGroupClient.Delete": + res.resp, res.err = c.dispatchDelete(req) + case "ConfigurationAssignmentsForResourceGroupClient.Get": + res.resp, res.err = c.dispatchGet(req) + case "ConfigurationAssignmentsForResourceGroupClient.Update": + res.resp, res.err = c.dispatchUpdate(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 (c *ConfigurationAssignmentsForResourceGroupServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { if c.srv.CreateOrUpdate == nil { return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { @@ -125,7 +141,7 @@ func (c *ConfigurationAssignmentsForResourceGroupServerTransport) dispatchDelete if c.srv.Delete == nil { return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { @@ -158,7 +174,7 @@ func (c *ConfigurationAssignmentsForResourceGroupServerTransport) dispatchGet(re if c.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { @@ -191,7 +207,7 @@ func (c *ConfigurationAssignmentsForResourceGroupServerTransport) dispatchUpdate if c.srv.Update == nil { return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/configurationAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { @@ -223,3 +239,9 @@ func (c *ConfigurationAssignmentsForResourceGroupServerTransport) dispatchUpdate } return resp, nil } + +// set this to conditionally intercept incoming requests to ConfigurationAssignmentsForResourceGroupServerTransport +var configurationAssignmentsForResourceGroupServerTransportInterceptor 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/maintenance/armmaintenance/fake/configurationassignmentsforsubscriptions_server.go b/sdk/resourcemanager/maintenance/armmaintenance/fake/configurationassignmentsforsubscriptions_server.go index a6319dbf9fda..df30408b81f5 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/fake/configurationassignmentsforsubscriptions_server.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/fake/configurationassignmentsforsubscriptions_server.go @@ -1,6 +1,3 @@ -//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. @@ -25,7 +22,7 @@ import ( type ConfigurationAssignmentsForSubscriptionsServer struct { // CreateOrUpdate is the fake for method ConfigurationAssignmentsForSubscriptionsClient.CreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdate func(ctx context.Context, configurationAssignmentName string, configurationAssignment armmaintenance.ConfigurationAssignment, options *armmaintenance.ConfigurationAssignmentsForSubscriptionsClientCreateOrUpdateOptions) (resp azfake.Responder[armmaintenance.ConfigurationAssignmentsForSubscriptionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + CreateOrUpdate func(ctx context.Context, configurationAssignmentName string, resource armmaintenance.ConfigurationAssignment, options *armmaintenance.ConfigurationAssignmentsForSubscriptionsClientCreateOrUpdateOptions) (resp azfake.Responder[armmaintenance.ConfigurationAssignmentsForSubscriptionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // Delete is the fake for method ConfigurationAssignmentsForSubscriptionsClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent @@ -37,7 +34,7 @@ type ConfigurationAssignmentsForSubscriptionsServer struct { // Update is the fake for method ConfigurationAssignmentsForSubscriptionsClient.Update // HTTP status codes to indicate success: http.StatusOK - Update func(ctx context.Context, configurationAssignmentName string, configurationAssignment armmaintenance.ConfigurationAssignment, options *armmaintenance.ConfigurationAssignmentsForSubscriptionsClientUpdateOptions) (resp azfake.Responder[armmaintenance.ConfigurationAssignmentsForSubscriptionsClientUpdateResponse], errResp azfake.ErrorResponder) + Update func(ctx context.Context, configurationAssignmentName string, properties armmaintenance.ConfigurationAssignment, options *armmaintenance.ConfigurationAssignmentsForSubscriptionsClientUpdateOptions) (resp azfake.Responder[armmaintenance.ConfigurationAssignmentsForSubscriptionsClientUpdateResponse], errResp azfake.ErrorResponder) } // NewConfigurationAssignmentsForSubscriptionsServerTransport creates a new instance of ConfigurationAssignmentsForSubscriptionsServerTransport with the provided implementation. @@ -61,27 +58,46 @@ func (c *ConfigurationAssignmentsForSubscriptionsServerTransport) Do(req *http.R return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error - - switch method { - case "ConfigurationAssignmentsForSubscriptionsClient.CreateOrUpdate": - resp, err = c.dispatchCreateOrUpdate(req) - case "ConfigurationAssignmentsForSubscriptionsClient.Delete": - resp, err = c.dispatchDelete(req) - case "ConfigurationAssignmentsForSubscriptionsClient.Get": - resp, err = c.dispatchGet(req) - case "ConfigurationAssignmentsForSubscriptionsClient.Update": - resp, err = c.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } + return c.dispatchToMethodFake(req, method) +} - if err != nil { - return nil, err +func (c *ConfigurationAssignmentsForSubscriptionsServerTransport) 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 configurationAssignmentsForSubscriptionsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = configurationAssignmentsForSubscriptionsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ConfigurationAssignmentsForSubscriptionsClient.CreateOrUpdate": + res.resp, res.err = c.dispatchCreateOrUpdate(req) + case "ConfigurationAssignmentsForSubscriptionsClient.Delete": + res.resp, res.err = c.dispatchDelete(req) + case "ConfigurationAssignmentsForSubscriptionsClient.Get": + res.resp, res.err = c.dispatchGet(req) + case "ConfigurationAssignmentsForSubscriptionsClient.Update": + res.resp, res.err = c.dispatchUpdate(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 (c *ConfigurationAssignmentsForSubscriptionsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -207,3 +223,9 @@ func (c *ConfigurationAssignmentsForSubscriptionsServerTransport) dispatchUpdate } return resp, nil } + +// set this to conditionally intercept incoming requests to ConfigurationAssignmentsForSubscriptionsServerTransport +var configurationAssignmentsForSubscriptionsServerTransportInterceptor 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/maintenance/armmaintenance/fake/configurationassignmentswithinsubscription_server.go b/sdk/resourcemanager/maintenance/armmaintenance/fake/configurationassignmentswithinsubscription_server.go index 831f6885dc50..af957f8fab17 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/fake/configurationassignmentswithinsubscription_server.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/fake/configurationassignmentswithinsubscription_server.go @@ -1,6 +1,3 @@ -//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. @@ -14,6 +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/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance" "net/http" "regexp" @@ -51,21 +49,40 @@ func (c *ConfigurationAssignmentsWithinSubscriptionServerTransport) Do(req *http return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return c.dispatchToMethodFake(req, method) +} - switch method { - case "ConfigurationAssignmentsWithinSubscriptionClient.NewListPager": - resp, err = c.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (c *ConfigurationAssignmentsWithinSubscriptionServerTransport) 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 configurationAssignmentsWithinSubscriptionServerTransportInterceptor != nil { + res.resp, res.err, intercepted = configurationAssignmentsWithinSubscriptionServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ConfigurationAssignmentsWithinSubscriptionClient.NewListPager": + res.resp, res.err = c.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 (c *ConfigurationAssignmentsWithinSubscriptionServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -83,6 +100,9 @@ func (c *ConfigurationAssignmentsWithinSubscriptionServerTransport) dispatchNewL resp := c.srv.NewListPager(nil) newListPager = &resp c.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armmaintenance.ConfigurationAssignmentsWithinSubscriptionClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) } resp, err := server.PagerResponderNext(newListPager, req) if err != nil { @@ -97,3 +117,9 @@ func (c *ConfigurationAssignmentsWithinSubscriptionServerTransport) dispatchNewL } return resp, nil } + +// set this to conditionally intercept incoming requests to ConfigurationAssignmentsWithinSubscriptionServerTransport +var configurationAssignmentsWithinSubscriptionServerTransportInterceptor 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/maintenance/armmaintenance/fake/configurations_server.go b/sdk/resourcemanager/maintenance/armmaintenance/fake/configurations_server.go index 431ac8883a8c..84081dd1cdd8 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/fake/configurations_server.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/fake/configurations_server.go @@ -1,6 +1,3 @@ -//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. @@ -15,6 +12,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/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance" "net/http" "net/url" @@ -25,7 +23,7 @@ import ( type ConfigurationsServer struct { // CreateOrUpdate is the fake for method ConfigurationsClient.CreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdate func(ctx context.Context, resourceGroupName string, resourceName string, configuration armmaintenance.Configuration, options *armmaintenance.ConfigurationsClientCreateOrUpdateOptions) (resp azfake.Responder[armmaintenance.ConfigurationsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + CreateOrUpdate func(ctx context.Context, resourceGroupName string, resourceName string, resource armmaintenance.Configuration, options *armmaintenance.ConfigurationsClientCreateOrUpdateOptions) (resp azfake.Responder[armmaintenance.ConfigurationsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // Delete is the fake for method ConfigurationsClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent @@ -41,7 +39,7 @@ type ConfigurationsServer struct { // Update is the fake for method ConfigurationsClient.Update // HTTP status codes to indicate success: http.StatusOK - Update func(ctx context.Context, resourceGroupName string, resourceName string, configuration armmaintenance.Configuration, options *armmaintenance.ConfigurationsClientUpdateOptions) (resp azfake.Responder[armmaintenance.ConfigurationsClientUpdateResponse], errResp azfake.ErrorResponder) + Update func(ctx context.Context, resourceGroupName string, resourceName string, properties armmaintenance.Configuration, options *armmaintenance.ConfigurationsClientUpdateOptions) (resp azfake.Responder[armmaintenance.ConfigurationsClientUpdateResponse], errResp azfake.ErrorResponder) } // NewConfigurationsServerTransport creates a new instance of ConfigurationsServerTransport with the provided implementation. @@ -69,36 +67,55 @@ func (c *ConfigurationsServerTransport) Do(req *http.Request) (*http.Response, e return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return c.dispatchToMethodFake(req, method) +} - switch method { - case "ConfigurationsClient.CreateOrUpdate": - resp, err = c.dispatchCreateOrUpdate(req) - case "ConfigurationsClient.Delete": - resp, err = c.dispatchDelete(req) - case "ConfigurationsClient.Get": - resp, err = c.dispatchGet(req) - case "ConfigurationsClient.NewListPager": - resp, err = c.dispatchNewListPager(req) - case "ConfigurationsClient.Update": - resp, err = c.dispatchUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (c *ConfigurationsServerTransport) 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 configurationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = configurationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ConfigurationsClient.CreateOrUpdate": + res.resp, res.err = c.dispatchCreateOrUpdate(req) + case "ConfigurationsClient.Delete": + res.resp, res.err = c.dispatchDelete(req) + case "ConfigurationsClient.Get": + res.resp, res.err = c.dispatchGet(req) + case "ConfigurationsClient.NewListPager": + res.resp, res.err = c.dispatchNewListPager(req) + case "ConfigurationsClient.Update": + res.resp, res.err = c.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 (c *ConfigurationsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { if c.srv.CreateOrUpdate == nil { return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/maintenanceConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/maintenanceConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { @@ -135,7 +152,7 @@ func (c *ConfigurationsServerTransport) dispatchDelete(req *http.Request) (*http if c.srv.Delete == nil { return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/maintenanceConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/maintenanceConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { @@ -168,7 +185,7 @@ func (c *ConfigurationsServerTransport) dispatchGet(req *http.Request) (*http.Re if c.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/maintenanceConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/maintenanceConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { @@ -212,6 +229,9 @@ func (c *ConfigurationsServerTransport) dispatchNewListPager(req *http.Request) resp := c.srv.NewListPager(nil) newListPager = &resp c.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armmaintenance.ConfigurationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) } resp, err := server.PagerResponderNext(newListPager, req) if err != nil { @@ -231,7 +251,7 @@ func (c *ConfigurationsServerTransport) dispatchUpdate(req *http.Request) (*http if c.srv.Update == nil { return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/maintenanceConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/maintenanceConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { @@ -263,3 +283,9 @@ func (c *ConfigurationsServerTransport) dispatchUpdate(req *http.Request) (*http } return resp, nil } + +// set this to conditionally intercept incoming requests to ConfigurationsServerTransport +var configurationsServerTransportInterceptor 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/maintenance/armmaintenance/fake/configurationsforresourcegroup_server.go b/sdk/resourcemanager/maintenance/armmaintenance/fake/configurationsforresourcegroup_server.go index eb43b7881627..9d0fa920b351 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/fake/configurationsforresourcegroup_server.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/fake/configurationsforresourcegroup_server.go @@ -1,6 +1,3 @@ -//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. @@ -14,6 +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/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance" "net/http" "net/url" @@ -52,21 +50,40 @@ func (c *ConfigurationsForResourceGroupServerTransport) Do(req *http.Request) (* return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return c.dispatchToMethodFake(req, method) +} - switch method { - case "ConfigurationsForResourceGroupClient.NewListPager": - resp, err = c.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (c *ConfigurationsForResourceGroupServerTransport) 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 configurationsForResourceGroupServerTransportInterceptor != nil { + res.resp, res.err, intercepted = configurationsForResourceGroupServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ConfigurationsForResourceGroupClient.NewListPager": + res.resp, res.err = c.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 (c *ConfigurationsForResourceGroupServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -75,7 +92,7 @@ func (c *ConfigurationsForResourceGroupServerTransport) dispatchNewListPager(req } newListPager := c.newListPager.get(req) if newListPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/maintenanceConfigurations` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/publicMaintenanceConfigurations` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 2 { @@ -88,6 +105,9 @@ func (c *ConfigurationsForResourceGroupServerTransport) dispatchNewListPager(req resp := c.srv.NewListPager(resourceGroupNameParam, nil) newListPager = &resp c.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armmaintenance.ConfigurationsForResourceGroupClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) } resp, err := server.PagerResponderNext(newListPager, req) if err != nil { @@ -102,3 +122,9 @@ func (c *ConfigurationsForResourceGroupServerTransport) dispatchNewListPager(req } return resp, nil } + +// set this to conditionally intercept incoming requests to ConfigurationsForResourceGroupServerTransport +var configurationsForResourceGroupServerTransportInterceptor 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/maintenance/armmaintenance/fake/internal.go b/sdk/resourcemanager/maintenance/armmaintenance/fake/internal.go index 5f75802a569e..4b65adc76adb 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/fake/internal.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/fake/internal.go @@ -1,6 +1,3 @@ -//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. @@ -14,6 +11,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } diff --git a/sdk/resourcemanager/maintenance/armmaintenance/fake/operations_server.go b/sdk/resourcemanager/maintenance/armmaintenance/fake/operations_server.go index 1fbad1996e9f..8e8083ce8c47 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/fake/operations_server.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/fake/operations_server.go @@ -1,6 +1,3 @@ -//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. @@ -14,6 +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/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance" "net/http" ) @@ -50,21 +48,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) { @@ -76,6 +93,9 @@ func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*ht resp := o.srv.NewListPager(nil) newListPager = &resp o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armmaintenance.OperationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) } resp, err := server.PagerResponderNext(newListPager, req) if err != nil { @@ -90,3 +110,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/maintenance/armmaintenance/fake/publicmaintenanceconfigurations_server.go b/sdk/resourcemanager/maintenance/armmaintenance/fake/publicmaintenanceconfigurations_server.go index f62224992003..7143612efe68 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/fake/publicmaintenanceconfigurations_server.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/fake/publicmaintenanceconfigurations_server.go @@ -1,6 +1,3 @@ -//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. @@ -15,6 +12,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/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance" "net/http" "net/url" @@ -57,23 +55,42 @@ func (p *PublicMaintenanceConfigurationsServerTransport) Do(req *http.Request) ( return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "PublicMaintenanceConfigurationsClient.Get": - resp, err = p.dispatchGet(req) - case "PublicMaintenanceConfigurationsClient.NewListPager": - resp, err = p.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *PublicMaintenanceConfigurationsServerTransport) 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 publicMaintenanceConfigurationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = publicMaintenanceConfigurationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PublicMaintenanceConfigurationsClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "PublicMaintenanceConfigurationsClient.NewListPager": + res.resp, res.err = p.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 (p *PublicMaintenanceConfigurationsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { @@ -120,6 +137,9 @@ func (p *PublicMaintenanceConfigurationsServerTransport) dispatchNewListPager(re resp := p.srv.NewListPager(nil) newListPager = &resp p.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armmaintenance.PublicMaintenanceConfigurationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) } resp, err := server.PagerResponderNext(newListPager, req) if err != nil { @@ -134,3 +154,9 @@ func (p *PublicMaintenanceConfigurationsServerTransport) dispatchNewListPager(re } return resp, nil } + +// set this to conditionally intercept incoming requests to PublicMaintenanceConfigurationsServerTransport +var publicMaintenanceConfigurationsServerTransportInterceptor 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/maintenance/armmaintenance/fake/scheduledevent_server.go b/sdk/resourcemanager/maintenance/armmaintenance/fake/scheduledevent_server.go index 230a859dedf3..ffd46633ba81 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/fake/scheduledevent_server.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/fake/scheduledevent_server.go @@ -1,6 +1,3 @@ -//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. @@ -49,21 +46,40 @@ func (s *ScheduledEventServerTransport) Do(req *http.Request) (*http.Response, e 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 "ScheduledEventClient.Acknowledge": - resp, err = s.dispatchAcknowledge(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (s *ScheduledEventServerTransport) 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 scheduledEventServerTransportInterceptor != nil { + res.resp, res.err, intercepted = scheduledEventServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ScheduledEventClient.Acknowledge": + res.resp, res.err = s.dispatchAcknowledge(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 *ScheduledEventServerTransport) dispatchAcknowledge(req *http.Request) (*http.Response, error) { @@ -106,3 +122,9 @@ func (s *ScheduledEventServerTransport) dispatchAcknowledge(req *http.Request) ( } return resp, nil } + +// set this to conditionally intercept incoming requests to ScheduledEventServerTransport +var scheduledEventServerTransportInterceptor 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/maintenance/armmaintenance/fake/server_factory.go b/sdk/resourcemanager/maintenance/armmaintenance/fake/server_factory.go index 21ad41daea38..9d92a80a65c4 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/fake/server_factory.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/fake/server_factory.go @@ -1,6 +1,3 @@ -//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. @@ -19,18 +16,41 @@ import ( // ServerFactory is a fake server for instances of the armmaintenance.ClientFactory type. type ServerFactory struct { - ApplyUpdateForResourceGroupServer ApplyUpdateForResourceGroupServer - ApplyUpdatesServer ApplyUpdatesServer - ConfigurationAssignmentsServer ConfigurationAssignmentsServer - ConfigurationAssignmentsForResourceGroupServer ConfigurationAssignmentsForResourceGroupServer - ConfigurationAssignmentsForSubscriptionsServer ConfigurationAssignmentsForSubscriptionsServer + // ApplyUpdateForResourceGroupServer contains the fakes for client ApplyUpdateForResourceGroupClient + ApplyUpdateForResourceGroupServer ApplyUpdateForResourceGroupServer + + // ApplyUpdatesServer contains the fakes for client ApplyUpdatesClient + ApplyUpdatesServer ApplyUpdatesServer + + // ConfigurationAssignmentsServer contains the fakes for client ConfigurationAssignmentsClient + ConfigurationAssignmentsServer ConfigurationAssignmentsServer + + // ConfigurationAssignmentsForResourceGroupServer contains the fakes for client ConfigurationAssignmentsForResourceGroupClient + ConfigurationAssignmentsForResourceGroupServer ConfigurationAssignmentsForResourceGroupServer + + // ConfigurationAssignmentsForSubscriptionsServer contains the fakes for client ConfigurationAssignmentsForSubscriptionsClient + ConfigurationAssignmentsForSubscriptionsServer ConfigurationAssignmentsForSubscriptionsServer + + // ConfigurationAssignmentsWithinSubscriptionServer contains the fakes for client ConfigurationAssignmentsWithinSubscriptionClient ConfigurationAssignmentsWithinSubscriptionServer ConfigurationAssignmentsWithinSubscriptionServer - ConfigurationsServer ConfigurationsServer - ConfigurationsForResourceGroupServer ConfigurationsForResourceGroupServer - OperationsServer OperationsServer - PublicMaintenanceConfigurationsServer PublicMaintenanceConfigurationsServer - ScheduledEventServer ScheduledEventServer - UpdatesServer UpdatesServer + + // ConfigurationsServer contains the fakes for client ConfigurationsClient + ConfigurationsServer ConfigurationsServer + + // ConfigurationsForResourceGroupServer contains the fakes for client ConfigurationsForResourceGroupClient + ConfigurationsForResourceGroupServer ConfigurationsForResourceGroupServer + + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // PublicMaintenanceConfigurationsServer contains the fakes for client PublicMaintenanceConfigurationsClient + PublicMaintenanceConfigurationsServer PublicMaintenanceConfigurationsServer + + // ScheduledEventServer contains the fakes for client ScheduledEventClient + ScheduledEventServer ScheduledEventServer + + // UpdatesServer contains the fakes for client UpdatesClient + UpdatesServer UpdatesServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. diff --git a/sdk/resourcemanager/maintenance/armmaintenance/fake/time_rfc3339.go b/sdk/resourcemanager/maintenance/armmaintenance/fake/time_rfc3339.go deleted file mode 100644 index 81f308b0d343..000000000000 --- a/sdk/resourcemanager/maintenance/armmaintenance/fake/time_rfc3339.go +++ /dev/null @@ -1,110 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. 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 ( - 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 - -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 { - 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 { - 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)) -} - -func (t *dateTimeRFC3339) Parse(layout, value string) error { - p, err := time.Parse(layout, strings.ToUpper(value)) - *t = dateTimeRFC3339(p) - 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 - } 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 || 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/maintenance/armmaintenance/fake/updates_server.go b/sdk/resourcemanager/maintenance/armmaintenance/fake/updates_server.go index 289ca56617d8..2a29b0b63c2c 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/fake/updates_server.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/fake/updates_server.go @@ -1,6 +1,3 @@ -//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. @@ -9,6 +6,7 @@ package fake import ( + "context" "errors" "fmt" azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" @@ -22,32 +20,26 @@ import ( // UpdatesServer is a fake server for instances of the armmaintenance.UpdatesClient type. type UpdatesServer struct { - // NewListPager is the fake for method UpdatesClient.NewListPager + // List is the fake for method UpdatesClient.List // HTTP status codes to indicate success: http.StatusOK - NewListPager func(resourceGroupName string, providerName string, resourceType string, resourceName string, options *armmaintenance.UpdatesClientListOptions) (resp azfake.PagerResponder[armmaintenance.UpdatesClientListResponse]) + List func(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, options *armmaintenance.UpdatesClientListOptions) (resp azfake.Responder[armmaintenance.UpdatesClientListResponse], errResp azfake.ErrorResponder) - // NewListParentPager is the fake for method UpdatesClient.NewListParentPager + // ListParent is the fake for method UpdatesClient.ListParent // HTTP status codes to indicate success: http.StatusOK - NewListParentPager func(resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, options *armmaintenance.UpdatesClientListParentOptions) (resp azfake.PagerResponder[armmaintenance.UpdatesClientListParentResponse]) + ListParent func(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, options *armmaintenance.UpdatesClientListParentOptions) (resp azfake.Responder[armmaintenance.UpdatesClientListParentResponse], errResp azfake.ErrorResponder) } // NewUpdatesServerTransport creates a new instance of UpdatesServerTransport with the provided implementation. // The returned UpdatesServerTransport instance is connected to an instance of armmaintenance.UpdatesClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewUpdatesServerTransport(srv *UpdatesServer) *UpdatesServerTransport { - return &UpdatesServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armmaintenance.UpdatesClientListResponse]](), - newListParentPager: newTracker[azfake.PagerResponder[armmaintenance.UpdatesClientListParentResponse]](), - } + return &UpdatesServerTransport{srv: srv} } // UpdatesServerTransport connects instances of armmaintenance.UpdatesClient to instances of UpdatesServer. // Don't use this type directly, use NewUpdatesServerTransport instead. type UpdatesServerTransport struct { - srv *UpdatesServer - newListPager *tracker[azfake.PagerResponder[armmaintenance.UpdatesClientListResponse]] - newListParentPager *tracker[azfake.PagerResponder[armmaintenance.UpdatesClientListParentResponse]] + srv *UpdatesServer } // Do implements the policy.Transporter interface for UpdatesServerTransport. @@ -58,121 +50,136 @@ func (u *UpdatesServerTransport) 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 u.dispatchToMethodFake(req, method) +} + +func (u *UpdatesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - switch method { - case "UpdatesClient.NewListPager": - resp, err = u.dispatchNewListPager(req) - case "UpdatesClient.NewListParentPager": - resp, err = u.dispatchNewListParentPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) + go func() { + var intercepted bool + var res result + if updatesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = updatesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "UpdatesClient.List": + res.resp, res.err = u.dispatchList(req) + case "UpdatesClient.ListParent": + res.resp, res.err = u.dispatchListParent(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 } +} +func (u *UpdatesServerTransport) dispatchList(req *http.Request) (*http.Response, error) { + if u.srv.List == nil { + return nil, &nonRetriableError{errors.New("fake for method List not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/updates` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) if err != nil { return nil, err } - - return resp, nil -} - -func (u *UpdatesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { - if u.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} - } - newListPager := u.newListPager.get(req) - if newListPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/updates` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 5 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - providerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("providerName")]) - if err != nil { - return nil, err - } - resourceTypeParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceType")]) - if err != nil { - return nil, err - } - resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) - if err != nil { - return nil, err - } - resp := u.srv.NewListPager(resourceGroupNameParam, providerNameParam, resourceTypeParam, resourceNameParam, nil) - newListPager = &resp - u.newListPager.add(req, newListPager) + providerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("providerName")]) + if err != nil { + return nil, err + } + resourceTypeParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceType")]) + if err != nil { + return nil, err } - resp, err := server.PagerResponderNext(newListPager, req) + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) if err != nil { return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - u.newListPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + respr, errRespr := u.srv.List(req.Context(), resourceGroupNameParam, providerNameParam, resourceTypeParam, resourceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr } - if !server.PagerResponderMore(newListPager) { - u.newListPager.remove(req) + 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).ListUpdatesResult, req) + if err != nil { + return nil, err } return resp, nil } -func (u *UpdatesServerTransport) dispatchNewListParentPager(req *http.Request) (*http.Response, error) { - if u.srv.NewListParentPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListParentPager not implemented")} - } - newListParentPager := u.newListParentPager.get(req) - if newListParentPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/updates` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 7 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - providerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("providerName")]) - if err != nil { - return nil, err - } - resourceParentTypeParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceParentType")]) - if err != nil { - return nil, err - } - resourceParentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceParentName")]) - if err != nil { - return nil, err - } - resourceTypeParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceType")]) - if err != nil { - return nil, err - } - resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) - if err != nil { - return nil, err - } - resp := u.srv.NewListParentPager(resourceGroupNameParam, providerNameParam, resourceParentTypeParam, resourceParentNameParam, resourceTypeParam, resourceNameParam, nil) - newListParentPager = &resp - u.newListParentPager.add(req, newListParentPager) +func (u *UpdatesServerTransport) dispatchListParent(req *http.Request) (*http.Response, error) { + if u.srv.ListParent == nil { + return nil, &nonRetriableError{errors.New("fake for method ListParent not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Maintenance/updates` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 7 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + providerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("providerName")]) + if err != nil { + return nil, err } - resp, err := server.PagerResponderNext(newListParentPager, req) + resourceParentTypeParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceParentType")]) if err != nil { return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - u.newListParentPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + resourceParentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceParentName")]) + if err != nil { + return nil, err + } + resourceTypeParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceType")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := u.srv.ListParent(req.Context(), resourceGroupNameParam, providerNameParam, resourceParentTypeParam, resourceParentNameParam, resourceTypeParam, resourceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr } - if !server.PagerResponderMore(newListParentPager) { - u.newListParentPager.remove(req) + 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).ListUpdatesResult, req) + if err != nil { + return nil, err } return resp, nil } + +// set this to conditionally intercept incoming requests to UpdatesServerTransport +var updatesServerTransportInterceptor 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/maintenance/armmaintenance/go.mod b/sdk/resourcemanager/maintenance/armmaintenance/go.mod index 8fee4903e0f9..ebf560787884 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/go.mod +++ b/sdk/resourcemanager/maintenance/armmaintenance/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmain go 1.23.0 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.2 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.36.0 // indirect golang.org/x/net v0.38.0 // indirect - golang.org/x/sys v0.31.0 // indirect golang.org/x/text v0.23.0 // indirect ) diff --git a/sdk/resourcemanager/maintenance/armmaintenance/go.sum b/sdk/resourcemanager/maintenance/armmaintenance/go.sum index 4bacf756f06c..4de695d9e23a 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/go.sum +++ b/sdk/resourcemanager/maintenance/armmaintenance/go.sum @@ -1,44 +1,15 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 h1:F0gBpfdPLGsw+nsgk6aqqkZS1jiixa5WwFe3fk/T3Ys= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2/go.mod h1:SqINnQ9lVVdRlyC8cd1lCI0SdX4n2paeABd2K8ggfnE= -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.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 h1:oygO0locgZJe7PpYPXT5A29ZkwJaPqcva7BVeemZOZs= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= -github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6 h1:IsMZxCuZqKuao2vNdfD82fjjgPLfyHLpR41Z88viRWs= -github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6/go.mod h1:3VeWNIJaW+O5xpRQbPp0Ybqu1vJd/pm7s2F473HRrkw= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E= -github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= 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.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= -golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/maintenance/armmaintenance/models.go b/sdk/resourcemanager/maintenance/armmaintenance/models.go index 3e47ce50647d..e24853bc5c22 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/models.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/models.go @@ -1,6 +1,3 @@ -//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. @@ -15,16 +12,16 @@ type ApplyUpdate struct { // Properties of the apply update Properties *ApplyUpdateProperties - // READ-ONLY; Fully qualified identifier of the resource + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Name of the resource + // READ-ONLY; The name of the resource Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY; Type of the resource + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -42,25 +39,25 @@ type ApplyUpdateProperties struct { // Configuration - Maintenance configuration record type type Configuration struct { - // Gets or sets location of the resource + // REQUIRED; The geo-location where the resource lives Location *string // Gets or sets properties of the resource Properties *ConfigurationProperties - // Gets or sets tags of the resource + // Resource tags. Tags map[string]*string - // READ-ONLY; Fully qualified identifier of the resource + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Name of the resource + // READ-ONLY; The name of the resource Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY; Type of the resource + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -72,16 +69,16 @@ type ConfigurationAssignment struct { // Properties of the configuration assignment Properties *ConfigurationAssignmentProperties - // READ-ONLY; Fully qualified identifier of the resource + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Name of the resource + // READ-ONLY; The name of the resource Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY; Type of the resource + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -142,6 +139,33 @@ type Error struct { Error *ErrorDetails } +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info any + + // READ-ONLY; The additional info type. + Type *string +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo + + // READ-ONLY; The error code. + Code *string + + // READ-ONLY; The error details. + Details []*ErrorDetail + + // READ-ONLY; The error message. + Message *string + + // READ-ONLY; The error target. + Target *string +} + // ErrorDetails - An error response details received from the Azure Maintenance service. type ErrorDetails struct { // Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. @@ -151,9 +175,16 @@ type ErrorDetails struct { Message *string } +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. +// (This also follows the OData error response format.). +type ErrorResponse struct { + // The error object. + Error *ErrorDetail +} + // InputLinuxParameters - Input properties for patching a Linux machine. type InputLinuxParameters struct { - // Classification category of patches to be patched + // Classification category of patches to be patched. Allowed values are 'Critical', 'Security', and 'Other'. ClassificationsToInclude []*string // Package names to be excluded for patching. @@ -178,7 +209,8 @@ type InputPatchConfiguration struct { // InputWindowsParameters - Input properties for patching a Windows machine. type InputWindowsParameters struct { - // Classification category of patches to be patched + // Classification category of patches to be patched. Allowed values are 'Critical', 'Security', 'UpdateRollup', 'FeaturePack', + // 'ServicePack', 'Definition', 'Tools', and 'Updates'. ClassificationsToInclude []*string // Exclude patches which need reboot @@ -193,18 +225,27 @@ type InputWindowsParameters struct { // ListApplyUpdate - Response for ApplyUpdate list type ListApplyUpdate struct { + // The link to the next page of items + NextLink *string + // The list of apply updates Value []*ApplyUpdate } // ListConfigurationAssignmentsResult - Response for ConfigurationAssignments list type ListConfigurationAssignmentsResult struct { + // The link to the next page of items + NextLink *string + // The list of configuration Assignments Value []*ConfigurationAssignment } // ListMaintenanceConfigurationsResult - Response for MaintenanceConfigurations list type ListMaintenanceConfigurationsResult struct { + // The link to the next page of items + NextLink *string + // The list of maintenance Configurations Value []*Configuration } @@ -215,57 +256,83 @@ type ListUpdatesResult struct { Value []*Update } -// Operation - Represents an operation returned by the GetOperations request +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API type Operation struct { - // Display name of the operation - Display *OperationInfo + // Localized display information for this particular operation. + Display *OperationDisplay - // Indicates whether the operation is a data action + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane + // operations. IsDataAction *bool - // Name of the 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 - // Origin of the operation - Origin *string - - // Properties of the operation - Properties any + // 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 } -// OperationInfo - Information about an operation -type OperationInfo struct { - // Description of the operation +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. Description *string - // Name of the operation + // 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 - // 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 - // Name of the resource type + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". Resource *string } -// OperationsListResult - Result of the List Operations operation -type OperationsListResult struct { - // A collection of 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 resource provider Value []*Operation } -// Resource - Definition of a Resource +// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a +// location +type ProxyResource struct { + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // 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 +} + +// Resource - Common fields that are returned in the response for all Azure Resource Manager resources type Resource struct { - // READ-ONLY; Fully qualified identifier of the resource + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string - // READ-ONLY; Name of the resource + // READ-ONLY; The name of the resource Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - // READ-ONLY; Type of the resource + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -305,6 +372,28 @@ type TagSettingsProperties struct { Tags map[string][]*string } +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' +// and a 'location' +type TrackedResource struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // 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 +} + // Update - Maintenance update on a resource type Update struct { // Duration of impact in seconds diff --git a/sdk/resourcemanager/maintenance/armmaintenance/models_serde.go b/sdk/resourcemanager/maintenance/armmaintenance/models_serde.go index e5d5e9b8d1c9..44a0a67b8e98 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/models_serde.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/models_serde.go @@ -1,6 +1,3 @@ -//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. @@ -343,6 +340,80 @@ func (e *Error) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "info", e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(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 "info": + err = unpopulate(val, "Info", &e.Info) + 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 ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) UnmarshalJSON(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 "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ErrorDetails. func (e ErrorDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -374,6 +445,33 @@ func (e *ErrorDetails) UnmarshalJSON(data []byte) error { 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 InputLinuxParameters. func (i InputLinuxParameters) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -486,6 +584,7 @@ func (i *InputWindowsParameters) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ListApplyUpdate. func (l ListApplyUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "nextLink", l.NextLink) populate(objectMap, "value", l.Value) return json.Marshal(objectMap) } @@ -499,6 +598,9 @@ func (l *ListApplyUpdate) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &l.NextLink) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &l.Value) delete(rawMsg, key) @@ -513,6 +615,7 @@ func (l *ListApplyUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ListConfigurationAssignmentsResult. func (l ListConfigurationAssignmentsResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "nextLink", l.NextLink) populate(objectMap, "value", l.Value) return json.Marshal(objectMap) } @@ -526,6 +629,9 @@ func (l *ListConfigurationAssignmentsResult) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &l.NextLink) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &l.Value) delete(rawMsg, key) @@ -540,6 +646,7 @@ func (l *ListConfigurationAssignmentsResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ListMaintenanceConfigurationsResult. func (l ListMaintenanceConfigurationsResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "nextLink", l.NextLink) populate(objectMap, "value", l.Value) return json.Marshal(objectMap) } @@ -553,6 +660,9 @@ func (l *ListMaintenanceConfigurationsResult) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &l.NextLink) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &l.Value) delete(rawMsg, key) @@ -594,11 +704,11 @@ func (l *ListUpdatesResult) 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) - populateAny(objectMap, "properties", o.Properties) return json.Marshal(objectMap) } @@ -611,6 +721,9 @@ 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) @@ -623,9 +736,6 @@ func (o *Operation) UnmarshalJSON(data []byte) error { case "origin": err = unpopulate(val, "Origin", &o.Origin) delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &o.Properties) - delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", o, err) @@ -634,8 +744,8 @@ func (o *Operation) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type OperationInfo. -func (o OperationInfo) 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) @@ -644,8 +754,8 @@ func (o OperationInfo) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationInfo. -func (o *OperationInfo) 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) @@ -673,15 +783,16 @@ func (o *OperationInfo) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type OperationsListResult. -func (o OperationsListResult) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) populate(objectMap, "value", o.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationsListResult. -func (o *OperationsListResult) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", o, err) @@ -689,6 +800,9 @@ func (o *OperationsListResult) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &o.Value) delete(rawMsg, key) @@ -700,6 +814,45 @@ func (o *OperationsListResult) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ProxyResource. +func (p ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyResource. +func (p *ProxyResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Resource. func (r Resource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -844,6 +997,53 @@ func (t *TagSettingsProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResource. +func (t *TrackedResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Update. func (u Update) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) diff --git a/sdk/resourcemanager/maintenance/armmaintenance/operations_client.go b/sdk/resourcemanager/maintenance/armmaintenance/operations_client.go index 6825ef26314c..f7faabe9617f 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/operations_client.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/operations_client.go @@ -1,6 +1,3 @@ -//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. @@ -37,28 +34,27 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO return client, nil } -// NewListPager - List the available operations supported by the Microsoft.Maintenance resource provider +// NewListPager - List the operations for the provider // // Generated from API version 2023-10-01-preview // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ More: func(page OperationsClientListResponse) bool { - return false + return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") - req, err := client.listCreateRequest(ctx, options) - if err != nil { - return OperationsClientListResponse{}, err + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) if err != nil { return OperationsClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OperationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, Tracer: client.internal.Tracer(), @@ -66,7 +62,7 @@ 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.Maintenance/operations" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { @@ -82,7 +78,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * // listHandleResponse handles the List response. func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { result := OperationsClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.OperationsListResult); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { return OperationsClientListResponse{}, err } return result, nil diff --git a/sdk/resourcemanager/maintenance/armmaintenance/operations_client_example_test.go b/sdk/resourcemanager/maintenance/armmaintenance/operations_client_example_test.go deleted file mode 100644 index 2d2c1910fa57..000000000000 --- a/sdk/resourcemanager/maintenance/armmaintenance/operations_client_example_test.go +++ /dev/null @@ -1,47 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armmaintenance_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/Operations_List.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationsListResult = armmaintenance.OperationsListResult{ - // Value: []*armmaintenance.Operation{ - // }, - // } - } -} diff --git a/sdk/resourcemanager/maintenance/armmaintenance/options.go b/sdk/resourcemanager/maintenance/armmaintenance/options.go index 41ff02f40317..50dcb46f303e 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/options.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/options.go @@ -1,6 +1,3 @@ -//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. @@ -81,12 +78,6 @@ type ConfigurationAssignmentsClientGetParentOptions struct { // placeholder for future optional parameters } -// ConfigurationAssignmentsClientListOptions contains the optional parameters for the ConfigurationAssignmentsClient.NewListPager -// method. -type ConfigurationAssignmentsClientListOptions struct { - // placeholder for future optional parameters -} - // ConfigurationAssignmentsClientListParentOptions contains the optional parameters for the ConfigurationAssignmentsClient.NewListParentPager // method. type ConfigurationAssignmentsClientListParentOptions struct { @@ -201,12 +192,12 @@ type ScheduledEventClientAcknowledgeOptions struct { // placeholder for future optional parameters } -// UpdatesClientListOptions contains the optional parameters for the UpdatesClient.NewListPager method. +// UpdatesClientListOptions contains the optional parameters for the UpdatesClient.List method. type UpdatesClientListOptions struct { // placeholder for future optional parameters } -// UpdatesClientListParentOptions contains the optional parameters for the UpdatesClient.NewListParentPager method. +// UpdatesClientListParentOptions contains the optional parameters for the UpdatesClient.ListParent method. type UpdatesClientListParentOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/maintenance/armmaintenance/publicmaintenanceconfigurations_client.go b/sdk/resourcemanager/maintenance/armmaintenance/publicmaintenanceconfigurations_client.go index 610b40e63fa0..b82cb15dc895 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/publicmaintenanceconfigurations_client.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/publicmaintenanceconfigurations_client.go @@ -1,6 +1,3 @@ -//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. @@ -47,7 +44,7 @@ func NewPublicMaintenanceConfigurationsClient(subscriptionID string, credential // If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceName - Maintenance Configuration Name +// - resourceName - The name of the MaintenanceConfiguration // - options - PublicMaintenanceConfigurationsClientGetOptions contains the optional parameters for the PublicMaintenanceConfigurationsClient.Get // method. func (client *PublicMaintenanceConfigurationsClient) Get(ctx context.Context, resourceName string, options *PublicMaintenanceConfigurationsClientGetOptions) (PublicMaintenanceConfigurationsClientGetResponse, error) { @@ -73,7 +70,7 @@ func (client *PublicMaintenanceConfigurationsClient) Get(ctx context.Context, re } // getCreateRequest creates the Get request. -func (client *PublicMaintenanceConfigurationsClient) getCreateRequest(ctx context.Context, resourceName string, options *PublicMaintenanceConfigurationsClientGetOptions) (*policy.Request, error) { +func (client *PublicMaintenanceConfigurationsClient) getCreateRequest(ctx context.Context, resourceName string, _ *PublicMaintenanceConfigurationsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/{resourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -111,21 +108,20 @@ func (client *PublicMaintenanceConfigurationsClient) getHandleResponse(resp *htt func (client *PublicMaintenanceConfigurationsClient) NewListPager(options *PublicMaintenanceConfigurationsClientListOptions) *runtime.Pager[PublicMaintenanceConfigurationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[PublicMaintenanceConfigurationsClientListResponse]{ More: func(page PublicMaintenanceConfigurationsClientListResponse) bool { - return false + return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *PublicMaintenanceConfigurationsClientListResponse) (PublicMaintenanceConfigurationsClientListResponse, error) { ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PublicMaintenanceConfigurationsClient.NewListPager") - req, err := client.listCreateRequest(ctx, options) - if err != nil { - return PublicMaintenanceConfigurationsClientListResponse{}, err + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) if err != nil { return PublicMaintenanceConfigurationsClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PublicMaintenanceConfigurationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, Tracer: client.internal.Tracer(), @@ -133,7 +129,7 @@ func (client *PublicMaintenanceConfigurationsClient) NewListPager(options *Publi } // listCreateRequest creates the List request. -func (client *PublicMaintenanceConfigurationsClient) listCreateRequest(ctx context.Context, options *PublicMaintenanceConfigurationsClientListOptions) (*policy.Request, error) { +func (client *PublicMaintenanceConfigurationsClient) listCreateRequest(ctx context.Context, _ *PublicMaintenanceConfigurationsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") diff --git a/sdk/resourcemanager/maintenance/armmaintenance/publicmaintenanceconfigurations_client_example_test.go b/sdk/resourcemanager/maintenance/armmaintenance/publicmaintenanceconfigurations_client_example_test.go deleted file mode 100644 index 9cc79cbac0b0..000000000000 --- a/sdk/resourcemanager/maintenance/armmaintenance/publicmaintenanceconfigurations_client_example_test.go +++ /dev/null @@ -1,100 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armmaintenance_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/PublicMaintenanceConfigurations_List.json -func ExamplePublicMaintenanceConfigurationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewPublicMaintenanceConfigurationsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ListMaintenanceConfigurationsResult = armmaintenance.ListMaintenanceConfigurationsResult{ - // Value: []*armmaintenance.Configuration{ - // { - // Name: to.Ptr("configuration1"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/configuration1"), - // Location: to.Ptr("westus2"), - // Properties: &armmaintenance.ConfigurationProperties{ - // MaintenanceScope: to.Ptr(armmaintenance.MaintenanceScopeSQLDB), - // MaintenanceWindow: &armmaintenance.Window{ - // Duration: to.Ptr("05:00:00"), - // ExpirationDateTime: to.Ptr("9999-12-31 00:00:00"), - // RecurEvery: to.Ptr("Week Saturday,Sunday"), - // StartDateTime: to.Ptr("2020-04-30 08:00:00"), - // TimeZone: to.Ptr("Pacific Standard Time"), - // }, - // Namespace: to.Ptr("Microsoft.Maintenance"), - // Visibility: to.Ptr(armmaintenance.VisibilityPublic), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/PublicMaintenanceConfigurations_GetForResource.json -func ExamplePublicMaintenanceConfigurationsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPublicMaintenanceConfigurationsClient().Get(ctx, "configuration1", 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.Configuration = armmaintenance.Configuration{ - // Name: to.Ptr("configuration1"), - // ID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/configuration1"), - // Location: to.Ptr("westus2"), - // Properties: &armmaintenance.ConfigurationProperties{ - // MaintenanceScope: to.Ptr(armmaintenance.MaintenanceScopeSQLDB), - // MaintenanceWindow: &armmaintenance.Window{ - // Duration: to.Ptr("05:00"), - // ExpirationDateTime: to.Ptr("9999-12-31 00:00"), - // RecurEvery: to.Ptr("2Weeks"), - // StartDateTime: to.Ptr("2020-04-30 08:00"), - // TimeZone: to.Ptr("Pacific Standard Time"), - // }, - // Namespace: to.Ptr("Microsoft.Maintenance"), - // Visibility: to.Ptr(armmaintenance.VisibilityPublic), - // }, - // } -} diff --git a/sdk/resourcemanager/maintenance/armmaintenance/responses.go b/sdk/resourcemanager/maintenance/armmaintenance/responses.go index 52f7df91cfc6..0e06bddf9e3b 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/responses.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/responses.go @@ -1,6 +1,3 @@ -//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. @@ -92,12 +89,6 @@ type ConfigurationAssignmentsClientListParentResponse struct { ListConfigurationAssignmentsResult } -// ConfigurationAssignmentsClientListResponse contains the response from method ConfigurationAssignmentsClient.NewListPager. -type ConfigurationAssignmentsClientListResponse struct { - // Response for ConfigurationAssignments list - ListConfigurationAssignmentsResult -} - // ConfigurationAssignmentsForResourceGroupClientCreateOrUpdateResponse contains the response from method ConfigurationAssignmentsForResourceGroupClient.CreateOrUpdate. type ConfigurationAssignmentsForResourceGroupClientCreateOrUpdateResponse struct { // Configuration Assignment @@ -190,8 +181,8 @@ type ConfigurationsForResourceGroupClientListResponse struct { // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { - // Result of the List Operations operation - OperationsListResult + // 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 } // PublicMaintenanceConfigurationsClientGetResponse contains the response from method PublicMaintenanceConfigurationsClient.Get. @@ -212,13 +203,13 @@ type ScheduledEventClientAcknowledgeResponse struct { ScheduledEventApproveResponse } -// UpdatesClientListParentResponse contains the response from method UpdatesClient.NewListParentPager. +// UpdatesClientListParentResponse contains the response from method UpdatesClient.ListParent. type UpdatesClientListParentResponse struct { // Response for Updates list ListUpdatesResult } -// UpdatesClientListResponse contains the response from method UpdatesClient.NewListPager. +// UpdatesClientListResponse contains the response from method UpdatesClient.List. type UpdatesClientListResponse struct { // Response for Updates list ListUpdatesResult diff --git a/sdk/resourcemanager/maintenance/armmaintenance/scheduledevent_client.go b/sdk/resourcemanager/maintenance/armmaintenance/scheduledevent_client.go index 2ad9c730ab8e..634e80a1f625 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/scheduledevent_client.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/scheduledevent_client.go @@ -1,6 +1,3 @@ -//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. @@ -76,7 +73,7 @@ func (client *ScheduledEventClient) Acknowledge(ctx context.Context, resourceGro } // acknowledgeCreateRequest creates the Acknowledge request. -func (client *ScheduledEventClient) acknowledgeCreateRequest(ctx context.Context, resourceGroupName string, resourceType string, resourceName string, scheduledEventID string, options *ScheduledEventClientAcknowledgeOptions) (*policy.Request, error) { +func (client *ScheduledEventClient) acknowledgeCreateRequest(ctx context.Context, resourceGroupName string, resourceType string, resourceName string, scheduledEventID string, _ *ScheduledEventClientAcknowledgeOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Compute/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/scheduledevents/{scheduledEventId}/acknowledge" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") diff --git a/sdk/resourcemanager/maintenance/armmaintenance/scheduledevent_client_example_test.go b/sdk/resourcemanager/maintenance/armmaintenance/scheduledevent_client_example_test.go deleted file mode 100644 index 539ee6a1d8a8..000000000000 --- a/sdk/resourcemanager/maintenance/armmaintenance/scheduledevent_client_example_test.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armmaintenance_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ScheduledEvents_Acknowledge.json -func ExampleScheduledEventClient_Acknowledge() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewScheduledEventClient().Acknowledge(ctx, "examplerg", "virtualMachines", "configuration1", "ad6d85cf-2c9e-4eec-9a1e-af3213cc0486", 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.ScheduledEventApproveResponse = armmaintenance.ScheduledEventApproveResponse{ - // Value: to.Ptr("Successfully Approved"), - // } -} diff --git a/sdk/resourcemanager/maintenance/armmaintenance/time_rfc3339.go b/sdk/resourcemanager/maintenance/armmaintenance/time_rfc3339.go index f0ce81b1898a..ec34b9470f5d 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/time_rfc3339.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/time_rfc3339.go @@ -1,6 +1,3 @@ -//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. @@ -60,6 +57,9 @@ func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } tzOffset := tzOffsetRegex.Match(data) hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") var layout string diff --git a/sdk/resourcemanager/maintenance/armmaintenance/updates_client.go b/sdk/resourcemanager/maintenance/armmaintenance/updates_client.go index bdf31b481247..8486708c12c8 100644 --- a/sdk/resourcemanager/maintenance/armmaintenance/updates_client.go +++ b/sdk/resourcemanager/maintenance/armmaintenance/updates_client.go @@ -1,6 +1,3 @@ -//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. @@ -43,40 +40,39 @@ func NewUpdatesClient(subscriptionID string, credential azcore.TokenCredential, return client, nil } -// NewListPager - Get updates to resources. +// List - Get updates to resources. +// If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource group name +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - providerName - Resource provider name // - resourceType - Resource type // - resourceName - Resource identifier -// - options - UpdatesClientListOptions contains the optional parameters for the UpdatesClient.NewListPager method. -func (client *UpdatesClient) NewListPager(resourceGroupName string, providerName string, resourceType string, resourceName string, options *UpdatesClientListOptions) *runtime.Pager[UpdatesClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[UpdatesClientListResponse]{ - More: func(page UpdatesClientListResponse) bool { - return false - }, - Fetcher: func(ctx context.Context, page *UpdatesClientListResponse) (UpdatesClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "UpdatesClient.NewListPager") - req, err := client.listCreateRequest(ctx, resourceGroupName, providerName, resourceType, resourceName, options) - if err != nil { - return UpdatesClientListResponse{}, err - } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return UpdatesClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return UpdatesClientListResponse{}, runtime.NewResponseError(resp) - } - return client.listHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) +// - options - UpdatesClientListOptions contains the optional parameters for the UpdatesClient.List method. +func (client *UpdatesClient) List(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, options *UpdatesClientListOptions) (UpdatesClientListResponse, error) { + var err error + const operationName = "UpdatesClient.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, resourceGroupName, providerName, resourceType, resourceName, options) + if err != nil { + return UpdatesClientListResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return UpdatesClientListResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return UpdatesClientListResponse{}, err + } + resp, err := client.listHandleResponse(httpResp) + return resp, err } // listCreateRequest creates the List request. -func (client *UpdatesClient) listCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, options *UpdatesClientListOptions) (*policy.Request, error) { +func (client *UpdatesClient) listCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceType string, resourceName string, _ *UpdatesClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -118,42 +114,41 @@ func (client *UpdatesClient) listHandleResponse(resp *http.Response) (UpdatesCli return result, nil } -// NewListParentPager - Get updates to resources. +// ListParent - Get updates to resources. +// If the operation fails it returns an *azcore.ResponseError type. // // Generated from API version 2023-10-01-preview -// - resourceGroupName - Resource group name +// - resourceGroupName - The name of the resource group. The name is case insensitive. // - providerName - Resource provider name // - resourceParentType - Resource parent type // - resourceParentName - Resource parent identifier // - resourceType - Resource type // - resourceName - Resource identifier -// - options - UpdatesClientListParentOptions contains the optional parameters for the UpdatesClient.NewListParentPager method. -func (client *UpdatesClient) NewListParentPager(resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, options *UpdatesClientListParentOptions) *runtime.Pager[UpdatesClientListParentResponse] { - return runtime.NewPager(runtime.PagingHandler[UpdatesClientListParentResponse]{ - More: func(page UpdatesClientListParentResponse) bool { - return false - }, - Fetcher: func(ctx context.Context, page *UpdatesClientListParentResponse) (UpdatesClientListParentResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "UpdatesClient.NewListParentPager") - req, err := client.listParentCreateRequest(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName, options) - if err != nil { - return UpdatesClientListParentResponse{}, err - } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return UpdatesClientListParentResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return UpdatesClientListParentResponse{}, runtime.NewResponseError(resp) - } - return client.listParentHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) +// - options - UpdatesClientListParentOptions contains the optional parameters for the UpdatesClient.ListParent method. +func (client *UpdatesClient) ListParent(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, options *UpdatesClientListParentOptions) (UpdatesClientListParentResponse, error) { + var err error + const operationName = "UpdatesClient.ListParent" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listParentCreateRequest(ctx, resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName, options) + if err != nil { + return UpdatesClientListParentResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return UpdatesClientListParentResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return UpdatesClientListParentResponse{}, err + } + resp, err := client.listParentHandleResponse(httpResp) + return resp, err } // listParentCreateRequest creates the ListParent request. -func (client *UpdatesClient) listParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, options *UpdatesClientListParentOptions) (*policy.Request, error) { +func (client *UpdatesClient) listParentCreateRequest(ctx context.Context, resourceGroupName string, providerName string, resourceParentType string, resourceParentName string, resourceType string, resourceName string, _ *UpdatesClientListParentOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") diff --git a/sdk/resourcemanager/maintenance/armmaintenance/updates_client_example_test.go b/sdk/resourcemanager/maintenance/armmaintenance/updates_client_example_test.go deleted file mode 100644 index e68e3b637187..000000000000 --- a/sdk/resourcemanager/maintenance/armmaintenance/updates_client_example_test.go +++ /dev/null @@ -1,94 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armmaintenance_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maintenance/armmaintenance" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/Updates_ListParent.json -func ExampleUpdatesClient_NewListParentPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUpdatesClient().NewListParentPager("examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", "virtualMachines", "1", 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.ListUpdatesResult = armmaintenance.ListUpdatesResult{ - // Value: []*armmaintenance.Update{ - // { - // ImpactDurationInSec: to.Ptr[int32](1440), - // ImpactType: to.Ptr(armmaintenance.ImpactType("Reboot")), - // MaintenanceScope: to.Ptr(armmaintenance.MaintenanceScopeResource), - // NotBefore: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-09T06:17:44.235Z"); return t}()), - // Properties: &armmaintenance.UpdateProperties{ - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1/virtualMachines/1"), - // }, - // Status: to.Ptr(armmaintenance.UpdateStatusPending), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/33c4457b1d13f83965f4fe3367dca4a6df898100/specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/Updates_List.json -func ExampleUpdatesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armmaintenance.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUpdatesClient().NewListPager("examplerg", "Microsoft.Compute", "virtualMachineScaleSets", "smdtest1", 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.ListUpdatesResult = armmaintenance.ListUpdatesResult{ - // Value: []*armmaintenance.Update{ - // { - // ImpactDurationInSec: to.Ptr[int32](1440), - // ImpactType: to.Ptr(armmaintenance.ImpactType("Reboot")), - // MaintenanceScope: to.Ptr(armmaintenance.MaintenanceScopeResource), - // NotBefore: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-09T06:17:44.235Z"); return t}()), - // Properties: &armmaintenance.UpdateProperties{ - // ResourceID: to.Ptr("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Compute/virtualMachineScaleSets/smdtest1"), - // }, - // Status: to.Ptr(armmaintenance.UpdateStatusPending), - // }}, - // } - } -}