diff --git a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/CHANGELOG.md b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/CHANGELOG.md index 8575db6b3af2..5eaded94277d 100644 --- a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/CHANGELOG.md +++ b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 0.6.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 0.5.0 (2022-05-18) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 0.5.0, which contains breaking changes. diff --git a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/README.md b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/README.md index cf3e5e87bc43..9eaa9f050cab 100644 --- a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/README.md +++ b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Edge Order Partner modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Edge Order Partner module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armedgeorderpartner.NewAPISClient(, cred, nil) +clientFactory, err := armedgeorderpartner.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armedgeorderpartner.NewAPISClient(, cred, &options) +clientFactory, err := armedgeorderpartner.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewAPISClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/zz_generated_apis_client.go b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/apis_client.go similarity index 83% rename from sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/zz_generated_apis_client.go rename to sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/apis_client.go index 4d24b23c02c5..bfe7dee92c40 100644 --- a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/zz_generated_apis_client.go +++ b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/apis_client.go @@ -5,6 +5,7 @@ // 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 armedgeorderpartner @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,40 +24,31 @@ import ( // APISClient contains the methods for the EdgeOrderPartnerAPIS group. // Don't use this type directly, use NewAPISClient() instead. type APISClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAPISClient creates a new instance of APISClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAPISClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*APISClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".APISClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &APISClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListOperationsPartnerPager - This method gets all the operations that are exposed for customer. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-01-preview -// options - APISClientListOperationsPartnerOptions contains the optional parameters for the APISClient.ListOperationsPartner -// method. +// - options - APISClientListOperationsPartnerOptions contains the optional parameters for the APISClient.NewListOperationsPartnerPager +// method. func (client *APISClient) NewListOperationsPartnerPager(options *APISClientListOperationsPartnerOptions) *runtime.Pager[APISClientListOperationsPartnerResponse] { return runtime.NewPager(runtime.PagingHandler[APISClientListOperationsPartnerResponse]{ More: func(page APISClientListOperationsPartnerResponse) bool { @@ -75,7 +65,7 @@ func (client *APISClient) NewListOperationsPartnerPager(options *APISClientListO if err != nil { return APISClientListOperationsPartnerResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return APISClientListOperationsPartnerResponse{}, err } @@ -90,7 +80,7 @@ func (client *APISClient) NewListOperationsPartnerPager(options *APISClientListO // listOperationsPartnerCreateRequest creates the ListOperationsPartner request. func (client *APISClient) listOperationsPartnerCreateRequest(ctx context.Context, options *APISClientListOperationsPartnerOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.EdgeOrderPartner/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -112,34 +102,36 @@ func (client *APISClient) listOperationsPartnerHandleResponse(resp *http.Respons // BeginManageInventoryMetadata - API for updating inventory metadata and inventory configuration // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-01-preview -// familyIdentifier - Unique identifier for the product family -// location - The location of the resource -// serialNumber - The serial number of the device -// manageInventoryMetadataRequest - Updates inventory metadata and inventory configuration -// options - APISClientBeginManageInventoryMetadataOptions contains the optional parameters for the APISClient.BeginManageInventoryMetadata -// method. +// - familyIdentifier - Unique identifier for the product family +// - location - The location of the resource +// - serialNumber - The serial number of the device +// - manageInventoryMetadataRequest - Updates inventory metadata and inventory configuration +// - options - APISClientBeginManageInventoryMetadataOptions contains the optional parameters for the APISClient.BeginManageInventoryMetadata +// method. func (client *APISClient) BeginManageInventoryMetadata(ctx context.Context, familyIdentifier string, location string, serialNumber string, manageInventoryMetadataRequest ManageInventoryMetadataRequest, options *APISClientBeginManageInventoryMetadataOptions) (*runtime.Poller[APISClientManageInventoryMetadataResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.manageInventoryMetadata(ctx, familyIdentifier, location, serialNumber, manageInventoryMetadataRequest, options) if err != nil { return nil, err } - return runtime.NewPoller[APISClientManageInventoryMetadataResponse](resp, client.pl, nil) + return runtime.NewPoller[APISClientManageInventoryMetadataResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[APISClientManageInventoryMetadataResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[APISClientManageInventoryMetadataResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // ManageInventoryMetadata - API for updating inventory metadata and inventory configuration // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-01-preview func (client *APISClient) manageInventoryMetadata(ctx context.Context, familyIdentifier string, location string, serialNumber string, manageInventoryMetadataRequest ManageInventoryMetadataRequest, options *APISClientBeginManageInventoryMetadataOptions) (*http.Response, error) { req, err := client.manageInventoryMetadataCreateRequest(ctx, familyIdentifier, location, serialNumber, manageInventoryMetadataRequest, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -168,7 +160,7 @@ func (client *APISClient) manageInventoryMetadataCreateRequest(ctx context.Conte return nil, errors.New("parameter serialNumber cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serialNumber}", url.PathEscape(serialNumber)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -181,18 +173,19 @@ func (client *APISClient) manageInventoryMetadataCreateRequest(ctx context.Conte // ManageLink - API for linking management resource with inventory // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-01-preview -// familyIdentifier - Unique identifier for the product family -// location - The location of the resource -// serialNumber - The serial number of the device -// manageLinkRequest - Links the management resource to the inventory -// options - APISClientManageLinkOptions contains the optional parameters for the APISClient.ManageLink method. +// - familyIdentifier - Unique identifier for the product family +// - location - The location of the resource +// - serialNumber - The serial number of the device +// - manageLinkRequest - Links the management resource to the inventory +// - options - APISClientManageLinkOptions contains the optional parameters for the APISClient.ManageLink method. func (client *APISClient) ManageLink(ctx context.Context, familyIdentifier string, location string, serialNumber string, manageLinkRequest ManageLinkRequest, options *APISClientManageLinkOptions) (APISClientManageLinkResponse, error) { req, err := client.manageLinkCreateRequest(ctx, familyIdentifier, location, serialNumber, manageLinkRequest, options) if err != nil { return APISClientManageLinkResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return APISClientManageLinkResponse{}, err } @@ -221,7 +214,7 @@ func (client *APISClient) manageLinkCreateRequest(ctx context.Context, familyIde return nil, errors.New("parameter serialNumber cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{serialNumber}", url.PathEscape(serialNumber)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -233,10 +226,11 @@ func (client *APISClient) manageLinkCreateRequest(ctx context.Context, familyIde } // NewSearchInventoriesPager - API for Search inventories -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-12-01-preview -// searchInventoriesRequest - Searches inventories with the given filters and returns in the form of a list -// options - APISClientSearchInventoriesOptions contains the optional parameters for the APISClient.SearchInventories method. +// - searchInventoriesRequest - Searches inventories with the given filters and returns in the form of a list +// - options - APISClientSearchInventoriesOptions contains the optional parameters for the APISClient.NewSearchInventoriesPager +// method. func (client *APISClient) NewSearchInventoriesPager(searchInventoriesRequest SearchInventoriesRequest, options *APISClientSearchInventoriesOptions) *runtime.Pager[APISClientSearchInventoriesResponse] { return runtime.NewPager(runtime.PagingHandler[APISClientSearchInventoriesResponse]{ More: func(page APISClientSearchInventoriesResponse) bool { @@ -253,7 +247,7 @@ func (client *APISClient) NewSearchInventoriesPager(searchInventoriesRequest Sea if err != nil { return APISClientSearchInventoriesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return APISClientSearchInventoriesResponse{}, err } @@ -272,7 +266,7 @@ func (client *APISClient) searchInventoriesCreateRequest(ctx context.Context, se return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/apis_client_example_test.go b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/apis_client_example_test.go new file mode 100644 index 000000000000..af461f47bfc6 --- /dev/null +++ b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/apis_client_example_test.go @@ -0,0 +1,290 @@ +//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 armedgeorderpartner_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/edgeorderpartner/armedgeorderpartner" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorderpartner/resource-manager/Microsoft.EdgeOrderPartner/preview/2020-12-01-preview/examples/ListOperationsPartner.json +func ExampleAPISClient_NewListOperationsPartnerPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorderpartner.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAPISClient().NewListOperationsPartnerPager(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.OperationListResult = armedgeorderpartner.OperationListResult{ + // Value: []*armedgeorderpartner.Operation{ + // { + // Name: to.Ptr("Microsoft.EdgeOrderPartner/operations/read"), + // Display: &armedgeorderpartner.OperationDisplay{ + // Description: to.Ptr("List or get the Operations"), + // Operation: to.Ptr("List or Get Operations"), + // Provider: to.Ptr("Edge Ordering"), + // Resource: to.Ptr("Operations"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr(armedgeorderpartner.OriginUser), + // }, + // { + // Name: to.Ptr("Microsoft.EdgeOrderPartner/searchInventories/action"), + // Display: &armedgeorderpartner.OperationDisplay{ + // Provider: to.Ptr("Edge Ordering"), + // Resource: to.Ptr("ArmApiRes_Microsoft.EdgeOrderPartner"), + // }, + // IsDataAction: to.Ptr(true), + // Origin: to.Ptr(armedgeorderpartner.OriginUser), + // }, + // { + // Name: to.Ptr("Microsoft.EdgeOrderPartner/locations/productFamilies/inventories/manageLink/action"), + // Display: &armedgeorderpartner.OperationDisplay{ + // Provider: to.Ptr("Edge Ordering"), + // Resource: to.Ptr("ArmApiRes_inventories"), + // }, + // IsDataAction: to.Ptr(true), + // Origin: to.Ptr(armedgeorderpartner.OriginUser), + // }, + // { + // Name: to.Ptr("Microsoft.EdgeOrderPartner/locations/productFamilies/inventories/manageInventoryMetadata/action"), + // Display: &armedgeorderpartner.OperationDisplay{ + // Provider: to.Ptr("Edge Ordering"), + // Resource: to.Ptr("ArmApiRes_inventories"), + // }, + // IsDataAction: to.Ptr(true), + // Origin: to.Ptr(armedgeorderpartner.OriginUser), + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorderpartner/resource-manager/Microsoft.EdgeOrderPartner/preview/2020-12-01-preview/examples/ManageInventoryMetadata.json +func ExampleAPISClient_BeginManageInventoryMetadata() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorderpartner.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAPISClient().BeginManageInventoryMetadata(ctx, "AzureStackEdge", "westus", "SerialNumber1", armedgeorderpartner.ManageInventoryMetadataRequest{ + ConfigurationOnDevice: &armedgeorderpartner.ConfigurationOnDevice{ + ConfigurationIdentifier: to.Ptr("EdgeP_High"), + }, + InventoryMetadata: to.Ptr("InventoryMetadata"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorderpartner/resource-manager/Microsoft.EdgeOrderPartner/preview/2020-12-01-preview/examples/ManageLink.json +func ExampleAPISClient_ManageLink() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorderpartner.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewAPISClient().ManageLink(ctx, "AzureStackEdge", "westus", "SerialNumber1", armedgeorderpartner.ManageLinkRequest{ + ManagementResourceArmID: to.Ptr("/subscriptions/c783ea86-c85c-4175-b76d-3992656af50d/resourceGroups/EdgeTestRG/providers/Microsoft.DataBoxEdge/DataBoxEdgeDevices/TestEdgeDeviceName1"), + Operation: to.Ptr(armedgeorderpartner.ManageLinkOperationLink), + TenantID: to.Ptr("a783ea86-c85c-4175-b76d-3992656af50d"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorderpartner/resource-manager/Microsoft.EdgeOrderPartner/preview/2020-12-01-preview/examples/SearchInventories.json +func ExampleAPISClient_NewSearchInventoriesPager_searchInventories() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorderpartner.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAPISClient().NewSearchInventoriesPager(armedgeorderpartner.SearchInventoriesRequest{ + FamilyIdentifier: to.Ptr("AzureStackEdge"), + SerialNumber: to.Ptr("SerialNumber1"), + }, 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.PartnerInventoryList = armedgeorderpartner.PartnerInventoryList{ + // Value: []*armedgeorderpartner.PartnerInventory{ + // { + // Properties: &armedgeorderpartner.InventoryProperties{ + // Configuration: &armedgeorderpartner.ConfigurationData{ + // ConfigurationIdentifier: to.Ptr("EdgeP_Base"), + // ConfigurationIdentifierOnDevice: to.Ptr("EdgeP_High"), + // FamilyIdentifier: to.Ptr("AzureStackEdge"), + // ProductIdentifier: to.Ptr("AzureStackEdgeProGPU"), + // ProductLineIdentifier: to.Ptr("AzureStackEdgePL"), + // }, + // Inventory: &armedgeorderpartner.InventoryData{ + // Location: to.Ptr("Rack"), + // RegistrationAllowed: to.Ptr(true), + // Status: to.Ptr("Healthy"), + // }, + // Location: to.Ptr("westus"), + // ManagementResource: &armedgeorderpartner.ManagementResourceData{ + // ArmID: to.Ptr("/subscriptions/c783ea86-c85c-4175-b76d-3992656af50d/resourceGroups/EdgeTestRG/providers/Microsoft.DataBoxEdge/DataBoxEdgeDevices/TestEdgeDeviceName1"), + // TenantID: to.Ptr("a783ea86-c85c-4175-b76d-3992656af50d"), + // }, + // OrderItem: &armedgeorderpartner.OrderItemData{ + // ArmID: to.Ptr("/subscriptions/b783ea86-c85c-4175-b76d-3992656af50d/resourceGroups/TestRG/providers/Microsoft.EdgeOrder/orders/TestOrderName1"), + // OrderItemType: to.Ptr(armedgeorderpartner.OrderItemTypeRental), + // }, + // SerialNumber: to.Ptr("SerialNumber1"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorderpartner/resource-manager/Microsoft.EdgeOrderPartner/preview/2020-12-01-preview/examples/SearchInventoriesDetails.json +func ExampleAPISClient_NewSearchInventoriesPager_searchInventoriesDetails() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armedgeorderpartner.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAPISClient().NewSearchInventoriesPager(armedgeorderpartner.SearchInventoriesRequest{ + FamilyIdentifier: to.Ptr("AzureStackEdge"), + SerialNumber: to.Ptr("SerialNumber1"), + }, 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.PartnerInventoryList = armedgeorderpartner.PartnerInventoryList{ + // Value: []*armedgeorderpartner.PartnerInventory{ + // { + // Properties: &armedgeorderpartner.InventoryProperties{ + // Configuration: &armedgeorderpartner.ConfigurationData{ + // ConfigurationIdentifier: to.Ptr("EdgeP_Base"), + // ConfigurationIdentifierOnDevice: to.Ptr("EdgeP_High"), + // FamilyIdentifier: to.Ptr("AzureStackEdge"), + // ProductIdentifier: to.Ptr("AzureStackEdgeProGPU"), + // ProductLineIdentifier: to.Ptr("AzureStackEdgePL"), + // }, + // Inventory: &armedgeorderpartner.InventoryData{ + // Location: to.Ptr("Rack"), + // RegistrationAllowed: to.Ptr(true), + // Status: to.Ptr("Healthy"), + // }, + // Location: to.Ptr("westus"), + // ManagementResource: &armedgeorderpartner.ManagementResourceData{ + // ArmID: to.Ptr("/subscriptions/c783ea86-c85c-4175-b76d-3992656af50d/resourceGroups/EdgeTestRG/providers/Microsoft.DataBoxEdge/DataBoxEdgeDevices/TestEdgeDeviceName1"), + // TenantID: to.Ptr("a783ea86-c85c-4175-b76d-3992656af50d"), + // }, + // OrderItem: &armedgeorderpartner.OrderItemData{ + // ArmID: to.Ptr("/subscriptions/b783ea86-c85c-4175-b76d-3992656af50d/resourceGroups/TestRG/providers/Microsoft.EdgeOrder/orders/TestOrderName1"), + // OrderItemType: to.Ptr(armedgeorderpartner.OrderItemTypeRental), + // }, + // SerialNumber: to.Ptr("SerialNumber1"), + // Details: &armedgeorderpartner.InventoryAdditionalDetails{ + // Billing: &armedgeorderpartner.BillingDetails{ + // BillingType: to.Ptr("Pav2"), + // Status: to.Ptr("InProgress"), + // }, + // Configuration: &armedgeorderpartner.ConfigurationDetails{ + // Specifications: []*armedgeorderpartner.SpecificationDetails{ + // { + // Name: to.Ptr("Cores"), + // Value: to.Ptr("24"), + // }, + // { + // Name: to.Ptr("Memory"), + // Value: to.Ptr("128 GB"), + // }, + // { + // Name: to.Ptr("Storage"), + // Value: to.Ptr("~8 TB"), + // }}, + // }, + // Inventory: &armedgeorderpartner.AdditionalInventoryDetails{ + // AdditionalData: map[string]*string{ + // "ManuacturingYear": to.Ptr("2020"), + // "SourceCountry": to.Ptr("USA"), + // }, + // }, + // InventoryMetadata: to.Ptr("This is currently in Japan"), + // InventorySecrets: map[string]*string{ + // "PublicCert": to.Ptr(""), + // }, + // OrderItem: &armedgeorderpartner.AdditionalOrderItemDetails{ + // Status: &armedgeorderpartner.StageDetails{ + // DisplayName: to.Ptr("Delivered - Succeeded"), + // StageName: to.Ptr(armedgeorderpartner.StageNameDelivered), + // StageStatus: to.Ptr(armedgeorderpartner.StageStatusSucceeded), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-07T10:50:36.3341513+05:30"); return t}()), + // }, + // Subscription: &armedgeorderpartner.SubscriptionDetails{ + // ID: to.Ptr("b783ea86-c85c-4175-b76d-3992656af50d"), + // QuotaID: to.Ptr("Internal_2014-09-01"), + // State: to.Ptr("Registered"), + // }, + // }, + // }, + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/autorest.md b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/autorest.md index b8955c8bdb05..6c9adf5866a3 100644 --- a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/autorest.md +++ b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorderpartner/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/edgeorderpartner/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.5.0 +module-version: 0.6.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/client_factory.go b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/client_factory.go new file mode 100644 index 000000000000..b9d2d8d5f507 --- /dev/null +++ b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/client_factory.go @@ -0,0 +1,44 @@ +//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 armedgeorderpartner + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewAPISClient() *APISClient { + subClient, _ := NewAPISClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/zz_generated_constants.go b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/constants.go similarity index 99% rename from sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/zz_generated_constants.go rename to sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/constants.go index 22a1af404091..0bd5b612c3a8 100644 --- a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/zz_generated_constants.go +++ b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/constants.go @@ -5,12 +5,13 @@ // 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 armedgeorderpartner const ( moduleName = "armedgeorderpartner" - moduleVersion = "v0.5.0" + moduleVersion = "v0.6.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. diff --git a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/go.mod b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/go.mod index 6198aefa7a6b..de8a3f91d6e7 100644 --- a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/go.mod +++ b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/edgeorderpartner/ar go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/go.sum b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/go.sum +++ b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/zz_generated_models.go b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/models.go similarity index 95% rename from sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/zz_generated_models.go rename to sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/models.go index e0651fed0936..060d432b5869 100644 --- a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/zz_generated_models.go +++ b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/models.go @@ -5,6 +5,7 @@ // 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 armedgeorderpartner @@ -17,7 +18,8 @@ type APISClientBeginManageInventoryMetadataOptions struct { ResumeToken string } -// APISClientListOperationsPartnerOptions contains the optional parameters for the APISClient.ListOperationsPartner method. +// APISClientListOperationsPartnerOptions contains the optional parameters for the APISClient.NewListOperationsPartnerPager +// method. type APISClientListOperationsPartnerOptions struct { // placeholder for future optional parameters } @@ -27,15 +29,15 @@ type APISClientManageLinkOptions struct { // placeholder for future optional parameters } -// APISClientSearchInventoriesOptions contains the optional parameters for the APISClient.SearchInventories method. +// APISClientSearchInventoriesOptions contains the optional parameters for the APISClient.NewSearchInventoriesPager method. type APISClientSearchInventoriesOptions struct { // placeholder for future optional parameters } type AdditionalErrorInfo struct { // Anything - Info interface{} `json:"info,omitempty"` - Type *string `json:"type,omitempty"` + Info any `json:"info,omitempty"` + Type *string `json:"type,omitempty"` } // AdditionalInventoryDetails - Contains additional data about inventory in dictionary format @@ -62,18 +64,6 @@ type BillingDetails struct { Status *string `json:"status,omitempty" azure:"ro"` } -type CloudError struct { - Code *string `json:"code,omitempty"` - Message *string `json:"message,omitempty"` - Target *string `json:"target,omitempty"` - - // READ-ONLY - AdditionalInfo []*AdditionalErrorInfo `json:"additionalInfo,omitempty" azure:"ro"` - - // READ-ONLY - Details []*CloudError `json:"details,omitempty" azure:"ro"` -} - // ConfigurationData - Contains information about inventory configuration type ConfigurationData struct { // READ-ONLY; Configuration identifier of inventory @@ -108,7 +98,7 @@ type ConfigurationOnDevice struct { // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. - Info interface{} `json:"info,omitempty" azure:"ro"` + Info any `json:"info,omitempty" azure:"ro"` // READ-ONLY; The additional info type. Type *string `json:"type,omitempty" azure:"ro"` diff --git a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/models_serde.go b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/models_serde.go new file mode 100644 index 000000000000..ad6786d39c67 --- /dev/null +++ b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/models_serde.go @@ -0,0 +1,923 @@ +//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 armedgeorderpartner + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AdditionalErrorInfo. +func (a AdditionalErrorInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "info", &a.Info) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AdditionalErrorInfo. +func (a *AdditionalErrorInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &a.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AdditionalInventoryDetails. +func (a AdditionalInventoryDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalData", a.AdditionalData) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AdditionalInventoryDetails. +func (a *AdditionalInventoryDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalData": + err = unpopulate(val, "AdditionalData", &a.AdditionalData) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AdditionalOrderItemDetails. +func (a AdditionalOrderItemDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "status", a.Status) + populate(objectMap, "subscription", a.Subscription) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AdditionalOrderItemDetails. +func (a *AdditionalOrderItemDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "status": + err = unpopulate(val, "Status", &a.Status) + delete(rawMsg, key) + case "subscription": + err = unpopulate(val, "Subscription", &a.Subscription) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BillingDetails. +func (b BillingDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "billingType", b.BillingType) + populate(objectMap, "status", b.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BillingDetails. +func (b *BillingDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingType": + err = unpopulate(val, "BillingType", &b.BillingType) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &b.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ConfigurationData. +func (c ConfigurationData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "configurationIdentifier", c.ConfigurationIdentifier) + populate(objectMap, "configurationIdentifierOnDevice", c.ConfigurationIdentifierOnDevice) + populate(objectMap, "familyIdentifier", c.FamilyIdentifier) + populate(objectMap, "productIdentifier", c.ProductIdentifier) + populate(objectMap, "productLineIdentifier", c.ProductLineIdentifier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigurationData. +func (c *ConfigurationData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "configurationIdentifier": + err = unpopulate(val, "ConfigurationIdentifier", &c.ConfigurationIdentifier) + delete(rawMsg, key) + case "configurationIdentifierOnDevice": + err = unpopulate(val, "ConfigurationIdentifierOnDevice", &c.ConfigurationIdentifierOnDevice) + delete(rawMsg, key) + case "familyIdentifier": + err = unpopulate(val, "FamilyIdentifier", &c.FamilyIdentifier) + delete(rawMsg, key) + case "productIdentifier": + err = unpopulate(val, "ProductIdentifier", &c.ProductIdentifier) + delete(rawMsg, key) + case "productLineIdentifier": + err = unpopulate(val, "ProductLineIdentifier", &c.ProductLineIdentifier) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ConfigurationDetails. +func (c ConfigurationDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "specifications", c.Specifications) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigurationDetails. +func (c *ConfigurationDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "specifications": + err = unpopulate(val, "Specifications", &c.Specifications) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ConfigurationOnDevice. +func (c ConfigurationOnDevice) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "configurationIdentifier", c.ConfigurationIdentifier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigurationOnDevice. +func (c *ConfigurationOnDevice) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "configurationIdentifier": + err = unpopulate(val, "ConfigurationIdentifier", &c.ConfigurationIdentifier) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(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 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 InventoryAdditionalDetails. +func (i InventoryAdditionalDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "billing", i.Billing) + populate(objectMap, "configuration", i.Configuration) + populate(objectMap, "inventory", i.Inventory) + populate(objectMap, "inventoryMetadata", i.InventoryMetadata) + populate(objectMap, "inventorySecrets", i.InventorySecrets) + populate(objectMap, "orderItem", i.OrderItem) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InventoryAdditionalDetails. +func (i *InventoryAdditionalDetails) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billing": + err = unpopulate(val, "Billing", &i.Billing) + delete(rawMsg, key) + case "configuration": + err = unpopulate(val, "Configuration", &i.Configuration) + delete(rawMsg, key) + case "inventory": + err = unpopulate(val, "Inventory", &i.Inventory) + delete(rawMsg, key) + case "inventoryMetadata": + err = unpopulate(val, "InventoryMetadata", &i.InventoryMetadata) + delete(rawMsg, key) + case "inventorySecrets": + err = unpopulate(val, "InventorySecrets", &i.InventorySecrets) + delete(rawMsg, key) + case "orderItem": + err = unpopulate(val, "OrderItem", &i.OrderItem) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type InventoryData. +func (i InventoryData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "location", i.Location) + populate(objectMap, "registrationAllowed", i.RegistrationAllowed) + populate(objectMap, "status", i.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InventoryData. +func (i *InventoryData) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "location": + err = unpopulate(val, "Location", &i.Location) + delete(rawMsg, key) + case "registrationAllowed": + err = unpopulate(val, "RegistrationAllowed", &i.RegistrationAllowed) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &i.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type InventoryProperties. +func (i InventoryProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "configuration", i.Configuration) + populate(objectMap, "details", i.Details) + populate(objectMap, "inventory", i.Inventory) + populate(objectMap, "location", i.Location) + populate(objectMap, "managementResource", i.ManagementResource) + populate(objectMap, "orderItem", i.OrderItem) + populate(objectMap, "serialNumber", i.SerialNumber) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InventoryProperties. +func (i *InventoryProperties) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "configuration": + err = unpopulate(val, "Configuration", &i.Configuration) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &i.Details) + delete(rawMsg, key) + case "inventory": + err = unpopulate(val, "Inventory", &i.Inventory) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &i.Location) + delete(rawMsg, key) + case "managementResource": + err = unpopulate(val, "ManagementResource", &i.ManagementResource) + delete(rawMsg, key) + case "orderItem": + err = unpopulate(val, "OrderItem", &i.OrderItem) + delete(rawMsg, key) + case "serialNumber": + err = unpopulate(val, "SerialNumber", &i.SerialNumber) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManageInventoryMetadataRequest. +func (m ManageInventoryMetadataRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "configurationOnDevice", m.ConfigurationOnDevice) + populate(objectMap, "inventoryMetadata", m.InventoryMetadata) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManageInventoryMetadataRequest. +func (m *ManageInventoryMetadataRequest) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "configurationOnDevice": + err = unpopulate(val, "ConfigurationOnDevice", &m.ConfigurationOnDevice) + delete(rawMsg, key) + case "inventoryMetadata": + err = unpopulate(val, "InventoryMetadata", &m.InventoryMetadata) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManageLinkRequest. +func (m ManageLinkRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "managementResourceArmId", m.ManagementResourceArmID) + populate(objectMap, "operation", m.Operation) + populate(objectMap, "tenantId", m.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManageLinkRequest. +func (m *ManageLinkRequest) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "managementResourceArmId": + err = unpopulate(val, "ManagementResourceArmID", &m.ManagementResourceArmID) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &m.Operation) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &m.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagementResourceData. +func (m ManagementResourceData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "armId", m.ArmID) + populate(objectMap, "tenantId", m.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagementResourceData. +func (m *ManagementResourceData) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "armId": + err = unpopulate(val, "ArmID", &m.ArmID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &m.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// 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) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OrderItemData. +func (o OrderItemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "armId", o.ArmID) + populate(objectMap, "orderItemType", o.OrderItemType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrderItemData. +func (o *OrderItemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "armId": + err = unpopulate(val, "ArmID", &o.ArmID) + delete(rawMsg, key) + case "orderItemType": + err = unpopulate(val, "OrderItemType", &o.OrderItemType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PartnerInventory. +func (p PartnerInventory) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PartnerInventory. +func (p *PartnerInventory) 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 "properties": + err = unpopulate(val, "Properties", &p.Properties) + 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 PartnerInventoryList. +func (p PartnerInventoryList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PartnerInventoryList. +func (p *PartnerInventoryList) 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 "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + 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 SearchInventoriesRequest. +func (s SearchInventoriesRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "familyIdentifier", s.FamilyIdentifier) + populate(objectMap, "serialNumber", s.SerialNumber) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SearchInventoriesRequest. +func (s *SearchInventoriesRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "familyIdentifier": + err = unpopulate(val, "FamilyIdentifier", &s.FamilyIdentifier) + delete(rawMsg, key) + case "serialNumber": + err = unpopulate(val, "SerialNumber", &s.SerialNumber) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SpecificationDetails. +func (s SpecificationDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", s.Name) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SpecificationDetails. +func (s *SpecificationDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StageDetails. +func (s StageDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", s.DisplayName) + populate(objectMap, "stageName", s.StageName) + populate(objectMap, "stageStatus", s.StageStatus) + populateTimeRFC3339(objectMap, "startTime", s.StartTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StageDetails. +func (s *StageDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &s.DisplayName) + delete(rawMsg, key) + case "stageName": + err = unpopulate(val, "StageName", &s.StageName) + delete(rawMsg, key) + case "stageStatus": + err = unpopulate(val, "StageStatus", &s.StageStatus) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &s.StartTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionDetails. +func (s SubscriptionDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "quotaId", s.QuotaID) + populate(objectMap, "state", s.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionDetails. +func (s *SubscriptionDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "quotaId": + err = unpopulate(val, "QuotaID", &s.QuotaID) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &s.State) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/zz_generated_response_types.go b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/response_types.go similarity index 85% rename from sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/zz_generated_response_types.go rename to sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/response_types.go index e2367fae51ed..1cc168609046 100644 --- a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/zz_generated_response_types.go +++ b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/response_types.go @@ -5,15 +5,16 @@ // 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 armedgeorderpartner -// APISClientListOperationsPartnerResponse contains the response from method APISClient.ListOperationsPartner. +// APISClientListOperationsPartnerResponse contains the response from method APISClient.NewListOperationsPartnerPager. type APISClientListOperationsPartnerResponse struct { OperationListResult } -// APISClientManageInventoryMetadataResponse contains the response from method APISClient.ManageInventoryMetadata. +// APISClientManageInventoryMetadataResponse contains the response from method APISClient.BeginManageInventoryMetadata. type APISClientManageInventoryMetadataResponse struct { // placeholder for future response values } @@ -23,7 +24,7 @@ type APISClientManageLinkResponse struct { // placeholder for future response values } -// APISClientSearchInventoriesResponse contains the response from method APISClient.SearchInventories. +// APISClientSearchInventoriesResponse contains the response from method APISClient.NewSearchInventoriesPager. type APISClientSearchInventoriesResponse struct { PartnerInventoryList } diff --git a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/zz_generated_time_rfc3339.go b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/time_rfc3339.go index d7c37ede4562..3359237bc6d1 100644 --- a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/time_rfc3339.go @@ -5,6 +5,7 @@ // 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 armedgeorderpartner @@ -61,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/ze_generated_example_edgeorderpartnerapis_client_test.go b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/ze_generated_example_edgeorderpartnerapis_client_test.go deleted file mode 100644 index c0603a7a624f..000000000000 --- a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/ze_generated_example_edgeorderpartnerapis_client_test.go +++ /dev/null @@ -1,127 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armedgeorderpartner_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/edgeorderpartner/armedgeorderpartner" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/edgeorderpartner/resource-manager/Microsoft.EdgeOrderPartner/preview/2020-12-01-preview/examples/ListOperationsPartner.json -func ExampleAPISClient_NewListOperationsPartnerPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorderpartner.NewAPISClient("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListOperationsPartnerPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/edgeorderpartner/resource-manager/Microsoft.EdgeOrderPartner/preview/2020-12-01-preview/examples/ManageInventoryMetadata.json -func ExampleAPISClient_BeginManageInventoryMetadata() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorderpartner.NewAPISClient("b783ea86-c85c-4175-b76d-3992656af50d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginManageInventoryMetadata(ctx, - "AzureStackEdge", - "westus", - "SerialNumber1", - armedgeorderpartner.ManageInventoryMetadataRequest{ - ConfigurationOnDevice: &armedgeorderpartner.ConfigurationOnDevice{ - ConfigurationIdentifier: to.Ptr("EdgeP_High"), - }, - InventoryMetadata: to.Ptr("InventoryMetadata"), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/edgeorderpartner/resource-manager/Microsoft.EdgeOrderPartner/preview/2020-12-01-preview/examples/ManageLink.json -func ExampleAPISClient_ManageLink() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorderpartner.NewAPISClient("b783ea86-c85c-4175-b76d-3992656af50d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.ManageLink(ctx, - "AzureStackEdge", - "westus", - "SerialNumber1", - armedgeorderpartner.ManageLinkRequest{ - ManagementResourceArmID: to.Ptr("/subscriptions/c783ea86-c85c-4175-b76d-3992656af50d/resourceGroups/EdgeTestRG/providers/Microsoft.DataBoxEdge/DataBoxEdgeDevices/TestEdgeDeviceName1"), - Operation: to.Ptr(armedgeorderpartner.ManageLinkOperationLink), - TenantID: to.Ptr("a783ea86-c85c-4175-b76d-3992656af50d"), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/edgeorderpartner/resource-manager/Microsoft.EdgeOrderPartner/preview/2020-12-01-preview/examples/SearchInventories.json -func ExampleAPISClient_NewSearchInventoriesPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armedgeorderpartner.NewAPISClient("b783ea86-c85c-4175-b76d-3992656af50d", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewSearchInventoriesPager(armedgeorderpartner.SearchInventoriesRequest{ - FamilyIdentifier: to.Ptr("AzureStackEdge"), - SerialNumber: to.Ptr("SerialNumber1"), - }, - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/zz_generated_models_serde.go b/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/zz_generated_models_serde.go deleted file mode 100644 index 97a4640c998e..000000000000 --- a/sdk/resourcemanager/edgeorderpartner/armedgeorderpartner/zz_generated_models_serde.go +++ /dev/null @@ -1,53 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armedgeorderpartner - -import ( - "encoding/json" - "fmt" -) - -// UnmarshalJSON implements the json.Unmarshaller interface for type StageDetails. -func (s *StageDetails) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "displayName": - err = unpopulate(val, "DisplayName", &s.DisplayName) - delete(rawMsg, key) - case "stageName": - err = unpopulate(val, "StageName", &s.StageName) - delete(rawMsg, key) - case "stageStatus": - err = unpopulate(val, "StageStatus", &s.StageStatus) - delete(rawMsg, key) - case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &s.StartTime) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -func unpopulate(data json.RawMessage, fn string, v interface{}) error { - if data == nil { - return nil - } - if err := json.Unmarshal(data, v); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - return nil -} diff --git a/sdk/resourcemanager/education/armeducation/CHANGELOG.md b/sdk/resourcemanager/education/armeducation/CHANGELOG.md index fd448d28ed1a..aeba04e04187 100644 --- a/sdk/resourcemanager/education/armeducation/CHANGELOG.md +++ b/sdk/resourcemanager/education/armeducation/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 0.3.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 0.2.0 (2022-07-04) ### Features Added diff --git a/sdk/resourcemanager/education/armeducation/README.md b/sdk/resourcemanager/education/armeducation/README.md index 673821527f02..1a8c30085f2c 100644 --- a/sdk/resourcemanager/education/armeducation/README.md +++ b/sdk/resourcemanager/education/armeducation/README.md @@ -33,23 +33,31 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Education modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Education module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armeducation.(, cred, nil) +clientFactory, err := armeducation.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). ```go -options := arm.ClientOptions{ +options := arm.ClientOptions { ClientOptions: azcore.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armeducation.(, cred, &options) +clientFactory, err := armeducation.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewStudentsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/education/armeducation/autorest.md b/sdk/resourcemanager/education/armeducation/autorest.md index 981976fe1d84..fc79211588c0 100644 --- a/sdk/resourcemanager/education/armeducation/autorest.md +++ b/sdk/resourcemanager/education/armeducation/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.2.0 +module-version: 0.3.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/education/armeducation/client_factory.go b/sdk/resourcemanager/education/armeducation/client_factory.go new file mode 100644 index 000000000000..10db447943c2 --- /dev/null +++ b/sdk/resourcemanager/education/armeducation/client_factory.go @@ -0,0 +1,72 @@ +//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 armeducation + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewGrantsClient() *GrantsClient { + subClient, _ := NewGrantsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewLabsClient() *LabsClient { + subClient, _ := NewLabsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewJoinRequestsClient() *JoinRequestsClient { + subClient, _ := NewJoinRequestsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewManagementClient() *ManagementClient { + subClient, _ := NewManagementClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewStudentsClient() *StudentsClient { + subClient, _ := NewStudentsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewStudentLabsClient() *StudentLabsClient { + subClient, _ := NewStudentLabsClient(c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/education/armeducation/constants.go b/sdk/resourcemanager/education/armeducation/constants.go index daf7e67665cb..7c038841f3e4 100644 --- a/sdk/resourcemanager/education/armeducation/constants.go +++ b/sdk/resourcemanager/education/armeducation/constants.go @@ -11,7 +11,7 @@ package armeducation const ( moduleName = "armeducation" - moduleVersion = "v0.2.0" + moduleVersion = "v0.3.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. diff --git a/sdk/resourcemanager/education/armeducation/go.mod b/sdk/resourcemanager/education/armeducation/go.mod index 83771c914474..059e0994f4b8 100644 --- a/sdk/resourcemanager/education/armeducation/go.mod +++ b/sdk/resourcemanager/education/armeducation/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/education/armeducat go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/education/armeducation/go.sum b/sdk/resourcemanager/education/armeducation/go.sum index 8828b17b1853..8ba445a8c4da 100644 --- a/sdk/resourcemanager/education/armeducation/go.sum +++ b/sdk/resourcemanager/education/armeducation/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 h1:BWe8a+f/t+7KY7zH2mqygeUD0t8hNFXe08p1Pb3/jKE= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/education/armeducation/grants_client.go b/sdk/resourcemanager/education/armeducation/grants_client.go index 5a0069c6e353..1f0da918c0cb 100644 --- a/sdk/resourcemanager/education/armeducation/grants_client.go +++ b/sdk/resourcemanager/education/armeducation/grants_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,44 +25,36 @@ import ( // GrantsClient contains the methods for the Grants group. // Don't use this type directly, use NewGrantsClient() instead. type GrantsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewGrantsClient creates a new instance of GrantsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewGrantsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*GrantsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".GrantsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &GrantsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get details for a specific grant linked to the provided billing account and billing profile. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// billingAccountName - Billing account name. -// billingProfileName - Billing profile name. -// options - GrantsClientGetOptions contains the optional parameters for the GrantsClient.Get method. +// - billingAccountName - Billing account name. +// - billingProfileName - Billing profile name. +// - options - GrantsClientGetOptions contains the optional parameters for the GrantsClient.Get method. func (client *GrantsClient) Get(ctx context.Context, billingAccountName string, billingProfileName string, options *GrantsClientGetOptions) (GrantsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, billingAccountName, billingProfileName, options) if err != nil { return GrantsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GrantsClientGetResponse{}, err } @@ -85,7 +75,7 @@ func (client *GrantsClient) getCreateRequest(ctx context.Context, billingAccount return nil, errors.New("parameter billingProfileName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -109,11 +99,11 @@ func (client *GrantsClient) getHandleResponse(resp *http.Response) (GrantsClient } // NewListPager - Get details for a specific grant linked to the provided billing account and billing profile. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// billingAccountName - Billing account name. -// billingProfileName - Billing profile name. -// options - GrantsClientListOptions contains the optional parameters for the GrantsClient.List method. +// - billingAccountName - Billing account name. +// - billingProfileName - Billing profile name. +// - options - GrantsClientListOptions contains the optional parameters for the GrantsClient.NewListPager method. func (client *GrantsClient) NewListPager(billingAccountName string, billingProfileName string, options *GrantsClientListOptions) *runtime.Pager[GrantsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[GrantsClientListResponse]{ More: func(page GrantsClientListResponse) bool { @@ -130,7 +120,7 @@ func (client *GrantsClient) NewListPager(billingAccountName string, billingProfi if err != nil { return GrantsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GrantsClientListResponse{}, err } @@ -153,7 +143,7 @@ func (client *GrantsClient) listCreateRequest(ctx context.Context, billingAccoun return nil, errors.New("parameter billingProfileName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -177,9 +167,9 @@ func (client *GrantsClient) listHandleResponse(resp *http.Response) (GrantsClien } // NewListAllPager - Get a list of grants that Microsoft has provided. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// options - GrantsClientListAllOptions contains the optional parameters for the GrantsClient.ListAll method. +// - options - GrantsClientListAllOptions contains the optional parameters for the GrantsClient.NewListAllPager method. func (client *GrantsClient) NewListAllPager(options *GrantsClientListAllOptions) *runtime.Pager[GrantsClientListAllResponse] { return runtime.NewPager(runtime.PagingHandler[GrantsClientListAllResponse]{ More: func(page GrantsClientListAllResponse) bool { @@ -196,7 +186,7 @@ func (client *GrantsClient) NewListAllPager(options *GrantsClientListAllOptions) if err != nil { return GrantsClientListAllResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return GrantsClientListAllResponse{}, err } @@ -211,7 +201,7 @@ func (client *GrantsClient) NewListAllPager(options *GrantsClientListAllOptions) // listAllCreateRequest creates the ListAll request. func (client *GrantsClient) listAllCreateRequest(ctx context.Context, options *GrantsClientListAllOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Education/grants" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/education/armeducation/grants_client_example_test.go b/sdk/resourcemanager/education/armeducation/grants_client_example_test.go index 57084a6a65fe..6ba12039f632 100644 --- a/sdk/resourcemanager/education/armeducation/grants_client_example_test.go +++ b/sdk/resourcemanager/education/armeducation/grants_client_example_test.go @@ -5,6 +5,7 @@ // 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 armeducation_test @@ -17,74 +18,256 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/education/armeducation" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/GrantList.json -func ExampleGrantsClient_NewListAllPager() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/GrantList.json +func ExampleGrantsClient_NewListAllPager_grantList() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewGrantsClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListAllPager(&armeducation.GrantsClientListAllOptions{IncludeAllocatedBudget: to.Ptr(false)}) + pager := clientFactory.NewGrantsClient().NewListAllPager(&armeducation.GrantsClientListAllOptions{IncludeAllocatedBudget: to.Ptr(false)}) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.GrantListResponse = armeducation.GrantListResponse{ + // Value: []*armeducation.GrantDetails{ + // { + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Education/Grants"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Education/grants/default"), + // Properties: &armeducation.GrantDetailProperties{ + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T09:08:05.505Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T09:08:05.505Z"); return t}()), + // OfferCap: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](1000), + // }, + // OfferType: to.Ptr(armeducation.GrantTypeAcademic), + // Status: to.Ptr(armeducation.GrantStatusActive), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/GrantDefaultList.json -func ExampleGrantsClient_NewListPager() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/GrantListIncludeAllocatedBudget.json +func ExampleGrantsClient_NewListAllPager_grantListIncludeAllocatedBudget() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewGrantsClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("{billingAccountName}", - "{billingProfileName}", - &armeducation.GrantsClientListOptions{IncludeAllocatedBudget: to.Ptr(false)}) + pager := clientFactory.NewGrantsClient().NewListAllPager(&armeducation.GrantsClientListAllOptions{IncludeAllocatedBudget: to.Ptr(true)}) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.GrantListResponse = armeducation.GrantListResponse{ + // Value: []*armeducation.GrantDetails{ + // { + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Education/Grants"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Education/grants/default"), + // Properties: &armeducation.GrantDetailProperties{ + // AllocatedBudget: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](0), + // }, + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T09:08:05.505Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T09:08:05.505Z"); return t}()), + // OfferCap: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](1000), + // }, + // OfferType: to.Ptr(armeducation.GrantTypeAcademic), + // Status: to.Ptr(armeducation.GrantStatusActive), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/Grant.json -func ExampleGrantsClient_Get() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/GrantDefaultList.json +func ExampleGrantsClient_NewListPager_grantList() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewGrantsClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, - "{billingAccountName}", - "{billingProfileName}", - &armeducation.GrantsClientGetOptions{IncludeAllocatedBudget: to.Ptr(false)}) + pager := clientFactory.NewGrantsClient().NewListPager("{billingAccountName}", "{billingProfileName}", &armeducation.GrantsClientListOptions{IncludeAllocatedBudget: to.Ptr(false)}) + 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.GrantListResponse = armeducation.GrantListResponse{ + // Value: []*armeducation.GrantDetails{ + // { + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Education/Grants"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Education/grants/default"), + // Properties: &armeducation.GrantDetailProperties{ + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T09:08:05.505Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T09:08:05.505Z"); return t}()), + // OfferCap: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](1000), + // }, + // OfferType: to.Ptr(armeducation.GrantTypeAcademic), + // Status: to.Ptr(armeducation.GrantStatusActive), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/GrantDefaultListIncludeAllocatedBudget.json +func ExampleGrantsClient_NewListPager_grantListIncludeAllocatedBudget() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armeducation.NewClientFactory(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewGrantsClient().NewListPager("{billingAccountName}", "{billingProfileName}", &armeducation.GrantsClientListOptions{IncludeAllocatedBudget: to.Ptr(false)}) + 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.GrantListResponse = armeducation.GrantListResponse{ + // Value: []*armeducation.GrantDetails{ + // { + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Education/Grants"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Education/grants/default"), + // Properties: &armeducation.GrantDetailProperties{ + // AllocatedBudget: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](0), + // }, + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T09:08:05.505Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T09:08:05.505Z"); return t}()), + // OfferCap: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](1000), + // }, + // OfferType: to.Ptr(armeducation.GrantTypeAcademic), + // Status: to.Ptr(armeducation.GrantStatusActive), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/Grant.json +func ExampleGrantsClient_Get_grant() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armeducation.NewClientFactory(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewGrantsClient().Get(ctx, "{billingAccountName}", "{billingProfileName}", &armeducation.GrantsClientGetOptions{IncludeAllocatedBudget: to.Ptr(false)}) + 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.GrantDetails = armeducation.GrantDetails{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Education/Grants"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Education/grants/default"), + // Properties: &armeducation.GrantDetailProperties{ + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T09:08:05.505Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T09:08:05.505Z"); return t}()), + // OfferCap: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](100), + // }, + // OfferType: to.Ptr(armeducation.GrantTypeStudent), + // Status: to.Ptr(armeducation.GrantStatusActive), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/GrantIncludeAllocatedBudget.json +func ExampleGrantsClient_Get_grantIncludeAllocatedBudget() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armeducation.NewClientFactory(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewGrantsClient().Get(ctx, "{billingAccountName}", "{billingProfileName}", &armeducation.GrantsClientGetOptions{IncludeAllocatedBudget: to.Ptr(false)}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.GrantDetails = armeducation.GrantDetails{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Education/Grants"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.Education/grants/default"), + // Properties: &armeducation.GrantDetailProperties{ + // AllocatedBudget: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](0), + // }, + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T09:08:05.505Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T09:08:05.505Z"); return t}()), + // OfferCap: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](100), + // }, + // OfferType: to.Ptr(armeducation.GrantTypeStudent), + // Status: to.Ptr(armeducation.GrantStatusActive), + // }, + // } } diff --git a/sdk/resourcemanager/education/armeducation/joinrequests_client.go b/sdk/resourcemanager/education/armeducation/joinrequests_client.go index 5a292ec4b707..b24ec090a08a 100644 --- a/sdk/resourcemanager/education/armeducation/joinrequests_client.go +++ b/sdk/resourcemanager/education/armeducation/joinrequests_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,46 +25,38 @@ import ( // JoinRequestsClient contains the methods for the JoinRequests group. // Don't use this type directly, use NewJoinRequestsClient() instead. type JoinRequestsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewJoinRequestsClient creates a new instance of JoinRequestsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewJoinRequestsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*JoinRequestsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".JoinRequestsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &JoinRequestsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // Approve - Approve student joining the redeemable lab // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// billingAccountName - Billing account name. -// billingProfileName - Billing profile name. -// invoiceSectionName - Invoice section name. -// joinRequestName - Join name -// options - JoinRequestsClientApproveOptions contains the optional parameters for the JoinRequestsClient.Approve method. +// - billingAccountName - Billing account name. +// - billingProfileName - Billing profile name. +// - invoiceSectionName - Invoice section name. +// - joinRequestName - Join name +// - options - JoinRequestsClientApproveOptions contains the optional parameters for the JoinRequestsClient.Approve method. func (client *JoinRequestsClient) Approve(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, joinRequestName string, options *JoinRequestsClientApproveOptions) (JoinRequestsClientApproveResponse, error) { req, err := client.approveCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, joinRequestName, options) if err != nil { return JoinRequestsClientApproveResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return JoinRequestsClientApproveResponse{}, err } @@ -95,7 +85,7 @@ func (client *JoinRequestsClient) approveCreateRequest(ctx context.Context, bill return nil, errors.New("parameter joinRequestName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{joinRequestName}", url.PathEscape(joinRequestName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -108,18 +98,19 @@ func (client *JoinRequestsClient) approveCreateRequest(ctx context.Context, bill // Deny - Deny student joining the redeemable lab // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// billingAccountName - Billing account name. -// billingProfileName - Billing profile name. -// invoiceSectionName - Invoice section name. -// joinRequestName - Join name -// options - JoinRequestsClientDenyOptions contains the optional parameters for the JoinRequestsClient.Deny method. +// - billingAccountName - Billing account name. +// - billingProfileName - Billing profile name. +// - invoiceSectionName - Invoice section name. +// - joinRequestName - Join name +// - options - JoinRequestsClientDenyOptions contains the optional parameters for the JoinRequestsClient.Deny method. func (client *JoinRequestsClient) Deny(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, joinRequestName string, options *JoinRequestsClientDenyOptions) (JoinRequestsClientDenyResponse, error) { req, err := client.denyCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, joinRequestName, options) if err != nil { return JoinRequestsClientDenyResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return JoinRequestsClientDenyResponse{}, err } @@ -148,7 +139,7 @@ func (client *JoinRequestsClient) denyCreateRequest(ctx context.Context, billing return nil, errors.New("parameter joinRequestName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{joinRequestName}", url.PathEscape(joinRequestName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -161,18 +152,19 @@ func (client *JoinRequestsClient) denyCreateRequest(ctx context.Context, billing // Get - get student join requests // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// billingAccountName - Billing account name. -// billingProfileName - Billing profile name. -// invoiceSectionName - Invoice section name. -// joinRequestName - Join name -// options - JoinRequestsClientGetOptions contains the optional parameters for the JoinRequestsClient.Get method. +// - billingAccountName - Billing account name. +// - billingProfileName - Billing profile name. +// - invoiceSectionName - Invoice section name. +// - joinRequestName - Join name +// - options - JoinRequestsClientGetOptions contains the optional parameters for the JoinRequestsClient.Get method. func (client *JoinRequestsClient) Get(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, joinRequestName string, options *JoinRequestsClientGetOptions) (JoinRequestsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, joinRequestName, options) if err != nil { return JoinRequestsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return JoinRequestsClientGetResponse{}, err } @@ -201,7 +193,7 @@ func (client *JoinRequestsClient) getCreateRequest(ctx context.Context, billingA return nil, errors.New("parameter joinRequestName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{joinRequestName}", url.PathEscape(joinRequestName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -222,12 +214,12 @@ func (client *JoinRequestsClient) getHandleResponse(resp *http.Response) (JoinRe } // NewListPager - get student join requests -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// billingAccountName - Billing account name. -// billingProfileName - Billing profile name. -// invoiceSectionName - Invoice section name. -// options - JoinRequestsClientListOptions contains the optional parameters for the JoinRequestsClient.List method. +// - billingAccountName - Billing account name. +// - billingProfileName - Billing profile name. +// - invoiceSectionName - Invoice section name. +// - options - JoinRequestsClientListOptions contains the optional parameters for the JoinRequestsClient.NewListPager method. func (client *JoinRequestsClient) NewListPager(billingAccountName string, billingProfileName string, invoiceSectionName string, options *JoinRequestsClientListOptions) *runtime.Pager[JoinRequestsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[JoinRequestsClientListResponse]{ More: func(page JoinRequestsClientListResponse) bool { @@ -244,7 +236,7 @@ func (client *JoinRequestsClient) NewListPager(billingAccountName string, billin if err != nil { return JoinRequestsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return JoinRequestsClientListResponse{}, err } @@ -271,7 +263,7 @@ func (client *JoinRequestsClient) listCreateRequest(ctx context.Context, billing return nil, errors.New("parameter invoiceSectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/education/armeducation/joinrequests_client_example_test.go b/sdk/resourcemanager/education/armeducation/joinrequests_client_example_test.go index bbb689193e30..08d3f61ddc03 100644 --- a/sdk/resourcemanager/education/armeducation/joinrequests_client_example_test.go +++ b/sdk/resourcemanager/education/armeducation/joinrequests_client_example_test.go @@ -5,6 +5,7 @@ // 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 armeducation_test @@ -17,96 +18,88 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/education/armeducation" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/JoinRequestList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/JoinRequestList.json func ExampleJoinRequestsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewJoinRequestsClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("{billingAccountName}", - "{billingProfileName}", - "{invoiceSectionName}", - &armeducation.JoinRequestsClientListOptions{IncludeDenied: to.Ptr(false)}) + pager := clientFactory.NewJoinRequestsClient().NewListPager("{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", &armeducation.JoinRequestsClientListOptions{IncludeDenied: to.Ptr(false)}) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.JoinRequestList = armeducation.JoinRequestList{ + // Value: []*armeducation.JoinRequestDetails{ + // { + // Name: to.Ptr("{joinRequestName}"), + // Type: to.Ptr("Microsoft.Education/JoinRequest"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/joinRequests/{joinRequestName}"), + // Properties: &armeducation.JoinRequestProperties{ + // Email: to.Ptr("test@contoso.com"), + // FirstName: to.Ptr("test"), + // LastName: to.Ptr("user"), + // Status: to.Ptr(armeducation.JoinRequestStatusPending), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/JoinRequest.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/JoinRequest.json func ExampleJoinRequestsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewJoinRequestsClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, - "{billingAccountName}", - "{billingProfileName}", - "{invoiceSectionName}", - "{joinRequestName}", - nil) + res, err := clientFactory.NewJoinRequestsClient().Get(ctx, "{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", "{joinRequestName}", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.JoinRequestDetails = armeducation.JoinRequestDetails{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Education/JoinRequest"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/joinRequests/{joinRequestName}"), + // Properties: &armeducation.JoinRequestProperties{ + // Email: to.Ptr("test@contoso.com"), + // FirstName: to.Ptr("test"), + // LastName: to.Ptr("user"), + // Status: to.Ptr(armeducation.JoinRequestStatusPending), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/JoinRequestApproveAndDeny.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/JoinRequestApproveAndDeny.json func ExampleJoinRequestsClient_Approve() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewJoinRequestsClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Approve(ctx, - "{billingAccountName}", - "{billingProfileName}", - "{invoiceSectionName}", - "{joinRequestName}", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/JoinRequestApproveAndDeny.json -func ExampleJoinRequestsClient_Deny() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armeducation.NewJoinRequestsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Deny(ctx, - "{billingAccountName}", - "{billingProfileName}", - "{invoiceSectionName}", - "{joinRequestName}", - nil) + _, err = clientFactory.NewJoinRequestsClient().Approve(ctx, "{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", "{joinRequestName}", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/education/armeducation/labs_client.go b/sdk/resourcemanager/education/armeducation/labs_client.go index 01d1e82679b3..0cbfeca87d58 100644 --- a/sdk/resourcemanager/education/armeducation/labs_client.go +++ b/sdk/resourcemanager/education/armeducation/labs_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,46 +25,38 @@ import ( // LabsClient contains the methods for the Labs group. // Don't use this type directly, use NewLabsClient() instead. type LabsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewLabsClient creates a new instance of LabsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewLabsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*LabsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".LabsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &LabsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create a new lab or update a previously created lab. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// billingAccountName - Billing account name. -// billingProfileName - Billing profile name. -// invoiceSectionName - Invoice section name. -// parameters - Request parameters that are provided to create lab resource. -// options - LabsClientCreateOrUpdateOptions contains the optional parameters for the LabsClient.CreateOrUpdate method. +// - billingAccountName - Billing account name. +// - billingProfileName - Billing profile name. +// - invoiceSectionName - Invoice section name. +// - parameters - Request parameters that are provided to create lab resource. +// - options - LabsClientCreateOrUpdateOptions contains the optional parameters for the LabsClient.CreateOrUpdate method. func (client *LabsClient) CreateOrUpdate(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, parameters LabDetails, options *LabsClientCreateOrUpdateOptions) (LabsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, parameters, options) if err != nil { return LabsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LabsClientCreateOrUpdateResponse{}, err } @@ -91,7 +81,7 @@ func (client *LabsClient) createOrUpdateCreateRequest(ctx context.Context, billi return nil, errors.New("parameter invoiceSectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -114,17 +104,18 @@ func (client *LabsClient) createOrUpdateHandleResponse(resp *http.Response) (Lab // Delete - Delete a specific lab associated with the provided billing account name, billing profile name, and invoice section // name. Note all students must be removed from the lab in order to delete the lab. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// billingAccountName - Billing account name. -// billingProfileName - Billing profile name. -// invoiceSectionName - Invoice section name. -// options - LabsClientDeleteOptions contains the optional parameters for the LabsClient.Delete method. +// - billingAccountName - Billing account name. +// - billingProfileName - Billing profile name. +// - invoiceSectionName - Invoice section name. +// - options - LabsClientDeleteOptions contains the optional parameters for the LabsClient.Delete method. func (client *LabsClient) Delete(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *LabsClientDeleteOptions) (LabsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, options) if err != nil { return LabsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LabsClientDeleteResponse{}, err } @@ -149,7 +140,7 @@ func (client *LabsClient) deleteCreateRequest(ctx context.Context, billingAccoun return nil, errors.New("parameter invoiceSectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -162,18 +153,19 @@ func (client *LabsClient) deleteCreateRequest(ctx context.Context, billingAccoun // GenerateInviteCode - Generate invite code for a lab // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// billingAccountName - Billing account name. -// billingProfileName - Billing profile name. -// invoiceSectionName - Invoice section name. -// parameters - Request parameters that are provided to generate invite code. -// options - LabsClientGenerateInviteCodeOptions contains the optional parameters for the LabsClient.GenerateInviteCode method. +// - billingAccountName - Billing account name. +// - billingProfileName - Billing profile name. +// - invoiceSectionName - Invoice section name. +// - parameters - Request parameters that are provided to generate invite code. +// - options - LabsClientGenerateInviteCodeOptions contains the optional parameters for the LabsClient.GenerateInviteCode method. func (client *LabsClient) GenerateInviteCode(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, parameters InviteCodeGenerateRequest, options *LabsClientGenerateInviteCodeOptions) (LabsClientGenerateInviteCodeResponse, error) { req, err := client.generateInviteCodeCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, parameters, options) if err != nil { return LabsClientGenerateInviteCodeResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LabsClientGenerateInviteCodeResponse{}, err } @@ -198,7 +190,7 @@ func (client *LabsClient) generateInviteCodeCreateRequest(ctx context.Context, b return nil, errors.New("parameter invoiceSectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -224,17 +216,18 @@ func (client *LabsClient) generateInviteCodeHandleResponse(resp *http.Response) // Get - Get the details for a specific lab associated with the provided billing account name, billing profile name, and invoice // section name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// billingAccountName - Billing account name. -// billingProfileName - Billing profile name. -// invoiceSectionName - Invoice section name. -// options - LabsClientGetOptions contains the optional parameters for the LabsClient.Get method. +// - billingAccountName - Billing account name. +// - billingProfileName - Billing profile name. +// - invoiceSectionName - Invoice section name. +// - options - LabsClientGetOptions contains the optional parameters for the LabsClient.Get method. func (client *LabsClient) Get(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, options *LabsClientGetOptions) (LabsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, options) if err != nil { return LabsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LabsClientGetResponse{}, err } @@ -259,7 +252,7 @@ func (client *LabsClient) getCreateRequest(ctx context.Context, billingAccountNa return nil, errors.New("parameter invoiceSectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -284,12 +277,12 @@ func (client *LabsClient) getHandleResponse(resp *http.Response) (LabsClientGetR // NewListPager - Get the details for a specific lab associated with the provided billing account name, billing profile name, // and invoice section name. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// billingAccountName - Billing account name. -// billingProfileName - Billing profile name. -// invoiceSectionName - Invoice section name. -// options - LabsClientListOptions contains the optional parameters for the LabsClient.List method. +// - billingAccountName - Billing account name. +// - billingProfileName - Billing profile name. +// - invoiceSectionName - Invoice section name. +// - options - LabsClientListOptions contains the optional parameters for the LabsClient.NewListPager method. func (client *LabsClient) NewListPager(billingAccountName string, billingProfileName string, invoiceSectionName string, options *LabsClientListOptions) *runtime.Pager[LabsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[LabsClientListResponse]{ More: func(page LabsClientListResponse) bool { @@ -306,7 +299,7 @@ func (client *LabsClient) NewListPager(billingAccountName string, billingProfile if err != nil { return LabsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LabsClientListResponse{}, err } @@ -333,7 +326,7 @@ func (client *LabsClient) listCreateRequest(ctx context.Context, billingAccountN return nil, errors.New("parameter invoiceSectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -357,11 +350,11 @@ func (client *LabsClient) listHandleResponse(resp *http.Response) (LabsClientLis } // NewListAllPager - Get a list of labs associated with the provided billing account name and billing profile name. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// billingAccountName - Billing account name. -// billingProfileName - Billing profile name. -// options - LabsClientListAllOptions contains the optional parameters for the LabsClient.ListAll method. +// - billingAccountName - Billing account name. +// - billingProfileName - Billing profile name. +// - options - LabsClientListAllOptions contains the optional parameters for the LabsClient.NewListAllPager method. func (client *LabsClient) NewListAllPager(billingAccountName string, billingProfileName string, options *LabsClientListAllOptions) *runtime.Pager[LabsClientListAllResponse] { return runtime.NewPager(runtime.PagingHandler[LabsClientListAllResponse]{ More: func(page LabsClientListAllResponse) bool { @@ -378,7 +371,7 @@ func (client *LabsClient) NewListAllPager(billingAccountName string, billingProf if err != nil { return LabsClientListAllResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return LabsClientListAllResponse{}, err } @@ -401,7 +394,7 @@ func (client *LabsClient) listAllCreateRequest(ctx context.Context, billingAccou return nil, errors.New("parameter billingProfileName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/education/armeducation/labs_client_example_test.go b/sdk/resourcemanager/education/armeducation/labs_client_example_test.go index 8cc0a9a21261..13ac802aba5f 100644 --- a/sdk/resourcemanager/education/armeducation/labs_client_example_test.go +++ b/sdk/resourcemanager/education/armeducation/labs_client_example_test.go @@ -5,6 +5,7 @@ // 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 armeducation_test @@ -19,161 +20,393 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/education/armeducation" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/LabList.json -func ExampleLabsClient_NewListAllPager() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/LabList.json +func ExampleLabsClient_NewListAllPager_labList() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewLabsClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListAllPager("{billingAccountName}", - "{billingProfileName}", - &armeducation.LabsClientListAllOptions{IncludeBudget: to.Ptr(false), - IncludeDeleted: nil, - }) + pager := clientFactory.NewLabsClient().NewListAllPager("{billingAccountName}", "{billingProfileName}", &armeducation.LabsClientListAllOptions{IncludeBudget: to.Ptr(false), + IncludeDeleted: nil, + }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.LabListResult = armeducation.LabListResult{ + // Value: []*armeducation.LabDetails{ + // { + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Education/Labs"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default"), + // Properties: &armeducation.LabProperties{ + // Description: to.Ptr("example lab description"), + // BudgetPerStudent: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](100), + // }, + // DisplayName: to.Ptr("example lab"), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T21:25:56.838Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-09T21:25:56.838Z"); return t}()), + // Status: to.Ptr(armeducation.LabStatusActive), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/LabListWithInvoiceSectionName.json -func ExampleLabsClient_NewListPager() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/LabListIncludeBudget.json +func ExampleLabsClient_NewListAllPager_labListIncludeBudget() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewLabsClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("{billingAccountName}", - "{billingProfileName}", - "{invoiceSectionName}", - &armeducation.LabsClientListOptions{IncludeBudget: to.Ptr(true)}) + pager := clientFactory.NewLabsClient().NewListAllPager("{billingAccountName}", "{billingProfileName}", &armeducation.LabsClientListAllOptions{IncludeBudget: to.Ptr(true), + IncludeDeleted: nil, + }) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.LabListResult = armeducation.LabListResult{ + // Value: []*armeducation.LabDetails{ + // { + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Education/Labs"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default"), + // Properties: &armeducation.LabProperties{ + // Description: to.Ptr("example lab description"), + // BudgetPerStudent: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](100), + // }, + // DisplayName: to.Ptr("example lab"), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T21:25:56.838Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-09T21:25:56.838Z"); return t}()), + // Status: to.Ptr(armeducation.LabStatusActive), + // TotalAllocatedBudget: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](500), + // }, + // TotalBudget: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](500), + // }, + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/Lab.json -func ExampleLabsClient_Get() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/LabListWithInvoiceSectionName.json +func ExampleLabsClient_NewListPager_labListWithInvoiceSectionName() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewLabsClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, - "{billingAccountName}", - "{billingProfileName}", - "{invoiceSectionName}", - &armeducation.LabsClientGetOptions{IncludeBudget: to.Ptr(false)}) + pager := clientFactory.NewLabsClient().NewListPager("{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", &armeducation.LabsClientListOptions{IncludeBudget: to.Ptr(true)}) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.LabListResult = armeducation.LabListResult{ + // Value: []*armeducation.LabDetails{ + // { + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Education/Labs"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default"), + // Properties: &armeducation.LabProperties{ + // Description: to.Ptr("example lab description"), + // BudgetPerStudent: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](100), + // }, + // DisplayName: to.Ptr("example lab"), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T21:25:56.838Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-09T21:25:56.838Z"); return t}()), + // Status: to.Ptr(armeducation.LabStatusActive), + // TotalAllocatedBudget: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](500), + // }, + // TotalBudget: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](500), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/LabListWithInvoiceSectionNameIncludeBudget.json +func ExampleLabsClient_NewListPager_labListWithInvoiceSectionNameIncludeBudget() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armeducation.NewClientFactory(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewLabsClient().NewListPager("{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", &armeducation.LabsClientListOptions{IncludeBudget: to.Ptr(true)}) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.LabListResult = armeducation.LabListResult{ + // Value: []*armeducation.LabDetails{ + // { + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Education/Labs"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default"), + // Properties: &armeducation.LabProperties{ + // Description: to.Ptr("example lab description"), + // BudgetPerStudent: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](100), + // }, + // DisplayName: to.Ptr("example lab"), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T21:25:56.838Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-09T21:25:56.838Z"); return t}()), + // Status: to.Ptr(armeducation.LabStatusActive), + // TotalAllocatedBudget: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](500), + // }, + // TotalBudget: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](500), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/Lab.json +func ExampleLabsClient_Get_lab() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armeducation.NewClientFactory(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewLabsClient().Get(ctx, "{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", &armeducation.LabsClientGetOptions{IncludeBudget: to.Ptr(false)}) + 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.LabDetails = armeducation.LabDetails{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Education/Labs"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default"), + // Properties: &armeducation.LabProperties{ + // Description: to.Ptr("example lab description"), + // BudgetPerStudent: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](100), + // }, + // DisplayName: to.Ptr("example lab"), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T21:25:56.838Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-09T21:25:56.838Z"); return t}()), + // InvitationCode: to.Ptr(""), + // MaxStudentCount: to.Ptr[float32](0), + // Status: to.Ptr(armeducation.LabStatusActive), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/LabIncludeBudget.json +func ExampleLabsClient_Get_labIncludeBudget() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armeducation.NewClientFactory(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewLabsClient().Get(ctx, "{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", &armeducation.LabsClientGetOptions{IncludeBudget: to.Ptr(true)}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.LabDetails = armeducation.LabDetails{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Education/Labs"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default"), + // Properties: &armeducation.LabProperties{ + // Description: to.Ptr("example lab description"), + // BudgetPerStudent: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](100), + // }, + // DisplayName: to.Ptr("example lab"), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T21:25:56.838Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-09T21:25:56.838Z"); return t}()), + // InvitationCode: to.Ptr(""), + // MaxStudentCount: to.Ptr[float32](0), + // Status: to.Ptr(armeducation.LabStatusActive), + // TotalAllocatedBudget: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](500), + // }, + // TotalBudget: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](500), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/DeleteLab.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/DeleteLab.json func ExampleLabsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewLabsClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, - "{billingAccountName}", - "{billingProfileName}", - "{invoiceSectionName}", - nil) + _, err = clientFactory.NewLabsClient().Delete(ctx, "{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/CreateLab.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/CreateLab.json func ExampleLabsClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewLabsClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, - "{billingAccountName}", - "{billingProfileName}", - "{invoiceSectionName}", - armeducation.LabDetails{ - Properties: &armeducation.LabProperties{ - Description: to.Ptr("example lab description"), - BudgetPerStudent: &armeducation.Amount{ - Currency: to.Ptr("USD"), - Value: to.Ptr[float32](100), - }, - DisplayName: to.Ptr("example lab"), - ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-09T22:11:29.422Z"); return t }()), + res, err := clientFactory.NewLabsClient().CreateOrUpdate(ctx, "{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", armeducation.LabDetails{ + Properties: &armeducation.LabProperties{ + Description: to.Ptr("example lab description"), + BudgetPerStudent: &armeducation.Amount{ + Currency: to.Ptr("USD"), + Value: to.Ptr[float32](100), }, + DisplayName: to.Ptr("example lab"), + ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-09T22:11:29.422Z"); return t }()), }, - nil) + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.LabDetails = armeducation.LabDetails{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Education/Labs"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default"), + // Properties: &armeducation.LabProperties{ + // Description: to.Ptr("example lab description"), + // BudgetPerStudent: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](100), + // }, + // DisplayName: to.Ptr("example lab"), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T21:25:56.838Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-09T21:25:56.838Z"); return t}()), + // Status: to.Ptr(armeducation.LabStatusActive), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/GenerateInviteCode.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/GenerateInviteCode.json func ExampleLabsClient_GenerateInviteCode() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewLabsClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.GenerateInviteCode(ctx, - "{billingAccountName}", - "{billingProfileName}", - "{invoiceSectionName}", - armeducation.InviteCodeGenerateRequest{ - MaxStudentCount: to.Ptr[float32](10), - }, - &armeducation.LabsClientGenerateInviteCodeOptions{OnlyUpdateStudentCountParameter: nil}) + res, err := clientFactory.NewLabsClient().GenerateInviteCode(ctx, "{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", armeducation.InviteCodeGenerateRequest{ + MaxStudentCount: to.Ptr[float32](10), + }, &armeducation.LabsClientGenerateInviteCodeOptions{OnlyUpdateStudentCountParameter: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.LabDetails = armeducation.LabDetails{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Education/Labs"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default"), + // Properties: &armeducation.LabProperties{ + // Description: to.Ptr("example lab description"), + // BudgetPerStudent: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](100), + // }, + // DisplayName: to.Ptr("example lab"), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T21:25:56.838Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-12-09T21:25:56.838Z"); return t}()), + // InvitationCode: to.Ptr("exampleIviteCode"), + // MaxStudentCount: to.Ptr[float32](10), + // Status: to.Ptr(armeducation.LabStatusActive), + // }, + // } } diff --git a/sdk/resourcemanager/education/armeducation/management_client.go b/sdk/resourcemanager/education/armeducation/management_client.go index 245306b4dd22..f67fbf2229d5 100644 --- a/sdk/resourcemanager/education/armeducation/management_client.go +++ b/sdk/resourcemanager/education/armeducation/management_client.go @@ -13,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -23,44 +21,36 @@ import ( // ManagementClient contains the methods for the EducationManagementClient group. // Don't use this type directly, use NewManagementClient() instead. type ManagementClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewManagementClient creates a new instance of ManagementClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewManagementClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ManagementClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ManagementClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ManagementClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // RedeemInvitationCode - Redeem invite code to join a redeemable lab // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// parameters - Request parameters to provide redeem code. -// options - ManagementClientRedeemInvitationCodeOptions contains the optional parameters for the ManagementClient.RedeemInvitationCode -// method. +// - parameters - Request parameters to provide redeem code. +// - options - ManagementClientRedeemInvitationCodeOptions contains the optional parameters for the ManagementClient.RedeemInvitationCode +// method. func (client *ManagementClient) RedeemInvitationCode(ctx context.Context, parameters RedeemRequest, options *ManagementClientRedeemInvitationCodeOptions) (ManagementClientRedeemInvitationCodeResponse, error) { req, err := client.redeemInvitationCodeCreateRequest(ctx, parameters, options) if err != nil { return ManagementClientRedeemInvitationCodeResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementClientRedeemInvitationCodeResponse{}, err } @@ -73,7 +63,7 @@ func (client *ManagementClient) RedeemInvitationCode(ctx context.Context, parame // redeemInvitationCodeCreateRequest creates the RedeemInvitationCode request. func (client *ManagementClient) redeemInvitationCodeCreateRequest(ctx context.Context, parameters RedeemRequest, options *ManagementClientRedeemInvitationCodeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Education/redeemInvitationCode" - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/education/armeducation/educationmanagementclient_client_example_test.go b/sdk/resourcemanager/education/armeducation/management_client_example_test.go similarity index 68% rename from sdk/resourcemanager/education/armeducation/educationmanagementclient_client_example_test.go rename to sdk/resourcemanager/education/armeducation/management_client_example_test.go index c837b343497e..68f78c830c70 100644 --- a/sdk/resourcemanager/education/armeducation/educationmanagementclient_client_example_test.go +++ b/sdk/resourcemanager/education/armeducation/management_client_example_test.go @@ -5,6 +5,7 @@ // 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 armeducation_test @@ -17,24 +18,22 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/education/armeducation" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/RedeemCode.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/RedeemCode.json func ExampleManagementClient_RedeemInvitationCode() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewManagementClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.RedeemInvitationCode(ctx, - armeducation.RedeemRequest{ - FirstName: to.Ptr("test"), - LastName: to.Ptr("user"), - RedeemCode: to.Ptr("exampleRedeemCode"), - }, - nil) + _, err = clientFactory.NewManagementClient().RedeemInvitationCode(ctx, armeducation.RedeemRequest{ + FirstName: to.Ptr("test"), + LastName: to.Ptr("user"), + RedeemCode: to.Ptr("exampleRedeemCode"), + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/education/armeducation/models.go b/sdk/resourcemanager/education/armeducation/models.go index ebd7ed016f3b..e6aa29eebb2a 100644 --- a/sdk/resourcemanager/education/armeducation/models.go +++ b/sdk/resourcemanager/education/armeducation/models.go @@ -90,13 +90,13 @@ type GrantsClientGetOptions struct { IncludeAllocatedBudget *bool } -// GrantsClientListAllOptions contains the optional parameters for the GrantsClient.ListAll method. +// GrantsClientListAllOptions contains the optional parameters for the GrantsClient.NewListAllPager method. type GrantsClientListAllOptions struct { // May be used to include information about budget that has been allocated. IncludeAllocatedBudget *bool } -// GrantsClientListOptions contains the optional parameters for the GrantsClient.List method. +// GrantsClientListOptions contains the optional parameters for the GrantsClient.NewListPager method. type GrantsClientListOptions struct { // May be used to include information about budget that has been allocated. IncludeAllocatedBudget *bool @@ -165,7 +165,7 @@ type JoinRequestsClientGetOptions struct { // placeholder for future optional parameters } -// JoinRequestsClientListOptions contains the optional parameters for the JoinRequestsClient.List method. +// JoinRequestsClientListOptions contains the optional parameters for the JoinRequestsClient.NewListPager method. type JoinRequestsClientListOptions struct { // Include denied IncludeDenied *bool @@ -253,7 +253,7 @@ type LabsClientGetOptions struct { IncludeBudget *bool } -// LabsClientListAllOptions contains the optional parameters for the LabsClient.ListAll method. +// LabsClientListAllOptions contains the optional parameters for the LabsClient.NewListAllPager method. type LabsClientListAllOptions struct { // May be used to include budget information. IncludeBudget *bool @@ -261,7 +261,7 @@ type LabsClientListAllOptions struct { IncludeDeleted *bool } -// LabsClientListOptions contains the optional parameters for the LabsClient.List method. +// LabsClientListOptions contains the optional parameters for the LabsClient.NewListPager method. type LabsClientListOptions struct { // May be used to include budget information. IncludeBudget *bool @@ -434,7 +434,7 @@ type StudentLabsClientGetOptions struct { // placeholder for future optional parameters } -// StudentLabsClientListAllOptions contains the optional parameters for the StudentLabsClient.ListAll method. +// StudentLabsClientListAllOptions contains the optional parameters for the StudentLabsClient.NewListAllPager method. type StudentLabsClientListAllOptions struct { // placeholder for future optional parameters } @@ -499,7 +499,7 @@ type StudentsClientGetOptions struct { // placeholder for future optional parameters } -// StudentsClientListOptions contains the optional parameters for the StudentsClient.List method. +// StudentsClientListOptions contains the optional parameters for the StudentsClient.NewListPager method. type StudentsClientListOptions struct { // May be used to show deleted items. IncludeDeleted *bool diff --git a/sdk/resourcemanager/education/armeducation/models_serde.go b/sdk/resourcemanager/education/armeducation/models_serde.go index 69608a1f1d18..5c21beaca077 100644 --- a/sdk/resourcemanager/education/armeducation/models_serde.go +++ b/sdk/resourcemanager/education/armeducation/models_serde.go @@ -18,7 +18,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type Amount. func (a Amount) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "currency", a.Currency) populate(objectMap, "value", a.Value) return json.Marshal(objectMap) @@ -49,7 +49,7 @@ func (a *Amount) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorResponse. func (e ErrorResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "code", e.Code) populate(objectMap, "message", e.Message) return json.Marshal(objectMap) @@ -80,7 +80,7 @@ func (e *ErrorResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorResponseBody. func (e ErrorResponseBody) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "error", e.Error) return json.Marshal(objectMap) } @@ -107,7 +107,7 @@ func (e *ErrorResponseBody) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GrantDetailProperties. func (g GrantDetailProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "allocatedBudget", g.AllocatedBudget) populateTimeRFC3339(objectMap, "effectiveDate", g.EffectiveDate) populateTimeRFC3339(objectMap, "expirationDate", g.ExpirationDate) @@ -154,7 +154,7 @@ func (g *GrantDetailProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GrantDetails. func (g GrantDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", g.ID) populate(objectMap, "name", g.Name) populate(objectMap, "properties", g.Properties) @@ -197,7 +197,7 @@ func (g *GrantDetails) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type GrantListResponse. func (g GrantListResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", g.NextLink) populate(objectMap, "value", g.Value) return json.Marshal(objectMap) @@ -228,7 +228,7 @@ func (g *GrantListResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type InviteCodeGenerateRequest. func (i InviteCodeGenerateRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "maxStudentCount", i.MaxStudentCount) return json.Marshal(objectMap) } @@ -255,7 +255,7 @@ func (i *InviteCodeGenerateRequest) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JoinRequestDetails. func (j JoinRequestDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", j.ID) populate(objectMap, "name", j.Name) populate(objectMap, "properties", j.Properties) @@ -298,7 +298,7 @@ func (j *JoinRequestDetails) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JoinRequestList. func (j JoinRequestList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", j.NextLink) populate(objectMap, "value", j.Value) return json.Marshal(objectMap) @@ -329,7 +329,7 @@ func (j *JoinRequestList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JoinRequestProperties. func (j JoinRequestProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "email", j.Email) populate(objectMap, "firstName", j.FirstName) populate(objectMap, "lastName", j.LastName) @@ -368,7 +368,7 @@ func (j *JoinRequestProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LabDetails. func (l LabDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", l.ID) populate(objectMap, "name", l.Name) populate(objectMap, "properties", l.Properties) @@ -411,7 +411,7 @@ func (l *LabDetails) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LabListResult. func (l LabListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", l.NextLink) populate(objectMap, "value", l.Value) return json.Marshal(objectMap) @@ -442,7 +442,7 @@ func (l *LabListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LabProperties. func (l LabProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "budgetPerStudent", l.BudgetPerStudent) populate(objectMap, "description", l.Description) populate(objectMap, "displayName", l.DisplayName) @@ -505,7 +505,7 @@ func (l *LabProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Operation. func (o Operation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "actionType", o.ActionType) populate(objectMap, "display", o.Display) populate(objectMap, "isDataAction", o.IsDataAction) @@ -548,7 +548,7 @@ func (o *Operation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationDisplay. func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", o.Description) populate(objectMap, "operation", o.Operation) populate(objectMap, "provider", o.Provider) @@ -587,7 +587,7 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationListResult. func (o OperationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", o.NextLink) populate(objectMap, "value", o.Value) return json.Marshal(objectMap) @@ -618,7 +618,7 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RedeemRequest. func (r RedeemRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "firstName", r.FirstName) populate(objectMap, "lastName", r.LastName) populate(objectMap, "redeemCode", r.RedeemCode) @@ -653,7 +653,7 @@ func (r *RedeemRequest) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Resource. func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "name", r.Name) populate(objectMap, "systemData", r.SystemData) @@ -692,7 +692,7 @@ func (r *Resource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StudentDetails. func (s StudentDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) @@ -735,7 +735,7 @@ func (s *StudentDetails) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StudentLabDetails. func (s StudentLabDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) @@ -778,7 +778,7 @@ func (s *StudentLabDetails) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StudentLabListResult. func (s StudentLabListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -809,7 +809,7 @@ func (s *StudentLabListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StudentLabProperties. func (s StudentLabProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "budget", s.Budget) populate(objectMap, "description", s.Description) populate(objectMap, "displayName", s.DisplayName) @@ -868,7 +868,7 @@ func (s *StudentLabProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StudentListResult. func (s StudentListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -899,7 +899,7 @@ func (s *StudentListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type StudentProperties. func (s StudentProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "budget", s.Budget) populateTimeRFC3339(objectMap, "effectiveDate", s.EffectiveDate) populate(objectMap, "email", s.Email) @@ -966,7 +966,7 @@ func (s *StudentProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) @@ -1011,7 +1011,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { return nil } -func populate(m map[string]interface{}, k string, v interface{}) { +func populate(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { @@ -1021,7 +1021,7 @@ func populate(m map[string]interface{}, k string, v interface{}) { } } -func unpopulate(data json.RawMessage, fn string, v interface{}) error { +func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil } diff --git a/sdk/resourcemanager/education/armeducation/operations_client.go b/sdk/resourcemanager/education/armeducation/operations_client.go index cd902cefee6b..2240fbbdb1de 100644 --- a/sdk/resourcemanager/education/armeducation/operations_client.go +++ b/sdk/resourcemanager/education/armeducation/operations_client.go @@ -13,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -23,42 +21,34 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // List - Lists all of the available Microsoft.Education API operations. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. func (client *OperationsClient) List(ctx context.Context, options *OperationsClientListOptions) (OperationsClientListResponse, error) { req, err := client.listCreateRequest(ctx, options) if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -71,7 +61,7 @@ func (client *OperationsClient) List(ctx context.Context, options *OperationsCli // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Education/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/education/armeducation/operations_client_example_test.go b/sdk/resourcemanager/education/armeducation/operations_client_example_test.go index bc920685589f..07f05adfa2eb 100644 --- a/sdk/resourcemanager/education/armeducation/operations_client_example_test.go +++ b/sdk/resourcemanager/education/armeducation/operations_client_example_test.go @@ -5,6 +5,7 @@ // 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 armeducation_test @@ -16,22 +17,61 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/education/armeducation" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/GetOperations.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/GetOperations.json func ExampleOperationsClient_List() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewOperationsClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.List(ctx, - nil) + res, err := clientFactory.NewOperationsClient().List(ctx, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.OperationListResult = armeducation.OperationListResult{ + // Value: []*armeducation.Operation{ + // { + // Name: to.Ptr("Microsoft.Education/grants/read"), + // Display: &armeducation.OperationDisplay{ + // Description: to.Ptr("Read all grants"), + // Operation: to.Ptr("Get grants"), + // Provider: to.Ptr("Microsoft Education"), + // Resource: to.Ptr("Grants"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Education/labs/read"), + // Display: &armeducation.OperationDisplay{ + // Description: to.Ptr("Read all labs"), + // Operation: to.Ptr("Get labs"), + // Provider: to.Ptr("Microsoft Edcucation"), + // Resource: to.Ptr("Labs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Education/labs/write"), + // Display: &armeducation.OperationDisplay{ + // Description: to.Ptr("Create or update lab"), + // Operation: to.Ptr("Create or update lab"), + // Provider: to.Ptr("Microsoft Edcucation"), + // Resource: to.Ptr("Labs"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.Education/labs/delete"), + // Display: &armeducation.OperationDisplay{ + // Description: to.Ptr("Delete a lab"), + // Operation: to.Ptr("Delete lab"), + // Provider: to.Ptr("Microsoft Edcucation"), + // Resource: to.Ptr("Labs"), + // }, + // }}, + // } } diff --git a/sdk/resourcemanager/education/armeducation/response_types.go b/sdk/resourcemanager/education/armeducation/response_types.go index a5a9b7439f8e..2e795c711674 100644 --- a/sdk/resourcemanager/education/armeducation/response_types.go +++ b/sdk/resourcemanager/education/armeducation/response_types.go @@ -14,12 +14,12 @@ type GrantsClientGetResponse struct { GrantDetails } -// GrantsClientListAllResponse contains the response from method GrantsClient.ListAll. +// GrantsClientListAllResponse contains the response from method GrantsClient.NewListAllPager. type GrantsClientListAllResponse struct { GrantListResponse } -// GrantsClientListResponse contains the response from method GrantsClient.List. +// GrantsClientListResponse contains the response from method GrantsClient.NewListPager. type GrantsClientListResponse struct { GrantListResponse } @@ -39,7 +39,7 @@ type JoinRequestsClientGetResponse struct { JoinRequestDetails } -// JoinRequestsClientListResponse contains the response from method JoinRequestsClient.List. +// JoinRequestsClientListResponse contains the response from method JoinRequestsClient.NewListPager. type JoinRequestsClientListResponse struct { JoinRequestList } @@ -64,12 +64,12 @@ type LabsClientGetResponse struct { LabDetails } -// LabsClientListAllResponse contains the response from method LabsClient.ListAll. +// LabsClientListAllResponse contains the response from method LabsClient.NewListAllPager. type LabsClientListAllResponse struct { LabListResult } -// LabsClientListResponse contains the response from method LabsClient.List. +// LabsClientListResponse contains the response from method LabsClient.NewListPager. type LabsClientListResponse struct { LabListResult } @@ -89,7 +89,7 @@ type StudentLabsClientGetResponse struct { StudentLabDetails } -// StudentLabsClientListAllResponse contains the response from method StudentLabsClient.ListAll. +// StudentLabsClientListAllResponse contains the response from method StudentLabsClient.NewListAllPager. type StudentLabsClientListAllResponse struct { StudentLabListResult } @@ -109,7 +109,7 @@ type StudentsClientGetResponse struct { StudentDetails } -// StudentsClientListResponse contains the response from method StudentsClient.List. +// StudentsClientListResponse contains the response from method StudentsClient.NewListPager. type StudentsClientListResponse struct { StudentListResult } diff --git a/sdk/resourcemanager/education/armeducation/studentlabs_client.go b/sdk/resourcemanager/education/armeducation/studentlabs_client.go index 93259bd41a13..bec8cbf1c58a 100644 --- a/sdk/resourcemanager/education/armeducation/studentlabs_client.go +++ b/sdk/resourcemanager/education/armeducation/studentlabs_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,43 +24,35 @@ import ( // StudentLabsClient contains the methods for the StudentLabs group. // Don't use this type directly, use NewStudentLabsClient() instead. type StudentLabsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewStudentLabsClient creates a new instance of StudentLabsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewStudentLabsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*StudentLabsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".StudentLabsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &StudentLabsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get the details for a specified lab associated with the student lab. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// studentLabName - Student lab name. -// options - StudentLabsClientGetOptions contains the optional parameters for the StudentLabsClient.Get method. +// - studentLabName - Student lab name. +// - options - StudentLabsClientGetOptions contains the optional parameters for the StudentLabsClient.Get method. func (client *StudentLabsClient) Get(ctx context.Context, studentLabName string, options *StudentLabsClientGetOptions) (StudentLabsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, studentLabName, options) if err != nil { return StudentLabsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StudentLabsClientGetResponse{}, err } @@ -79,7 +69,7 @@ func (client *StudentLabsClient) getCreateRequest(ctx context.Context, studentLa return nil, errors.New("parameter studentLabName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{studentLabName}", url.PathEscape(studentLabName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -100,9 +90,9 @@ func (client *StudentLabsClient) getHandleResponse(resp *http.Response) (Student } // NewListAllPager - Get a list of all labs associated with the caller of the API. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// options - StudentLabsClientListAllOptions contains the optional parameters for the StudentLabsClient.ListAll method. +// - options - StudentLabsClientListAllOptions contains the optional parameters for the StudentLabsClient.NewListAllPager method. func (client *StudentLabsClient) NewListAllPager(options *StudentLabsClientListAllOptions) *runtime.Pager[StudentLabsClientListAllResponse] { return runtime.NewPager(runtime.PagingHandler[StudentLabsClientListAllResponse]{ More: func(page StudentLabsClientListAllResponse) bool { @@ -119,7 +109,7 @@ func (client *StudentLabsClient) NewListAllPager(options *StudentLabsClientListA if err != nil { return StudentLabsClientListAllResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StudentLabsClientListAllResponse{}, err } @@ -134,7 +124,7 @@ func (client *StudentLabsClient) NewListAllPager(options *StudentLabsClientListA // listAllCreateRequest creates the ListAll request. func (client *StudentLabsClient) listAllCreateRequest(ctx context.Context, options *StudentLabsClientListAllOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Education/studentLabs" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/education/armeducation/studentlabs_client_example_test.go b/sdk/resourcemanager/education/armeducation/studentlabs_client_example_test.go index a0ea054bad15..06b6f0b7eaea 100644 --- a/sdk/resourcemanager/education/armeducation/studentlabs_client_example_test.go +++ b/sdk/resourcemanager/education/armeducation/studentlabs_client_example_test.go @@ -5,6 +5,7 @@ // 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 armeducation_test @@ -16,47 +17,88 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/education/armeducation" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/StudentLabList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/StudentLabList.json func ExampleStudentLabsClient_NewListAllPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewStudentLabsClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListAllPager(nil) + pager := clientFactory.NewStudentLabsClient().NewListAllPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.StudentLabListResult = armeducation.StudentLabListResult{ + // Value: []*armeducation.StudentLabDetails{ + // { + // Name: to.Ptr("{studentLabName}"), + // Type: to.Ptr("Microsoft.Education/StudentLabs"), + // ID: to.Ptr(" /providers/Microsoft.Education/studentLabs/{studentLabName}"), + // Properties: &armeducation.StudentLabProperties{ + // Description: to.Ptr("example lab description"), + // Budget: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](100), + // }, + // DisplayName: to.Ptr("example lab name"), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T21:54:17.438Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-09T21:54:17.438Z"); return t}()), + // LabScope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default"), + // Role: to.Ptr(armeducation.StudentRoleStudent), + // Status: to.Ptr(armeducation.StudentLabStatusActive), + // SubscriptionID: to.Ptr("000000000-0000-0000-0000-00000000000000"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/StudentLab.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/StudentLab.json func ExampleStudentLabsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewStudentLabsClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, - "{studentLabName}", - nil) + res, err := clientFactory.NewStudentLabsClient().Get(ctx, "{studentLabName}", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.StudentLabDetails = armeducation.StudentLabDetails{ + // Name: to.Ptr("{studentLabName}"), + // Type: to.Ptr("Microsoft.Education/StudentLabs"), + // ID: to.Ptr(" /providers/Microsoft.Education/studentLabs/{studentLabName}"), + // Properties: &armeducation.StudentLabProperties{ + // Description: to.Ptr("example lab description"), + // Budget: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](100), + // }, + // DisplayName: to.Ptr("example lab name"), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T21:54:17.438Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-09T21:54:17.438Z"); return t}()), + // LabScope: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default"), + // Role: to.Ptr(armeducation.StudentRoleStudent), + // Status: to.Ptr(armeducation.StudentLabStatusActive), + // SubscriptionID: to.Ptr("000000000-0000-0000-0000-00000000000000"), + // }, + // } } diff --git a/sdk/resourcemanager/education/armeducation/students_client.go b/sdk/resourcemanager/education/armeducation/students_client.go index e6c597211d4b..13450bf8a4f3 100644 --- a/sdk/resourcemanager/education/armeducation/students_client.go +++ b/sdk/resourcemanager/education/armeducation/students_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -27,28 +25,19 @@ import ( // StudentsClient contains the methods for the Students group. // Don't use this type directly, use NewStudentsClient() instead. type StudentsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewStudentsClient creates a new instance of StudentsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewStudentsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*StudentsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".StudentsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &StudentsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -56,19 +45,20 @@ func NewStudentsClient(credential azcore.TokenCredential, options *arm.ClientOpt // CreateOrUpdate - Create and add a new student to the specified lab or update the details of an existing student in a lab. // Note the student must have a valid tenant to accept the lab after they have been added to lab. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// billingAccountName - Billing account name. -// billingProfileName - Billing profile name. -// invoiceSectionName - Invoice section name. -// studentAlias - Student alias. -// parameters - Request parameters that are provided to update student properties. -// options - StudentsClientCreateOrUpdateOptions contains the optional parameters for the StudentsClient.CreateOrUpdate method. +// - billingAccountName - Billing account name. +// - billingProfileName - Billing profile name. +// - invoiceSectionName - Invoice section name. +// - studentAlias - Student alias. +// - parameters - Request parameters that are provided to update student properties. +// - options - StudentsClientCreateOrUpdateOptions contains the optional parameters for the StudentsClient.CreateOrUpdate method. func (client *StudentsClient) CreateOrUpdate(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, studentAlias string, parameters StudentDetails, options *StudentsClientCreateOrUpdateOptions) (StudentsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, studentAlias, parameters, options) if err != nil { return StudentsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StudentsClientCreateOrUpdateResponse{}, err } @@ -97,7 +87,7 @@ func (client *StudentsClient) createOrUpdateCreateRequest(ctx context.Context, b return nil, errors.New("parameter studentAlias cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{studentAlias}", url.PathEscape(studentAlias)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -119,18 +109,19 @@ func (client *StudentsClient) createOrUpdateHandleResponse(resp *http.Response) // Delete - Delete the specified student based on the student alias. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// billingAccountName - Billing account name. -// billingProfileName - Billing profile name. -// invoiceSectionName - Invoice section name. -// studentAlias - Student alias. -// options - StudentsClientDeleteOptions contains the optional parameters for the StudentsClient.Delete method. +// - billingAccountName - Billing account name. +// - billingProfileName - Billing profile name. +// - invoiceSectionName - Invoice section name. +// - studentAlias - Student alias. +// - options - StudentsClientDeleteOptions contains the optional parameters for the StudentsClient.Delete method. func (client *StudentsClient) Delete(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, studentAlias string, options *StudentsClientDeleteOptions) (StudentsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, studentAlias, options) if err != nil { return StudentsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StudentsClientDeleteResponse{}, err } @@ -159,7 +150,7 @@ func (client *StudentsClient) deleteCreateRequest(ctx context.Context, billingAc return nil, errors.New("parameter studentAlias cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{studentAlias}", url.PathEscape(studentAlias)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -172,18 +163,19 @@ func (client *StudentsClient) deleteCreateRequest(ctx context.Context, billingAc // Get - Get the details for a specific student in the specified lab by student alias // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// billingAccountName - Billing account name. -// billingProfileName - Billing profile name. -// invoiceSectionName - Invoice section name. -// studentAlias - Student alias. -// options - StudentsClientGetOptions contains the optional parameters for the StudentsClient.Get method. +// - billingAccountName - Billing account name. +// - billingProfileName - Billing profile name. +// - invoiceSectionName - Invoice section name. +// - studentAlias - Student alias. +// - options - StudentsClientGetOptions contains the optional parameters for the StudentsClient.Get method. func (client *StudentsClient) Get(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, studentAlias string, options *StudentsClientGetOptions) (StudentsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, billingAccountName, billingProfileName, invoiceSectionName, studentAlias, options) if err != nil { return StudentsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StudentsClientGetResponse{}, err } @@ -212,7 +204,7 @@ func (client *StudentsClient) getCreateRequest(ctx context.Context, billingAccou return nil, errors.New("parameter studentAlias cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{studentAlias}", url.PathEscape(studentAlias)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -233,12 +225,12 @@ func (client *StudentsClient) getHandleResponse(resp *http.Response) (StudentsCl } // NewListPager - Get a list of details about students that are associated with the specified lab. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-12-01-preview -// billingAccountName - Billing account name. -// billingProfileName - Billing profile name. -// invoiceSectionName - Invoice section name. -// options - StudentsClientListOptions contains the optional parameters for the StudentsClient.List method. +// - billingAccountName - Billing account name. +// - billingProfileName - Billing profile name. +// - invoiceSectionName - Invoice section name. +// - options - StudentsClientListOptions contains the optional parameters for the StudentsClient.NewListPager method. func (client *StudentsClient) NewListPager(billingAccountName string, billingProfileName string, invoiceSectionName string, options *StudentsClientListOptions) *runtime.Pager[StudentsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[StudentsClientListResponse]{ More: func(page StudentsClientListResponse) bool { @@ -255,7 +247,7 @@ func (client *StudentsClient) NewListPager(billingAccountName string, billingPro if err != nil { return StudentsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return StudentsClientListResponse{}, err } @@ -282,7 +274,7 @@ func (client *StudentsClient) listCreateRequest(ctx context.Context, billingAcco return nil, errors.New("parameter invoiceSectionName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{invoiceSectionName}", url.PathEscape(invoiceSectionName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/education/armeducation/students_client_example_test.go b/sdk/resourcemanager/education/armeducation/students_client_example_test.go index 2c5ecd56f302..6a7a2763cb11 100644 --- a/sdk/resourcemanager/education/armeducation/students_client_example_test.go +++ b/sdk/resourcemanager/education/armeducation/students_client_example_test.go @@ -5,6 +5,7 @@ // 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 armeducation_test @@ -19,112 +20,160 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/education/armeducation" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/StudentList.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/StudentList.json func ExampleStudentsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewStudentsClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("{billingAccountName}", - "{billingProfileName}", - "{invoiceSectionName}", - &armeducation.StudentsClientListOptions{IncludeDeleted: nil}) + pager := clientFactory.NewStudentsClient().NewListPager("{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", &armeducation.StudentsClientListOptions{IncludeDeleted: nil}) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.StudentListResult = armeducation.StudentListResult{ + // Value: []*armeducation.StudentDetails{ + // { + // Name: to.Ptr("{studentAlias}"), + // Type: to.Ptr("Microsoft.Education/Students"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/students/{studentAlias}"), + // Properties: &armeducation.StudentProperties{ + // Budget: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](100), + // }, + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T21:43:54.161Z"); return t}()), + // Email: to.Ptr("test@contoso.com"), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-09T21:43:54.161Z"); return t}()), + // FirstName: to.Ptr("test"), + // LastName: to.Ptr("user"), + // Role: to.Ptr(armeducation.StudentRoleStudent), + // Status: to.Ptr(armeducation.StudentLabStatusActive), + // SubscriptionAlias: to.Ptr("000000000-0000-0000-0000-00000000000000"), + // SubscriptionID: to.Ptr("000000000-0000-0000-0000-00000000000000"), + // SubscriptionInviteLastSentDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T21:43:54.161Z"); return t}()), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/Student.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/Student.json func ExampleStudentsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewStudentsClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, - "{billingAccountName}", - "{billingProfileName}", - "{invoiceSectionName}", - "{studentAlias}", - nil) + res, err := clientFactory.NewStudentsClient().Get(ctx, "{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", "{studentAlias}", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.StudentDetails = armeducation.StudentDetails{ + // Name: to.Ptr("{studentAlias}"), + // Type: to.Ptr("Microsoft.Education/Students"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/students/{studentAlias}"), + // Properties: &armeducation.StudentProperties{ + // Budget: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](100), + // }, + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T21:43:54.161Z"); return t}()), + // Email: to.Ptr("test@contoso.com"), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-09T21:43:54.161Z"); return t}()), + // FirstName: to.Ptr("test"), + // LastName: to.Ptr("user"), + // Role: to.Ptr(armeducation.StudentRoleStudent), + // Status: to.Ptr(armeducation.StudentLabStatusActive), + // SubscriptionAlias: to.Ptr("000000000-0000-0000-0000-00000000000000"), + // SubscriptionID: to.Ptr("000000000-0000-0000-0000-00000000000000"), + // SubscriptionInviteLastSentDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T21:43:54.161Z"); return t}()), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/DeleteStudent.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/DeleteStudent.json func ExampleStudentsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewStudentsClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, - "{billingAccountName}", - "{billingProfileName}", - "{invoiceSectionName}", - "{studentAlias}", - nil) + _, err = clientFactory.NewStudentsClient().Delete(ctx, "{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", "{studentAlias}", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/CreateStudent.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9b91929c304f8fb44002267b6c98d9fb9dde014/specification/education/resource-manager/Microsoft.Education/preview/2021-12-01-preview/examples/CreateStudent.json func ExampleStudentsClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armeducation.NewStudentsClient(cred, nil) + clientFactory, err := armeducation.NewClientFactory(cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, - "{billingAccountName}", - "{billingProfileName}", - "{invoiceSectionName}", - "{studentAlias}", - armeducation.StudentDetails{ - Properties: &armeducation.StudentProperties{ - Budget: &armeducation.Amount{ - Currency: to.Ptr("USD"), - Value: to.Ptr[float32](100), - }, - Email: to.Ptr("test@contoso.com"), - ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T22:13:21.795Z"); return t }()), - FirstName: to.Ptr("test"), - LastName: to.Ptr("user"), - Role: to.Ptr(armeducation.StudentRoleStudent), + res, err := clientFactory.NewStudentsClient().CreateOrUpdate(ctx, "{billingAccountName}", "{billingProfileName}", "{invoiceSectionName}", "{studentAlias}", armeducation.StudentDetails{ + Properties: &armeducation.StudentProperties{ + Budget: &armeducation.Amount{ + Currency: to.Ptr("USD"), + Value: to.Ptr[float32](100), }, + Email: to.Ptr("test@contoso.com"), + ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T22:13:21.795Z"); return t }()), + FirstName: to.Ptr("test"), + LastName: to.Ptr("user"), + Role: to.Ptr(armeducation.StudentRoleStudent), }, - nil) + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.StudentDetails = armeducation.StudentDetails{ + // Name: to.Ptr("{studentAlias}"), + // Type: to.Ptr("Microsoft.Education/Students"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Education/labs/default/students/{studentAlias}"), + // Properties: &armeducation.StudentProperties{ + // Budget: &armeducation.Amount{ + // Currency: to.Ptr("USD"), + // Value: to.Ptr[float32](100), + // }, + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-11-09T21:43:54.161Z"); return t}()), + // Email: to.Ptr("test@contoso.com"), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-11-09T21:43:54.161Z"); return t}()), + // FirstName: to.Ptr("test"), + // LastName: to.Ptr("user"), + // Role: to.Ptr(armeducation.StudentRoleStudent), + // Status: to.Ptr(armeducation.StudentLabStatusActive), + // SubscriptionID: to.Ptr("000000000-0000-0000-0000-00000000000000"), + // }, + // } } diff --git a/sdk/resourcemanager/education/armeducation/time_rfc3339.go b/sdk/resourcemanager/education/armeducation/time_rfc3339.go index 15d58ee7d2c3..40d1ee991b6b 100644 --- a/sdk/resourcemanager/education/armeducation/time_rfc3339.go +++ b/sdk/resourcemanager/education/armeducation/time_rfc3339.go @@ -62,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/elastic/armelastic/CHANGELOG.md b/sdk/resourcemanager/elastic/armelastic/CHANGELOG.md index ce0f66ec5b11..edfa83b1ff27 100644 --- a/sdk/resourcemanager/elastic/armelastic/CHANGELOG.md +++ b/sdk/resourcemanager/elastic/armelastic/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 0.7.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 0.6.0 (2022-11-10) ### Features Added diff --git a/sdk/resourcemanager/elastic/armelastic/README.md b/sdk/resourcemanager/elastic/armelastic/README.md index ff3fcc96be69..69d7a74c8376 100644 --- a/sdk/resourcemanager/elastic/armelastic/README.md +++ b/sdk/resourcemanager/elastic/armelastic/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Elastic modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Elastic module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armelastic.NewMonitorsClient(, cred, nil) +clientFactory, err := armelastic.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armelastic.NewMonitorsClient(, cred, &options) +clientFactory, err := armelastic.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewMonitorsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/elastic/armelastic/alltrafficfilters_client.go b/sdk/resourcemanager/elastic/armelastic/alltrafficfilters_client.go index 36587b1a2bed..85e342b090e1 100644 --- a/sdk/resourcemanager/elastic/armelastic/alltrafficfilters_client.go +++ b/sdk/resourcemanager/elastic/armelastic/alltrafficfilters_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,47 +32,39 @@ import ( // AllTrafficFiltersClient contains the methods for the AllTrafficFilters group. // Don't use this type directly, use NewAllTrafficFiltersClient() instead. type AllTrafficFiltersClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAllTrafficFiltersClient creates a new instance of AllTrafficFiltersClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAllTrafficFiltersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AllTrafficFiltersClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AllTrafficFiltersClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AllTrafficFiltersClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // List - Get the list of all traffic filters for the account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - AllTrafficFiltersClientListOptions contains the optional parameters for the AllTrafficFiltersClient.List method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - AllTrafficFiltersClientListOptions contains the optional parameters for the AllTrafficFiltersClient.List method. func (client *AllTrafficFiltersClient) List(ctx context.Context, resourceGroupName string, monitorName string, options *AllTrafficFiltersClientListOptions) (AllTrafficFiltersClientListResponse, error) { req, err := client.listCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return AllTrafficFiltersClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AllTrafficFiltersClientListResponse{}, err } @@ -99,7 +89,7 @@ func (client *AllTrafficFiltersClient) listCreateRequest(ctx context.Context, re return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elastic/armelastic/alltrafficfilters_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/alltrafficfilters_client_example_test.go index beeaccb7cc21..4d8c962a0692 100644 --- a/sdk/resourcemanager/elastic/armelastic/alltrafficfilters_client_example_test.go +++ b/sdk/resourcemanager/elastic/armelastic/alltrafficfilters_client_example_test.go @@ -2,9 +2,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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic_test @@ -16,21 +25,44 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/AllTrafficFilters_list.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/AllTrafficFilters_list.json func ExampleAllTrafficFiltersClient_List() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewAllTrafficFiltersClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.List(ctx, "myResourceGroup", "myMonitor", nil) + res, err := clientFactory.NewAllTrafficFiltersClient().List(ctx, "myResourceGroup", "myMonitor", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.TrafficFilterResponse = armelastic.TrafficFilterResponse{ + // Rulesets: []*armelastic.TrafficFilter{ + // { + // Name: to.Ptr("IPFromApi"), + // Type: to.Ptr(armelastic.TypeIP), + // Description: to.Ptr("created from azure"), + // ID: to.Ptr("31d91b5afb6f4c2eaaf104c97b1991dd"), + // IncludeByDefault: to.Ptr(false), + // Region: to.Ptr("azure-eastus"), + // Rules: []*armelastic.TrafficFilterRule{ + // { + // Description: to.Ptr("Allow inbound traffic from IP address 192.168.131.0"), + // ID: to.Ptr("f0297dad72af4a5e964cddf817f35e65"), + // Source: to.Ptr("192.168.131.0"), + // }, + // { + // Description: to.Ptr("Allow inbound traffic from IP address block 192.168.132.6/22"), + // ID: to.Ptr("f9c00169f0e54931ae72aabde326b589"), + // Source: to.Ptr("192.168.132.6/22"), + // }}, + // }}, + // } } diff --git a/sdk/resourcemanager/elastic/armelastic/associatetrafficfilter_client.go b/sdk/resourcemanager/elastic/armelastic/associatetrafficfilter_client.go index 8faf175a506e..480de2d479b9 100644 --- a/sdk/resourcemanager/elastic/armelastic/associatetrafficfilter_client.go +++ b/sdk/resourcemanager/elastic/armelastic/associatetrafficfilter_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,63 +32,56 @@ import ( // AssociateTrafficFilterClient contains the methods for the AssociateTrafficFilter group. // Don't use this type directly, use NewAssociateTrafficFilterClient() instead. type AssociateTrafficFilterClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAssociateTrafficFilterClient creates a new instance of AssociateTrafficFilterClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAssociateTrafficFilterClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AssociateTrafficFilterClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AssociateTrafficFilterClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AssociateTrafficFilterClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginAssociate - Associate traffic filter for the given deployment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - AssociateTrafficFilterClientBeginAssociateOptions contains the optional parameters for the AssociateTrafficFilterClient.BeginAssociate -// method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - AssociateTrafficFilterClientBeginAssociateOptions contains the optional parameters for the AssociateTrafficFilterClient.BeginAssociate +// method. func (client *AssociateTrafficFilterClient) BeginAssociate(ctx context.Context, resourceGroupName string, monitorName string, options *AssociateTrafficFilterClientBeginAssociateOptions) (*runtime.Poller[AssociateTrafficFilterClientAssociateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.associate(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - return runtime.NewPoller[AssociateTrafficFilterClientAssociateResponse](resp, client.pl, nil) + return runtime.NewPoller[AssociateTrafficFilterClientAssociateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[AssociateTrafficFilterClientAssociateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[AssociateTrafficFilterClientAssociateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Associate - Associate traffic filter for the given deployment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview func (client *AssociateTrafficFilterClient) associate(ctx context.Context, resourceGroupName string, monitorName string, options *AssociateTrafficFilterClientBeginAssociateOptions) (*http.Response, error) { req, err := client.associateCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -115,7 +106,7 @@ func (client *AssociateTrafficFilterClient) associateCreateRequest(ctx context.C return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elastic/armelastic/associatetrafficfilter_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/associatetrafficfilter_client_example_test.go index edecd73f62b1..6076dd6638ff 100644 --- a/sdk/resourcemanager/elastic/armelastic/associatetrafficfilter_client_example_test.go +++ b/sdk/resourcemanager/elastic/armelastic/associatetrafficfilter_client_example_test.go @@ -2,9 +2,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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic_test @@ -17,18 +26,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/AssociateTrafficFilter_Update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/AssociateTrafficFilter_Update.json func ExampleAssociateTrafficFilterClient_BeginAssociate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewAssociateTrafficFilterClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginAssociate(ctx, "myResourceGroup", "myMonitor", &armelastic.AssociateTrafficFilterClientBeginAssociateOptions{RulesetID: to.Ptr("31d91b5afb6f4c2eaaf104c97b1991dd")}) + poller, err := clientFactory.NewAssociateTrafficFilterClient().BeginAssociate(ctx, "myResourceGroup", "myMonitor", &armelastic.AssociateTrafficFilterClientBeginAssociateOptions{RulesetID: to.Ptr("31d91b5afb6f4c2eaaf104c97b1991dd")}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/elastic/armelastic/autorest.md b/sdk/resourcemanager/elastic/armelastic/autorest.md index 603c2442d9d4..a92c06ffe48f 100644 --- a/sdk/resourcemanager/elastic/armelastic/autorest.md +++ b/sdk/resourcemanager/elastic/armelastic/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.6.0 +module-version: 0.7.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/elastic/armelastic/client_factory.go b/sdk/resourcemanager/elastic/armelastic/client_factory.go new file mode 100644 index 000000000000..a0a3cd624324 --- /dev/null +++ b/sdk/resourcemanager/elastic/armelastic/client_factory.go @@ -0,0 +1,142 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewMonitorsClient() *MonitorsClient { + subClient, _ := NewMonitorsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewMonitoredResourcesClient() *MonitoredResourcesClient { + subClient, _ := NewMonitoredResourcesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDeploymentInfoClient() *DeploymentInfoClient { + subClient, _ := NewDeploymentInfoClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewExternalUserClient() *ExternalUserClient { + subClient, _ := NewExternalUserClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewTagRulesClient() *TagRulesClient { + subClient, _ := NewTagRulesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVMHostClient() *VMHostClient { + subClient, _ := NewVMHostClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVMIngestionClient() *VMIngestionClient { + subClient, _ := NewVMIngestionClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVMCollectionClient() *VMCollectionClient { + subClient, _ := NewVMCollectionClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewUpgradableVersionsClient() *UpgradableVersionsClient { + subClient, _ := NewUpgradableVersionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewMonitorClient() *MonitorClient { + subClient, _ := NewMonitorClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAllTrafficFiltersClient() *AllTrafficFiltersClient { + subClient, _ := NewAllTrafficFiltersClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewListAssociatedTrafficFiltersClient() *ListAssociatedTrafficFiltersClient { + subClient, _ := NewListAssociatedTrafficFiltersClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCreateAndAssociateIPFilterClient() *CreateAndAssociateIPFilterClient { + subClient, _ := NewCreateAndAssociateIPFilterClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCreateAndAssociatePLFilterClient() *CreateAndAssociatePLFilterClient { + subClient, _ := NewCreateAndAssociatePLFilterClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAssociateTrafficFilterClient() *AssociateTrafficFilterClient { + subClient, _ := NewAssociateTrafficFilterClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDetachAndDeleteTrafficFilterClient() *DetachAndDeleteTrafficFilterClient { + subClient, _ := NewDetachAndDeleteTrafficFilterClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDetachTrafficFilterClient() *DetachTrafficFilterClient { + subClient, _ := NewDetachTrafficFilterClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewTrafficFiltersClient() *TrafficFiltersClient { + subClient, _ := NewTrafficFiltersClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/elastic/armelastic/constants.go b/sdk/resourcemanager/elastic/armelastic/constants.go index 8eb77ac1802a..891c59588546 100644 --- a/sdk/resourcemanager/elastic/armelastic/constants.go +++ b/sdk/resourcemanager/elastic/armelastic/constants.go @@ -19,7 +19,7 @@ package armelastic const ( moduleName = "armelastic" - moduleVersion = "v0.6.0" + moduleVersion = "v0.7.0" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/elastic/armelastic/createandassociateipfilter_client.go b/sdk/resourcemanager/elastic/armelastic/createandassociateipfilter_client.go index 91540e714e30..8999bd7c0416 100644 --- a/sdk/resourcemanager/elastic/armelastic/createandassociateipfilter_client.go +++ b/sdk/resourcemanager/elastic/armelastic/createandassociateipfilter_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,63 +32,56 @@ import ( // CreateAndAssociateIPFilterClient contains the methods for the CreateAndAssociateIPFilter group. // Don't use this type directly, use NewCreateAndAssociateIPFilterClient() instead. type CreateAndAssociateIPFilterClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCreateAndAssociateIPFilterClient creates a new instance of CreateAndAssociateIPFilterClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewCreateAndAssociateIPFilterClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CreateAndAssociateIPFilterClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".CreateAndAssociateIPFilterClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CreateAndAssociateIPFilterClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create and Associate IP traffic filter for the given deployment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - CreateAndAssociateIPFilterClientBeginCreateOptions contains the optional parameters for the CreateAndAssociateIPFilterClient.BeginCreate -// method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - CreateAndAssociateIPFilterClientBeginCreateOptions contains the optional parameters for the CreateAndAssociateIPFilterClient.BeginCreate +// method. func (client *CreateAndAssociateIPFilterClient) BeginCreate(ctx context.Context, resourceGroupName string, monitorName string, options *CreateAndAssociateIPFilterClientBeginCreateOptions) (*runtime.Poller[CreateAndAssociateIPFilterClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - return runtime.NewPoller[CreateAndAssociateIPFilterClientCreateResponse](resp, client.pl, nil) + return runtime.NewPoller[CreateAndAssociateIPFilterClientCreateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[CreateAndAssociateIPFilterClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CreateAndAssociateIPFilterClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create and Associate IP traffic filter for the given deployment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview func (client *CreateAndAssociateIPFilterClient) create(ctx context.Context, resourceGroupName string, monitorName string, options *CreateAndAssociateIPFilterClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -115,7 +106,7 @@ func (client *CreateAndAssociateIPFilterClient) createCreateRequest(ctx context. return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elastic/armelastic/createandassociateipfilter_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/createandassociateipfilter_client_example_test.go index 788b0cc85e26..9df6c02eaa84 100644 --- a/sdk/resourcemanager/elastic/armelastic/createandassociateipfilter_client_example_test.go +++ b/sdk/resourcemanager/elastic/armelastic/createandassociateipfilter_client_example_test.go @@ -2,9 +2,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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic_test @@ -17,18 +26,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/IPTrafficFilter_Create.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/IPTrafficFilter_Create.json func ExampleCreateAndAssociateIPFilterClient_BeginCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewCreateAndAssociateIPFilterClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "myResourceGroup", "myMonitor", &armelastic.CreateAndAssociateIPFilterClientBeginCreateOptions{IPs: to.Ptr("192.168.131.0, 192.168.132.6/22"), + poller, err := clientFactory.NewCreateAndAssociateIPFilterClient().BeginCreate(ctx, "myResourceGroup", "myMonitor", &armelastic.CreateAndAssociateIPFilterClientBeginCreateOptions{IPs: to.Ptr("192.168.131.0, 192.168.132.6/22"), Name: nil, }) if err != nil { diff --git a/sdk/resourcemanager/elastic/armelastic/createandassociateplfilter_client.go b/sdk/resourcemanager/elastic/armelastic/createandassociateplfilter_client.go index 41621a95a63c..81ce4d528c09 100644 --- a/sdk/resourcemanager/elastic/armelastic/createandassociateplfilter_client.go +++ b/sdk/resourcemanager/elastic/armelastic/createandassociateplfilter_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,63 +32,56 @@ import ( // CreateAndAssociatePLFilterClient contains the methods for the CreateAndAssociatePLFilter group. // Don't use this type directly, use NewCreateAndAssociatePLFilterClient() instead. type CreateAndAssociatePLFilterClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCreateAndAssociatePLFilterClient creates a new instance of CreateAndAssociatePLFilterClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewCreateAndAssociatePLFilterClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CreateAndAssociatePLFilterClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".CreateAndAssociatePLFilterClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CreateAndAssociatePLFilterClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create and Associate private link traffic filter for the given deployment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - CreateAndAssociatePLFilterClientBeginCreateOptions contains the optional parameters for the CreateAndAssociatePLFilterClient.BeginCreate -// method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - CreateAndAssociatePLFilterClientBeginCreateOptions contains the optional parameters for the CreateAndAssociatePLFilterClient.BeginCreate +// method. func (client *CreateAndAssociatePLFilterClient) BeginCreate(ctx context.Context, resourceGroupName string, monitorName string, options *CreateAndAssociatePLFilterClientBeginCreateOptions) (*runtime.Poller[CreateAndAssociatePLFilterClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - return runtime.NewPoller[CreateAndAssociatePLFilterClientCreateResponse](resp, client.pl, nil) + return runtime.NewPoller[CreateAndAssociatePLFilterClientCreateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[CreateAndAssociatePLFilterClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CreateAndAssociatePLFilterClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create and Associate private link traffic filter for the given deployment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview func (client *CreateAndAssociatePLFilterClient) create(ctx context.Context, resourceGroupName string, monitorName string, options *CreateAndAssociatePLFilterClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -115,7 +106,7 @@ func (client *CreateAndAssociatePLFilterClient) createCreateRequest(ctx context. return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elastic/armelastic/createandassociateplfilter_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/createandassociateplfilter_client_example_test.go index a5924bc02c04..daf38cec2d02 100644 --- a/sdk/resourcemanager/elastic/armelastic/createandassociateplfilter_client_example_test.go +++ b/sdk/resourcemanager/elastic/armelastic/createandassociateplfilter_client_example_test.go @@ -2,9 +2,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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic_test @@ -17,18 +26,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/PrivateLinkTrafficFilters_Create.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/PrivateLinkTrafficFilters_Create.json func ExampleCreateAndAssociatePLFilterClient_BeginCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewCreateAndAssociatePLFilterClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "myResourceGroup", "myMonitor", &armelastic.CreateAndAssociatePLFilterClientBeginCreateOptions{Name: nil, + poller, err := clientFactory.NewCreateAndAssociatePLFilterClient().BeginCreate(ctx, "myResourceGroup", "myMonitor", &armelastic.CreateAndAssociatePLFilterClientBeginCreateOptions{Name: nil, PrivateEndpointGUID: to.Ptr("fdb54d3b-e85e-4d08-8958-0d2f7g523df9"), PrivateEndpointName: to.Ptr("myPrivateEndpoint"), }) diff --git a/sdk/resourcemanager/elastic/armelastic/deploymentinfo_client.go b/sdk/resourcemanager/elastic/armelastic/deploymentinfo_client.go index 863b871ce7ec..864670f4e97c 100644 --- a/sdk/resourcemanager/elastic/armelastic/deploymentinfo_client.go +++ b/sdk/resourcemanager/elastic/armelastic/deploymentinfo_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,47 +32,39 @@ import ( // DeploymentInfoClient contains the methods for the DeploymentInfo group. // Don't use this type directly, use NewDeploymentInfoClient() instead. type DeploymentInfoClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDeploymentInfoClient creates a new instance of DeploymentInfoClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewDeploymentInfoClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DeploymentInfoClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".DeploymentInfoClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DeploymentInfoClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // List - Fetch information regarding Elastic cloud deployment corresponding to the Elastic monitor resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - DeploymentInfoClientListOptions contains the optional parameters for the DeploymentInfoClient.List method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - DeploymentInfoClientListOptions contains the optional parameters for the DeploymentInfoClient.List method. func (client *DeploymentInfoClient) List(ctx context.Context, resourceGroupName string, monitorName string, options *DeploymentInfoClientListOptions) (DeploymentInfoClientListResponse, error) { req, err := client.listCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return DeploymentInfoClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DeploymentInfoClientListResponse{}, err } @@ -99,7 +89,7 @@ func (client *DeploymentInfoClient) listCreateRequest(ctx context.Context, resou return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elastic/armelastic/deploymentinfo_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/deploymentinfo_client_example_test.go index 45f09dd244a3..18502dea9a04 100644 --- a/sdk/resourcemanager/elastic/armelastic/deploymentinfo_client_example_test.go +++ b/sdk/resourcemanager/elastic/armelastic/deploymentinfo_client_example_test.go @@ -2,9 +2,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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic_test @@ -16,21 +25,28 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/DeploymentInfo_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/DeploymentInfo_List.json func ExampleDeploymentInfoClient_List() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewDeploymentInfoClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.List(ctx, "myResourceGroup", "myMonitor", nil) + res, err := clientFactory.NewDeploymentInfoClient().List(ctx, "myResourceGroup", "myMonitor", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.DeploymentInfoResponse = armelastic.DeploymentInfoResponse{ + // DiskCapacity: to.Ptr("245760"), + // MemoryCapacity: to.Ptr("1024"), + // Status: to.Ptr(armelastic.ElasticDeploymentStatusHealthy), + // Version: to.Ptr("7.9.3"), + // } } diff --git a/sdk/resourcemanager/elastic/armelastic/detachanddeletetrafficfilter_client.go b/sdk/resourcemanager/elastic/armelastic/detachanddeletetrafficfilter_client.go index 580fdfabe04c..02ce33c21371 100644 --- a/sdk/resourcemanager/elastic/armelastic/detachanddeletetrafficfilter_client.go +++ b/sdk/resourcemanager/elastic/armelastic/detachanddeletetrafficfilter_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,48 +32,40 @@ import ( // DetachAndDeleteTrafficFilterClient contains the methods for the DetachAndDeleteTrafficFilter group. // Don't use this type directly, use NewDetachAndDeleteTrafficFilterClient() instead. type DetachAndDeleteTrafficFilterClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDetachAndDeleteTrafficFilterClient creates a new instance of DetachAndDeleteTrafficFilterClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewDetachAndDeleteTrafficFilterClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DetachAndDeleteTrafficFilterClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".DetachAndDeleteTrafficFilterClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DetachAndDeleteTrafficFilterClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Delete - Detach and Delete traffic filter from the given deployment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - DetachAndDeleteTrafficFilterClientDeleteOptions contains the optional parameters for the DetachAndDeleteTrafficFilterClient.Delete -// method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - DetachAndDeleteTrafficFilterClientDeleteOptions contains the optional parameters for the DetachAndDeleteTrafficFilterClient.Delete +// method. func (client *DetachAndDeleteTrafficFilterClient) Delete(ctx context.Context, resourceGroupName string, monitorName string, options *DetachAndDeleteTrafficFilterClientDeleteOptions) (DetachAndDeleteTrafficFilterClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return DetachAndDeleteTrafficFilterClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return DetachAndDeleteTrafficFilterClientDeleteResponse{}, err } @@ -100,7 +90,7 @@ func (client *DetachAndDeleteTrafficFilterClient) deleteCreateRequest(ctx contex return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elastic/armelastic/detachanddeletetrafficfilter_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/detachanddeletetrafficfilter_client_example_test.go index 34ee8a29afc6..69a3d1825f71 100644 --- a/sdk/resourcemanager/elastic/armelastic/detachanddeletetrafficfilter_client_example_test.go +++ b/sdk/resourcemanager/elastic/armelastic/detachanddeletetrafficfilter_client_example_test.go @@ -2,9 +2,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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic_test @@ -17,18 +26,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/DetachAndDeleteTrafficFilter_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/DetachAndDeleteTrafficFilter_Delete.json func ExampleDetachAndDeleteTrafficFilterClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewDetachAndDeleteTrafficFilterClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "myResourceGroup", "myMonitor", &armelastic.DetachAndDeleteTrafficFilterClientDeleteOptions{RulesetID: to.Ptr("31d91b5afb6f4c2eaaf104c97b1991dd")}) + _, err = clientFactory.NewDetachAndDeleteTrafficFilterClient().Delete(ctx, "myResourceGroup", "myMonitor", &armelastic.DetachAndDeleteTrafficFilterClientDeleteOptions{RulesetID: to.Ptr("31d91b5afb6f4c2eaaf104c97b1991dd")}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/elastic/armelastic/detachtrafficfilter_client.go b/sdk/resourcemanager/elastic/armelastic/detachtrafficfilter_client.go index f5b6d2b96871..0cbf7f71b141 100644 --- a/sdk/resourcemanager/elastic/armelastic/detachtrafficfilter_client.go +++ b/sdk/resourcemanager/elastic/armelastic/detachtrafficfilter_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,63 +32,56 @@ import ( // DetachTrafficFilterClient contains the methods for the DetachTrafficFilter group. // Don't use this type directly, use NewDetachTrafficFilterClient() instead. type DetachTrafficFilterClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewDetachTrafficFilterClient creates a new instance of DetachTrafficFilterClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewDetachTrafficFilterClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DetachTrafficFilterClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".DetachTrafficFilterClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &DetachTrafficFilterClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginUpdate - Detach traffic filter for the given deployment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - DetachTrafficFilterClientBeginUpdateOptions contains the optional parameters for the DetachTrafficFilterClient.BeginUpdate -// method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - DetachTrafficFilterClientBeginUpdateOptions contains the optional parameters for the DetachTrafficFilterClient.BeginUpdate +// method. func (client *DetachTrafficFilterClient) BeginUpdate(ctx context.Context, resourceGroupName string, monitorName string, options *DetachTrafficFilterClientBeginUpdateOptions) (*runtime.Poller[DetachTrafficFilterClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - return runtime.NewPoller[DetachTrafficFilterClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[DetachTrafficFilterClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[DetachTrafficFilterClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[DetachTrafficFilterClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Detach traffic filter for the given deployment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview func (client *DetachTrafficFilterClient) update(ctx context.Context, resourceGroupName string, monitorName string, options *DetachTrafficFilterClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -115,7 +106,7 @@ func (client *DetachTrafficFilterClient) updateCreateRequest(ctx context.Context return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elastic/armelastic/detachtrafficfilter_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/detachtrafficfilter_client_example_test.go index 2c92ee42faa2..c9336b2968d9 100644 --- a/sdk/resourcemanager/elastic/armelastic/detachtrafficfilter_client_example_test.go +++ b/sdk/resourcemanager/elastic/armelastic/detachtrafficfilter_client_example_test.go @@ -2,9 +2,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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic_test @@ -17,18 +26,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/DetachTrafficFilters_Update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/DetachTrafficFilters_Update.json func ExampleDetachTrafficFilterClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewDetachTrafficFilterClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "myResourceGroup", "myMonitor", &armelastic.DetachTrafficFilterClientBeginUpdateOptions{RulesetID: to.Ptr("31d91b5afb6f4c2eaaf104c97b1991dd")}) + poller, err := clientFactory.NewDetachTrafficFilterClient().BeginUpdate(ctx, "myResourceGroup", "myMonitor", &armelastic.DetachTrafficFilterClientBeginUpdateOptions{RulesetID: to.Ptr("31d91b5afb6f4c2eaaf104c97b1991dd")}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/elastic/armelastic/externaluser_client.go b/sdk/resourcemanager/elastic/armelastic/externaluser_client.go index d04280112650..d6d9c6b5523f 100644 --- a/sdk/resourcemanager/elastic/armelastic/externaluser_client.go +++ b/sdk/resourcemanager/elastic/armelastic/externaluser_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,31 +32,22 @@ import ( // ExternalUserClient contains the methods for the ExternalUser group. // Don't use this type directly, use NewExternalUserClient() instead. type ExternalUserClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewExternalUserClient creates a new instance of ExternalUserClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewExternalUserClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExternalUserClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ExternalUserClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ExternalUserClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -66,17 +55,18 @@ func NewExternalUserClient(subscriptionID string, credential azcore.TokenCredent // CreateOrUpdate - Create User inside elastic deployment which are used by customers to perform operations on the elastic // deployment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - ExternalUserClientCreateOrUpdateOptions contains the optional parameters for the ExternalUserClient.CreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - ExternalUserClientCreateOrUpdateOptions contains the optional parameters for the ExternalUserClient.CreateOrUpdate +// method. func (client *ExternalUserClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, options *ExternalUserClientCreateOrUpdateOptions) (ExternalUserClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return ExternalUserClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExternalUserClientCreateOrUpdateResponse{}, err } @@ -101,7 +91,7 @@ func (client *ExternalUserClient) createOrUpdateCreateRequest(ctx context.Contex return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elastic/armelastic/externaluser_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/externaluser_client_example_test.go index 5f8910d9592f..f86bd5efeff0 100644 --- a/sdk/resourcemanager/elastic/armelastic/externaluser_client_example_test.go +++ b/sdk/resourcemanager/elastic/armelastic/externaluser_client_example_test.go @@ -2,9 +2,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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic_test @@ -16,21 +25,25 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/ExternalUserInfo.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/ExternalUserInfo.json func ExampleExternalUserClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewExternalUserClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "myResourceGroup", "myMonitor", &armelastic.ExternalUserClientCreateOrUpdateOptions{Body: nil}) + res, err := clientFactory.NewExternalUserClient().CreateOrUpdate(ctx, "myResourceGroup", "myMonitor", &armelastic.ExternalUserClientCreateOrUpdateOptions{Body: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.ExternalUserCreationResponse = armelastic.ExternalUserCreationResponse{ + // Created: to.Ptr(true), + // } } diff --git a/sdk/resourcemanager/elastic/armelastic/go.mod b/sdk/resourcemanager/elastic/armelastic/go.mod index 860dc4999af5..7ffe5f360783 100644 --- a/sdk/resourcemanager/elastic/armelastic/go.mod +++ b/sdk/resourcemanager/elastic/armelastic/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 // indirect - github.com/golang-jwt/jwt/v4 v4.4.2 // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/elastic/armelastic/go.sum b/sdk/resourcemanager/elastic/armelastic/go.sum index 8c0539b73123..8ba445a8c4da 100644 --- a/sdk/resourcemanager/elastic/armelastic/go.sum +++ b/sdk/resourcemanager/elastic/armelastic/go.sum @@ -1,30 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 h1:t/W5MYAuQy81cvM8VUNfRLzhtKpXhVUAN7Cd7KVbTyc= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0/go.mod h1:NBanQUfSWiWn3QEpWDTCU0IjBECKOYvl2R8xdRtMtiM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 h1:VgSJlZH5u0k2qxSpqyghcFQKmvYckj46uymKK5XzkBM= -github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0/go.mod h1:BDJ5qMFKx9DugEg3+uQSDCdbYPr5s9vBTrL9P8TpqOU= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= -github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/elastic/armelastic/listassociatedtrafficfilters_client.go b/sdk/resourcemanager/elastic/armelastic/listassociatedtrafficfilters_client.go index 869134347ff8..38b7d690a798 100644 --- a/sdk/resourcemanager/elastic/armelastic/listassociatedtrafficfilters_client.go +++ b/sdk/resourcemanager/elastic/armelastic/listassociatedtrafficfilters_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,48 +32,40 @@ import ( // ListAssociatedTrafficFiltersClient contains the methods for the ListAssociatedTrafficFilters group. // Don't use this type directly, use NewListAssociatedTrafficFiltersClient() instead. type ListAssociatedTrafficFiltersClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewListAssociatedTrafficFiltersClient creates a new instance of ListAssociatedTrafficFiltersClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewListAssociatedTrafficFiltersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ListAssociatedTrafficFiltersClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ListAssociatedTrafficFiltersClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ListAssociatedTrafficFiltersClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // List - Get the list of all associated traffic filters for the given deployment. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - ListAssociatedTrafficFiltersClientListOptions contains the optional parameters for the ListAssociatedTrafficFiltersClient.List -// method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - ListAssociatedTrafficFiltersClientListOptions contains the optional parameters for the ListAssociatedTrafficFiltersClient.List +// method. func (client *ListAssociatedTrafficFiltersClient) List(ctx context.Context, resourceGroupName string, monitorName string, options *ListAssociatedTrafficFiltersClientListOptions) (ListAssociatedTrafficFiltersClientListResponse, error) { req, err := client.listCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return ListAssociatedTrafficFiltersClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ListAssociatedTrafficFiltersClientListResponse{}, err } @@ -100,7 +90,7 @@ func (client *ListAssociatedTrafficFiltersClient) listCreateRequest(ctx context. return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elastic/armelastic/listassociatedtrafficfilters_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/listassociatedtrafficfilters_client_example_test.go index 4a08035bf1f3..bbd0a7516db4 100644 --- a/sdk/resourcemanager/elastic/armelastic/listassociatedtrafficfilters_client_example_test.go +++ b/sdk/resourcemanager/elastic/armelastic/listassociatedtrafficfilters_client_example_test.go @@ -2,9 +2,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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic_test @@ -16,21 +25,44 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/AssociatedFiltersForDeployment_list.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/AssociatedFiltersForDeployment_list.json func ExampleListAssociatedTrafficFiltersClient_List() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewListAssociatedTrafficFiltersClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.List(ctx, "myResourceGroup", "myMonitor", nil) + res, err := clientFactory.NewListAssociatedTrafficFiltersClient().List(ctx, "myResourceGroup", "myMonitor", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.TrafficFilterResponse = armelastic.TrafficFilterResponse{ + // Rulesets: []*armelastic.TrafficFilter{ + // { + // Name: to.Ptr("IPFromApi"), + // Type: to.Ptr(armelastic.TypeIP), + // Description: to.Ptr("created from azure"), + // ID: to.Ptr("31d91b5afb6f4c2eaaf104c97b1991dd"), + // IncludeByDefault: to.Ptr(false), + // Region: to.Ptr("azure-eastus"), + // Rules: []*armelastic.TrafficFilterRule{ + // { + // Description: to.Ptr("Allow inbound traffic from IP address 192.168.131.0"), + // ID: to.Ptr("f0297dad72af4a5e964cddf817f35e65"), + // Source: to.Ptr("192.168.131.0"), + // }, + // { + // Description: to.Ptr("Allow inbound traffic from IP address block 192.168.132.6/22"), + // ID: to.Ptr("f9c00169f0e54931ae72aabde326b589"), + // Source: to.Ptr("192.168.132.6/22"), + // }}, + // }}, + // } } diff --git a/sdk/resourcemanager/elastic/armelastic/models.go b/sdk/resourcemanager/elastic/armelastic/models.go index 4ef97417c273..9a13f6a056a8 100644 --- a/sdk/resourcemanager/elastic/armelastic/models.go +++ b/sdk/resourcemanager/elastic/armelastic/models.go @@ -330,7 +330,7 @@ type MonitoredResourceListResponse struct { Value []*MonitoredResource `json:"value,omitempty"` } -// MonitoredResourcesClientListOptions contains the optional parameters for the MonitoredResourcesClient.List method. +// MonitoredResourcesClientListOptions contains the optional parameters for the MonitoredResourcesClient.NewListPager method. type MonitoredResourcesClientListOptions struct { // placeholder for future optional parameters } @@ -390,12 +390,13 @@ type MonitorsClientGetOptions struct { // placeholder for future optional parameters } -// MonitorsClientListByResourceGroupOptions contains the optional parameters for the MonitorsClient.ListByResourceGroup method. +// MonitorsClientListByResourceGroupOptions contains the optional parameters for the MonitorsClient.NewListByResourceGroupPager +// method. type MonitorsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// MonitorsClientListOptions contains the optional parameters for the MonitorsClient.List method. +// MonitorsClientListOptions contains the optional parameters for the MonitorsClient.NewListPager method. type MonitorsClientListOptions struct { // placeholder for future optional parameters } @@ -445,7 +446,7 @@ type OperationResult struct { Origin *string `json:"origin,omitempty"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -503,7 +504,7 @@ type TagRulesClientGetOptions struct { // placeholder for future optional parameters } -// TagRulesClientListOptions contains the optional parameters for the TagRulesClient.List method. +// TagRulesClientListOptions contains the optional parameters for the TagRulesClient.NewListPager method. type TagRulesClientListOptions struct { // placeholder for future optional parameters } @@ -609,7 +610,7 @@ type VMCollectionUpdate struct { VMResourceID *string `json:"vmResourceId,omitempty"` } -// VMHostClientListOptions contains the optional parameters for the VMHostClient.List method. +// VMHostClientListOptions contains the optional parameters for the VMHostClient.NewListPager method. type VMHostClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/elastic/armelastic/models_serde.go b/sdk/resourcemanager/elastic/armelastic/models_serde.go index 8385411b1eb0..40d586262995 100644 --- a/sdk/resourcemanager/elastic/armelastic/models_serde.go +++ b/sdk/resourcemanager/elastic/armelastic/models_serde.go @@ -26,7 +26,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type CloudDeployment. func (c CloudDeployment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "azureSubscriptionId", c.AzureSubscriptionID) populate(objectMap, "deploymentId", c.DeploymentID) populate(objectMap, "elasticsearchRegion", c.ElasticsearchRegion) @@ -77,7 +77,7 @@ func (c *CloudDeployment) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CloudUser. func (c CloudUser) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "elasticCloudSsoDefaultUrl", c.ElasticCloudSsoDefaultURL) populate(objectMap, "emailAddress", c.EmailAddress) populate(objectMap, "id", c.ID) @@ -112,7 +112,7 @@ func (c *CloudUser) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CompanyInfo. func (c CompanyInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "business", c.Business) populate(objectMap, "country", c.Country) populate(objectMap, "domain", c.Domain) @@ -155,7 +155,7 @@ func (c *CompanyInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DeploymentInfoResponse. func (d DeploymentInfoResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "diskCapacity", d.DiskCapacity) populate(objectMap, "memoryCapacity", d.MemoryCapacity) populate(objectMap, "status", d.Status) @@ -194,7 +194,7 @@ func (d *DeploymentInfoResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ExternalUserCreationResponse. func (e ExternalUserCreationResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "created", e.Created) return json.Marshal(objectMap) } @@ -221,7 +221,7 @@ func (e *ExternalUserCreationResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ExternalUserInfo. func (e ExternalUserInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "emailId", e.EmailID) populate(objectMap, "fullName", e.FullName) populate(objectMap, "password", e.Password) @@ -264,7 +264,7 @@ func (e *ExternalUserInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type FilteringTag. func (f FilteringTag) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "action", f.Action) populate(objectMap, "name", f.Name) populate(objectMap, "value", f.Value) @@ -299,7 +299,7 @@ func (f *FilteringTag) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IdentityProperties. func (i IdentityProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "principalId", i.PrincipalID) populate(objectMap, "tenantId", i.TenantID) populate(objectMap, "type", i.Type) @@ -334,7 +334,7 @@ func (i *IdentityProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type LogRules. func (l LogRules) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "filteringTags", l.FilteringTags) populate(objectMap, "sendAadLogs", l.SendAADLogs) populate(objectMap, "sendActivityLogs", l.SendActivityLogs) @@ -373,7 +373,7 @@ func (l *LogRules) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitorProperties. func (m MonitorProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "elasticProperties", m.ElasticProperties) populate(objectMap, "liftrResourceCategory", m.LiftrResourceCategory) populate(objectMap, "liftrResourcePreference", m.LiftrResourcePreference) @@ -424,7 +424,7 @@ func (m *MonitorProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitorResource. func (m MonitorResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", m.ID) populate(objectMap, "identity", m.Identity) populate(objectMap, "location", m.Location) @@ -483,7 +483,7 @@ func (m *MonitorResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitorResourceListResponse. func (m MonitorResourceListResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", m.NextLink) populate(objectMap, "value", m.Value) return json.Marshal(objectMap) @@ -514,7 +514,7 @@ func (m *MonitorResourceListResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitorResourceUpdateParameters. func (m MonitorResourceUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "tags", m.Tags) return json.Marshal(objectMap) } @@ -541,7 +541,7 @@ func (m *MonitorResourceUpdateParameters) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitorUpgrade. func (m MonitorUpgrade) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "version", m.Version) return json.Marshal(objectMap) } @@ -568,7 +568,7 @@ func (m *MonitorUpgrade) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitoredResource. func (m MonitoredResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", m.ID) populate(objectMap, "reasonForLogsStatus", m.ReasonForLogsStatus) populate(objectMap, "sendingLogs", m.SendingLogs) @@ -603,7 +603,7 @@ func (m *MonitoredResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitoredResourceListResponse. func (m MonitoredResourceListResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", m.NextLink) populate(objectMap, "value", m.Value) return json.Marshal(objectMap) @@ -634,7 +634,7 @@ func (m *MonitoredResourceListResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitoringTagRules. func (m MonitoringTagRules) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", m.ID) populate(objectMap, "name", m.Name) populate(objectMap, "properties", m.Properties) @@ -677,7 +677,7 @@ func (m *MonitoringTagRules) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitoringTagRulesListResponse. func (m MonitoringTagRulesListResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", m.NextLink) populate(objectMap, "value", m.Value) return json.Marshal(objectMap) @@ -708,7 +708,7 @@ func (m *MonitoringTagRulesListResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MonitoringTagRulesProperties. func (m MonitoringTagRulesProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "logRules", m.LogRules) populate(objectMap, "provisioningState", m.ProvisioningState) return json.Marshal(objectMap) @@ -739,7 +739,7 @@ func (m *MonitoringTagRulesProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationDisplay. func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", o.Description) populate(objectMap, "operation", o.Operation) populate(objectMap, "provider", o.Provider) @@ -778,7 +778,7 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationListResult. func (o OperationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", o.NextLink) populate(objectMap, "value", o.Value) return json.Marshal(objectMap) @@ -809,7 +809,7 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationResult. func (o OperationResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "display", o.Display) populate(objectMap, "isDataAction", o.IsDataAction) populate(objectMap, "name", o.Name) @@ -848,7 +848,7 @@ func (o *OperationResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Properties. func (p Properties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "elasticCloudDeployment", p.ElasticCloudDeployment) populate(objectMap, "elasticCloudUser", p.ElasticCloudUser) return json.Marshal(objectMap) @@ -879,7 +879,7 @@ func (p *Properties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceSKU. func (r ResourceSKU) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", r.Name) return json.Marshal(objectMap) } @@ -906,7 +906,7 @@ func (r *ResourceSKU) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) @@ -953,7 +953,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrafficFilter. func (t TrafficFilter) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", t.Description) populate(objectMap, "id", t.ID) populate(objectMap, "includeByDefault", t.IncludeByDefault) @@ -1004,7 +1004,7 @@ func (t *TrafficFilter) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrafficFilterResponse. func (t TrafficFilterResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "rulesets", t.Rulesets) return json.Marshal(objectMap) } @@ -1031,7 +1031,7 @@ func (t *TrafficFilterResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrafficFilterRule. func (t TrafficFilterRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "azureEndpointGuid", t.AzureEndpointGUID) populate(objectMap, "azureEndpointName", t.AzureEndpointName) populate(objectMap, "description", t.Description) @@ -1074,7 +1074,7 @@ func (t *TrafficFilterRule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UpgradableVersionsList. func (u UpgradableVersionsList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "currentVersion", u.CurrentVersion) populate(objectMap, "upgradableVersions", u.UpgradableVersions) return json.Marshal(objectMap) @@ -1105,7 +1105,7 @@ func (u *UpgradableVersionsList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UserInfo. func (u UserInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "companyInfo", u.CompanyInfo) populate(objectMap, "companyName", u.CompanyName) populate(objectMap, "emailAddress", u.EmailAddress) @@ -1148,7 +1148,7 @@ func (u *UserInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VMCollectionUpdate. func (v VMCollectionUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "operationName", v.OperationName) populate(objectMap, "vmResourceId", v.VMResourceID) return json.Marshal(objectMap) @@ -1179,7 +1179,7 @@ func (v *VMCollectionUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VMHostListResponse. func (v VMHostListResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", v.NextLink) populate(objectMap, "value", v.Value) return json.Marshal(objectMap) @@ -1210,7 +1210,7 @@ func (v *VMHostListResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VMIngestionDetailsResponse. func (v VMIngestionDetailsResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "cloudId", v.CloudID) populate(objectMap, "ingestionKey", v.IngestionKey) return json.Marshal(objectMap) @@ -1241,7 +1241,7 @@ func (v *VMIngestionDetailsResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VMResources. func (v VMResources) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "vmResourceId", v.VMResourceID) return json.Marshal(objectMap) } @@ -1266,7 +1266,7 @@ func (v *VMResources) UnmarshalJSON(data []byte) error { return nil } -func populate(m map[string]interface{}, k string, v interface{}) { +func populate(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { @@ -1276,7 +1276,7 @@ func populate(m map[string]interface{}, k string, v interface{}) { } } -func unpopulate(data json.RawMessage, fn string, v interface{}) error { +func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil } diff --git a/sdk/resourcemanager/elastic/armelastic/monitor_client.go b/sdk/resourcemanager/elastic/armelastic/monitor_client.go index 01b9dbf28896..7af2fddf773d 100644 --- a/sdk/resourcemanager/elastic/armelastic/monitor_client.go +++ b/sdk/resourcemanager/elastic/armelastic/monitor_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,62 +32,55 @@ import ( // MonitorClient contains the methods for the Monitor group. // Don't use this type directly, use NewMonitorClient() instead. type MonitorClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewMonitorClient creates a new instance of MonitorClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewMonitorClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MonitorClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".MonitorClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &MonitorClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginUpgrade - Upgradable version for a monitor resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - MonitorClientBeginUpgradeOptions contains the optional parameters for the MonitorClient.BeginUpgrade method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - MonitorClientBeginUpgradeOptions contains the optional parameters for the MonitorClient.BeginUpgrade method. func (client *MonitorClient) BeginUpgrade(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorClientBeginUpgradeOptions) (*runtime.Poller[MonitorClientUpgradeResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.upgrade(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - return runtime.NewPoller[MonitorClientUpgradeResponse](resp, client.pl, nil) + return runtime.NewPoller[MonitorClientUpgradeResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[MonitorClientUpgradeResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[MonitorClientUpgradeResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Upgrade - Upgradable version for a monitor resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview func (client *MonitorClient) upgrade(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorClientBeginUpgradeOptions) (*http.Response, error) { req, err := client.upgradeCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -114,7 +105,7 @@ func (client *MonitorClient) upgradeCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elastic/armelastic/monitor_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/monitor_client_example_test.go index 8873cb24c165..4854dc263b56 100644 --- a/sdk/resourcemanager/elastic/armelastic/monitor_client_example_test.go +++ b/sdk/resourcemanager/elastic/armelastic/monitor_client_example_test.go @@ -2,9 +2,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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic_test @@ -16,18 +25,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/Monitor_Upgrade.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/Monitor_Upgrade.json func ExampleMonitorClient_BeginUpgrade() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewMonitorClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpgrade(ctx, "myResourceGroup", "myMonitor", &armelastic.MonitorClientBeginUpgradeOptions{Body: nil}) + poller, err := clientFactory.NewMonitorClient().BeginUpgrade(ctx, "myResourceGroup", "myMonitor", &armelastic.MonitorClientBeginUpgradeOptions{Body: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/elastic/armelastic/monitoredresources_client.go b/sdk/resourcemanager/elastic/armelastic/monitoredresources_client.go index de5ac0575378..c61ddd544f05 100644 --- a/sdk/resourcemanager/elastic/armelastic/monitoredresources_client.go +++ b/sdk/resourcemanager/elastic/armelastic/monitoredresources_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,40 +32,33 @@ import ( // MonitoredResourcesClient contains the methods for the MonitoredResources group. // Don't use this type directly, use NewMonitoredResourcesClient() instead. type MonitoredResourcesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewMonitoredResourcesClient creates a new instance of MonitoredResourcesClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewMonitoredResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MonitoredResourcesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".MonitoredResourcesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &MonitoredResourcesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - List the resources currently being monitored by the Elastic monitor resource. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - MonitoredResourcesClientListOptions contains the optional parameters for the MonitoredResourcesClient.List method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - MonitoredResourcesClientListOptions contains the optional parameters for the MonitoredResourcesClient.NewListPager +// method. func (client *MonitoredResourcesClient) NewListPager(resourceGroupName string, monitorName string, options *MonitoredResourcesClientListOptions) *runtime.Pager[MonitoredResourcesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[MonitoredResourcesClientListResponse]{ More: func(page MonitoredResourcesClientListResponse) bool { @@ -84,7 +75,7 @@ func (client *MonitoredResourcesClient) NewListPager(resourceGroupName string, m if err != nil { return MonitoredResourcesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitoredResourcesClientListResponse{}, err } @@ -111,7 +102,7 @@ func (client *MonitoredResourcesClient) listCreateRequest(ctx context.Context, r return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elastic/armelastic/monitoredresources_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/monitoredresources_client_example_test.go index d517d2b1a470..50e6417db7bf 100644 --- a/sdk/resourcemanager/elastic/armelastic/monitoredresources_client_example_test.go +++ b/sdk/resourcemanager/elastic/armelastic/monitoredresources_client_example_test.go @@ -2,9 +2,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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic_test @@ -16,26 +25,35 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/MonitoredResources_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/MonitoredResources_List.json func ExampleMonitoredResourcesClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewMonitoredResourcesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("myResourceGroup", "myMonitor", nil) + pager := clientFactory.NewMonitoredResourcesClient().NewListPager("myResourceGroup", "myMonitor", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.MonitoredResourceListResponse = armelastic.MonitoredResourceListResponse{ + // Value: []*armelastic.MonitoredResource{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/myVault"), + // ReasonForLogsStatus: to.Ptr("CapturedByRules"), + // SendingLogs: to.Ptr(armelastic.SendingLogsTrue), + // }}, + // } } } diff --git a/sdk/resourcemanager/elastic/armelastic/monitors_client.go b/sdk/resourcemanager/elastic/armelastic/monitors_client.go index 10c91254f3e3..8843078af1bb 100644 --- a/sdk/resourcemanager/elastic/armelastic/monitors_client.go +++ b/sdk/resourcemanager/elastic/armelastic/monitors_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,64 +32,57 @@ import ( // MonitorsClient contains the methods for the Monitors group. // Don't use this type directly, use NewMonitorsClient() instead. type MonitorsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewMonitorsClient creates a new instance of MonitorsClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewMonitorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MonitorsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".MonitorsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &MonitorsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create a monitor resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - MonitorsClientBeginCreateOptions contains the optional parameters for the MonitorsClient.BeginCreate method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - MonitorsClientBeginCreateOptions contains the optional parameters for the MonitorsClient.BeginCreate method. func (client *MonitorsClient) BeginCreate(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientBeginCreateOptions) (*runtime.Poller[MonitorsClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[MonitorsClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MonitorsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[MonitorsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[MonitorsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create a monitor resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview func (client *MonitorsClient) create(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -116,7 +107,7 @@ func (client *MonitorsClient) createCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -132,31 +123,33 @@ func (client *MonitorsClient) createCreateRequest(ctx context.Context, resourceG // BeginDelete - Delete a monitor resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - MonitorsClientBeginDeleteOptions contains the optional parameters for the MonitorsClient.BeginDelete method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - MonitorsClientBeginDeleteOptions contains the optional parameters for the MonitorsClient.BeginDelete method. func (client *MonitorsClient) BeginDelete(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientBeginDeleteOptions) (*runtime.Poller[MonitorsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - return runtime.NewPoller[MonitorsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[MonitorsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[MonitorsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[MonitorsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete a monitor resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview func (client *MonitorsClient) deleteOperation(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -181,7 +174,7 @@ func (client *MonitorsClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -194,16 +187,17 @@ func (client *MonitorsClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Get the properties of a specific monitor resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - MonitorsClientGetOptions contains the optional parameters for the MonitorsClient.Get method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - MonitorsClientGetOptions contains the optional parameters for the MonitorsClient.Get method. func (client *MonitorsClient) Get(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientGetOptions) (MonitorsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return MonitorsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorsClientGetResponse{}, err } @@ -228,7 +222,7 @@ func (client *MonitorsClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -249,8 +243,9 @@ func (client *MonitorsClient) getHandleResponse(resp *http.Response) (MonitorsCl } // NewListPager - List all monitors under the specified subscription. +// // Generated from API version 2022-07-01-preview -// options - MonitorsClientListOptions contains the optional parameters for the MonitorsClient.List method. +// - options - MonitorsClientListOptions contains the optional parameters for the MonitorsClient.NewListPager method. func (client *MonitorsClient) NewListPager(options *MonitorsClientListOptions) *runtime.Pager[MonitorsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[MonitorsClientListResponse]{ More: func(page MonitorsClientListResponse) bool { @@ -267,7 +262,7 @@ func (client *MonitorsClient) NewListPager(options *MonitorsClientListOptions) * if err != nil { return MonitorsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorsClientListResponse{}, err } @@ -286,7 +281,7 @@ func (client *MonitorsClient) listCreateRequest(ctx context.Context, options *Mo return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -307,10 +302,11 @@ func (client *MonitorsClient) listHandleResponse(resp *http.Response) (MonitorsC } // NewListByResourceGroupPager - List all monitors under the specified resource group. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// options - MonitorsClientListByResourceGroupOptions contains the optional parameters for the MonitorsClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - options - MonitorsClientListByResourceGroupOptions contains the optional parameters for the MonitorsClient.NewListByResourceGroupPager +// method. func (client *MonitorsClient) NewListByResourceGroupPager(resourceGroupName string, options *MonitorsClientListByResourceGroupOptions) *runtime.Pager[MonitorsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[MonitorsClientListByResourceGroupResponse]{ More: func(page MonitorsClientListByResourceGroupResponse) bool { @@ -327,7 +323,7 @@ func (client *MonitorsClient) NewListByResourceGroupPager(resourceGroupName stri if err != nil { return MonitorsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorsClientListByResourceGroupResponse{}, err } @@ -350,7 +346,7 @@ func (client *MonitorsClient) listByResourceGroupCreateRequest(ctx context.Conte return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -372,16 +368,17 @@ func (client *MonitorsClient) listByResourceGroupHandleResponse(resp *http.Respo // Update - Update a monitor resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - MonitorsClientUpdateOptions contains the optional parameters for the MonitorsClient.Update method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - MonitorsClientUpdateOptions contains the optional parameters for the MonitorsClient.Update method. func (client *MonitorsClient) Update(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientUpdateOptions) (MonitorsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return MonitorsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorsClientUpdateResponse{}, err } @@ -406,7 +403,7 @@ func (client *MonitorsClient) updateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elastic/armelastic/monitors_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/monitors_client_example_test.go index 1cb2be29ae11..2a1746322a73 100644 --- a/sdk/resourcemanager/elastic/armelastic/monitors_client_example_test.go +++ b/sdk/resourcemanager/elastic/armelastic/monitors_client_example_test.go @@ -2,9 +2,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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic_test @@ -16,85 +25,187 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/Monitors_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/Monitors_List.json func ExampleMonitorsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewMonitorsClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.MonitorResourceListResponse = armelastic.MonitorResourceListResponse{ + // Value: []*armelastic.MonitorResource{ + // { + // Name: to.Ptr("myMonitor"), + // Type: to.Ptr("Microsoft.Elastic/monitors"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/monitors/myMonitor"), + // Location: to.Ptr("West US 2"), + // Properties: &armelastic.MonitorProperties{ + // ElasticProperties: &armelastic.Properties{ + // ElasticCloudDeployment: &armelastic.CloudDeployment{ + // Name: to.Ptr("deploymentname"), + // AzureSubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // DeploymentID: to.Ptr("deployment_id"), + // ElasticsearchRegion: to.Ptr("azure-westus2"), + // ElasticsearchServiceURL: to.Ptr("https://elasticsearchendpoint.com"), + // KibanaServiceURL: to.Ptr("https://kibanaserviceurl.com"), + // KibanaSsoURL: to.Ptr("https://kibanssourl.com"), + // }, + // ElasticCloudUser: &armelastic.CloudUser{ + // ElasticCloudSsoDefaultURL: to.Ptr("https://examplessourl.com"), + // EmailAddress: to.Ptr("alice@microsoft.com"), + // ID: to.Ptr("myid123"), + // }, + // }, + // LiftrResourceCategory: to.Ptr(armelastic.LiftrResourceCategoriesMonitorLogs), + // LiftrResourcePreference: to.Ptr[int32](0), + // MonitoringStatus: to.Ptr(armelastic.MonitoringStatusEnabled), + // ProvisioningState: to.Ptr(armelastic.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/Monitors_ListByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/Monitors_ListByResourceGroup.json func ExampleMonitorsClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("myResourceGroup", nil) + pager := clientFactory.NewMonitorsClient().NewListByResourceGroupPager("myResourceGroup", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.MonitorResourceListResponse = armelastic.MonitorResourceListResponse{ + // Value: []*armelastic.MonitorResource{ + // { + // Name: to.Ptr("myMonitor"), + // Type: to.Ptr("Microsoft.Elastic/monitors"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/monitors/myMonitor"), + // Location: to.Ptr("West US 2"), + // Properties: &armelastic.MonitorProperties{ + // ElasticProperties: &armelastic.Properties{ + // ElasticCloudDeployment: &armelastic.CloudDeployment{ + // Name: to.Ptr("deploymentname"), + // AzureSubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // DeploymentID: to.Ptr("deployment_id"), + // ElasticsearchRegion: to.Ptr("azure-westus2"), + // ElasticsearchServiceURL: to.Ptr("https://elasticsearchendpoint.com"), + // KibanaServiceURL: to.Ptr("https://kibanaserviceurl.com"), + // KibanaSsoURL: to.Ptr("https://kibanssourl.com"), + // }, + // ElasticCloudUser: &armelastic.CloudUser{ + // ElasticCloudSsoDefaultURL: to.Ptr("https://examplessourl.com"), + // EmailAddress: to.Ptr("alice@microsoft.com"), + // ID: to.Ptr("myid123"), + // }, + // }, + // LiftrResourceCategory: to.Ptr(armelastic.LiftrResourceCategoriesMonitorLogs), + // LiftrResourcePreference: to.Ptr[int32](0), + // MonitoringStatus: to.Ptr(armelastic.MonitoringStatusEnabled), + // ProvisioningState: to.Ptr(armelastic.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/Monitors_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/Monitors_Get.json func ExampleMonitorsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "myResourceGroup", "myMonitor", nil) + res, err := clientFactory.NewMonitorsClient().Get(ctx, "myResourceGroup", "myMonitor", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.MonitorResource = armelastic.MonitorResource{ + // Name: to.Ptr("myMonitor"), + // Type: to.Ptr("Microsoft.Elastic/monitors"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/monitors/myMonitor"), + // Location: to.Ptr("West US 2"), + // Properties: &armelastic.MonitorProperties{ + // ElasticProperties: &armelastic.Properties{ + // ElasticCloudDeployment: &armelastic.CloudDeployment{ + // Name: to.Ptr("deploymentname"), + // AzureSubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // DeploymentID: to.Ptr("deployment_id"), + // ElasticsearchRegion: to.Ptr("azure-westus2"), + // ElasticsearchServiceURL: to.Ptr("https://elasticsearchendpoint.com"), + // KibanaServiceURL: to.Ptr("https://kibanaserviceurl.com"), + // KibanaSsoURL: to.Ptr("https://kibanssourl.com"), + // }, + // ElasticCloudUser: &armelastic.CloudUser{ + // ElasticCloudSsoDefaultURL: to.Ptr("https://examplessourl.com"), + // EmailAddress: to.Ptr("alice@microsoft.com"), + // ID: to.Ptr("myid123"), + // }, + // }, + // LiftrResourceCategory: to.Ptr(armelastic.LiftrResourceCategoriesMonitorLogs), + // LiftrResourcePreference: to.Ptr[int32](0), + // MonitoringStatus: to.Ptr(armelastic.MonitoringStatusEnabled), + // ProvisioningState: to.Ptr(armelastic.ProvisioningStateSucceeded), + // }, + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/Monitors_Create.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/Monitors_Create.json func ExampleMonitorsClient_BeginCreate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "myResourceGroup", "myMonitor", &armelastic.MonitorsClientBeginCreateOptions{Body: nil}) + poller, err := clientFactory.NewMonitorsClient().BeginCreate(ctx, "myResourceGroup", "myMonitor", &armelastic.MonitorsClientBeginCreateOptions{Body: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -102,41 +213,108 @@ func ExampleMonitorsClient_BeginCreate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // 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.MonitorResource = armelastic.MonitorResource{ + // Name: to.Ptr("myMonitor"), + // Type: to.Ptr("Microsoft.Elastic/monitors"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/monitors/myMonitor"), + // Location: to.Ptr("West US 2"), + // Properties: &armelastic.MonitorProperties{ + // ElasticProperties: &armelastic.Properties{ + // ElasticCloudDeployment: &armelastic.CloudDeployment{ + // Name: to.Ptr("deploymentname"), + // AzureSubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // DeploymentID: to.Ptr("deployment_id"), + // ElasticsearchRegion: to.Ptr("azure-westus2"), + // ElasticsearchServiceURL: to.Ptr("https://elasticsearchendpoint.com"), + // KibanaServiceURL: to.Ptr("https://kibanaserviceurl.com"), + // KibanaSsoURL: to.Ptr("https://kibanssourl.com"), + // }, + // ElasticCloudUser: &armelastic.CloudUser{ + // ElasticCloudSsoDefaultURL: to.Ptr("https://examplessourl.com"), + // EmailAddress: to.Ptr("alice@microsoft.com"), + // ID: to.Ptr("myid123"), + // }, + // }, + // ProvisioningState: to.Ptr(armelastic.ProvisioningStateSucceeded), + // }, + // SKU: &armelastic.ResourceSKU{ + // Name: to.Ptr("free_Monthly"), + // }, + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/Monitors_Update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/Monitors_Update.json func ExampleMonitorsClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, "myResourceGroup", "myMonitor", &armelastic.MonitorsClientUpdateOptions{Body: nil}) + res, err := clientFactory.NewMonitorsClient().Update(ctx, "myResourceGroup", "myMonitor", &armelastic.MonitorsClientUpdateOptions{Body: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.MonitorResource = armelastic.MonitorResource{ + // Name: to.Ptr("myMonitor"), + // Type: to.Ptr("Microsoft.Elastic/monitors"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/monitors/myMonitor"), + // Location: to.Ptr("West US 2"), + // Properties: &armelastic.MonitorProperties{ + // ElasticProperties: &armelastic.Properties{ + // ElasticCloudDeployment: &armelastic.CloudDeployment{ + // Name: to.Ptr("deploymentname"), + // AzureSubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // DeploymentID: to.Ptr("deployment_id"), + // ElasticsearchRegion: to.Ptr("azure-westus2"), + // ElasticsearchServiceURL: to.Ptr("https://elasticsearchendpoint.com"), + // KibanaServiceURL: to.Ptr("https://kibanaserviceurl.com"), + // KibanaSsoURL: to.Ptr("https://kibanssourl.com"), + // }, + // ElasticCloudUser: &armelastic.CloudUser{ + // ElasticCloudSsoDefaultURL: to.Ptr("https://examplessourl.com"), + // EmailAddress: to.Ptr("alice@microsoft.com"), + // ID: to.Ptr("myid123"), + // }, + // }, + // LiftrResourceCategory: to.Ptr(armelastic.LiftrResourceCategoriesMonitorLogs), + // LiftrResourcePreference: to.Ptr[int32](0), + // MonitoringStatus: to.Ptr(armelastic.MonitoringStatusEnabled), + // ProvisioningState: to.Ptr(armelastic.ProvisioningStateSucceeded), + // }, + // SKU: &armelastic.ResourceSKU{ + // Name: to.Ptr("free_Monthly"), + // }, + // Tags: map[string]*string{ + // "Environment": to.Ptr("Dev"), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/Monitors_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/Monitors_Delete.json func ExampleMonitorsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "myResourceGroup", "myMonitor", nil) + poller, err := clientFactory.NewMonitorsClient().BeginDelete(ctx, "myResourceGroup", "myMonitor", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/elastic/armelastic/operations_client.go b/sdk/resourcemanager/elastic/armelastic/operations_client.go index be3f5e8cd80a..e00b96189a79 100644 --- a/sdk/resourcemanager/elastic/armelastic/operations_client.go +++ b/sdk/resourcemanager/elastic/armelastic/operations_client.go @@ -21,8 +21,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -31,35 +29,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - List all operations provided by Microsoft.Elastic. +// // Generated from API version 2022-07-01-preview -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - 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 { @@ -76,7 +66,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -91,7 +81,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Elastic/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elastic/armelastic/operations_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/operations_client_example_test.go index 042f74a3063a..73a261ef159f 100644 --- a/sdk/resourcemanager/elastic/armelastic/operations_client_example_test.go +++ b/sdk/resourcemanager/elastic/armelastic/operations_client_example_test.go @@ -2,9 +2,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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic_test @@ -16,26 +25,39 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/Operations_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-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() - client, err := armelastic.NewOperationsClient(cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewOperationsClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.OperationListResult = armelastic.OperationListResult{ + // Value: []*armelastic.OperationResult{ + // { + // Name: to.Ptr("Microsoft.Elastic/monitors/write"), + // Display: &armelastic.OperationDisplay{ + // Description: to.Ptr("Write monitors resource"), + // Operation: to.Ptr("write"), + // Provider: to.Ptr("Microsoft.Elastic"), + // Resource: to.Ptr("monitors"), + // }, + // }}, + // } } } diff --git a/sdk/resourcemanager/elastic/armelastic/response_types.go b/sdk/resourcemanager/elastic/armelastic/response_types.go index 9bafdd026e51..f759805c35f6 100644 --- a/sdk/resourcemanager/elastic/armelastic/response_types.go +++ b/sdk/resourcemanager/elastic/armelastic/response_types.go @@ -22,17 +22,17 @@ type AllTrafficFiltersClientListResponse struct { TrafficFilterResponse } -// AssociateTrafficFilterClientAssociateResponse contains the response from method AssociateTrafficFilterClient.Associate. +// AssociateTrafficFilterClientAssociateResponse contains the response from method AssociateTrafficFilterClient.BeginAssociate. type AssociateTrafficFilterClientAssociateResponse struct { // placeholder for future response values } -// CreateAndAssociateIPFilterClientCreateResponse contains the response from method CreateAndAssociateIPFilterClient.Create. +// CreateAndAssociateIPFilterClientCreateResponse contains the response from method CreateAndAssociateIPFilterClient.BeginCreate. type CreateAndAssociateIPFilterClientCreateResponse struct { // placeholder for future response values } -// CreateAndAssociatePLFilterClientCreateResponse contains the response from method CreateAndAssociatePLFilterClient.Create. +// CreateAndAssociatePLFilterClientCreateResponse contains the response from method CreateAndAssociatePLFilterClient.BeginCreate. type CreateAndAssociatePLFilterClientCreateResponse struct { // placeholder for future response values } @@ -47,7 +47,7 @@ type DetachAndDeleteTrafficFilterClientDeleteResponse struct { // placeholder for future response values } -// DetachTrafficFilterClientUpdateResponse contains the response from method DetachTrafficFilterClient.Update. +// DetachTrafficFilterClientUpdateResponse contains the response from method DetachTrafficFilterClient.BeginUpdate. type DetachTrafficFilterClientUpdateResponse struct { // placeholder for future response values } @@ -62,22 +62,22 @@ type ListAssociatedTrafficFiltersClientListResponse struct { TrafficFilterResponse } -// MonitorClientUpgradeResponse contains the response from method MonitorClient.Upgrade. +// MonitorClientUpgradeResponse contains the response from method MonitorClient.BeginUpgrade. type MonitorClientUpgradeResponse struct { // placeholder for future response values } -// MonitoredResourcesClientListResponse contains the response from method MonitoredResourcesClient.List. +// MonitoredResourcesClientListResponse contains the response from method MonitoredResourcesClient.NewListPager. type MonitoredResourcesClientListResponse struct { MonitoredResourceListResponse } -// MonitorsClientCreateResponse contains the response from method MonitorsClient.Create. +// MonitorsClientCreateResponse contains the response from method MonitorsClient.BeginCreate. type MonitorsClientCreateResponse struct { MonitorResource } -// MonitorsClientDeleteResponse contains the response from method MonitorsClient.Delete. +// MonitorsClientDeleteResponse contains the response from method MonitorsClient.BeginDelete. type MonitorsClientDeleteResponse struct { // placeholder for future response values } @@ -87,12 +87,12 @@ type MonitorsClientGetResponse struct { MonitorResource } -// MonitorsClientListByResourceGroupResponse contains the response from method MonitorsClient.ListByResourceGroup. +// MonitorsClientListByResourceGroupResponse contains the response from method MonitorsClient.NewListByResourceGroupPager. type MonitorsClientListByResourceGroupResponse struct { MonitorResourceListResponse } -// MonitorsClientListResponse contains the response from method MonitorsClient.List. +// MonitorsClientListResponse contains the response from method MonitorsClient.NewListPager. type MonitorsClientListResponse struct { MonitorResourceListResponse } @@ -102,7 +102,7 @@ type MonitorsClientUpdateResponse struct { MonitorResource } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationListResult } @@ -112,7 +112,7 @@ type TagRulesClientCreateOrUpdateResponse struct { MonitoringTagRules } -// TagRulesClientDeleteResponse contains the response from method TagRulesClient.Delete. +// TagRulesClientDeleteResponse contains the response from method TagRulesClient.BeginDelete. type TagRulesClientDeleteResponse struct { // placeholder for future response values } @@ -122,7 +122,7 @@ type TagRulesClientGetResponse struct { MonitoringTagRules } -// TagRulesClientListResponse contains the response from method TagRulesClient.List. +// TagRulesClientListResponse contains the response from method TagRulesClient.NewListPager. type TagRulesClientListResponse struct { MonitoringTagRulesListResponse } @@ -142,7 +142,7 @@ type VMCollectionClientUpdateResponse struct { // placeholder for future response values } -// VMHostClientListResponse contains the response from method VMHostClient.List. +// VMHostClientListResponse contains the response from method VMHostClient.NewListPager. type VMHostClientListResponse struct { VMHostListResponse } diff --git a/sdk/resourcemanager/elastic/armelastic/tagrules_client.go b/sdk/resourcemanager/elastic/armelastic/tagrules_client.go index 33ec9c128a81..b0b8400c06fb 100644 --- a/sdk/resourcemanager/elastic/armelastic/tagrules_client.go +++ b/sdk/resourcemanager/elastic/armelastic/tagrules_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,48 +32,40 @@ import ( // TagRulesClient contains the methods for the TagRules group. // Don't use this type directly, use NewTagRulesClient() instead. type TagRulesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewTagRulesClient creates a new instance of TagRulesClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewTagRulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TagRulesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".TagRulesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &TagRulesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or update a tag rule set for a given monitor resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// ruleSetName - Tag Rule Set resource name -// options - TagRulesClientCreateOrUpdateOptions contains the optional parameters for the TagRulesClient.CreateOrUpdate method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - ruleSetName - Tag Rule Set resource name +// - options - TagRulesClientCreateOrUpdateOptions contains the optional parameters for the TagRulesClient.CreateOrUpdate method. func (client *TagRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientCreateOrUpdateOptions) (TagRulesClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, monitorName, ruleSetName, options) if err != nil { return TagRulesClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TagRulesClientCreateOrUpdateResponse{}, err } @@ -104,7 +94,7 @@ func (client *TagRulesClient) createOrUpdateCreateRequest(ctx context.Context, r return nil, errors.New("parameter ruleSetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ruleSetName}", url.PathEscape(ruleSetName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -129,32 +119,34 @@ func (client *TagRulesClient) createOrUpdateHandleResponse(resp *http.Response) // BeginDelete - Delete a tag rule set for a given monitor resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// ruleSetName - Tag Rule Set resource name -// options - TagRulesClientBeginDeleteOptions contains the optional parameters for the TagRulesClient.BeginDelete method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - ruleSetName - Tag Rule Set resource name +// - options - TagRulesClientBeginDeleteOptions contains the optional parameters for the TagRulesClient.BeginDelete method. func (client *TagRulesClient) BeginDelete(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientBeginDeleteOptions) (*runtime.Poller[TagRulesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, monitorName, ruleSetName, options) if err != nil { return nil, err } - return runtime.NewPoller[TagRulesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[TagRulesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[TagRulesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[TagRulesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete a tag rule set for a given monitor resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview func (client *TagRulesClient) deleteOperation(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, monitorName, ruleSetName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -183,7 +175,7 @@ func (client *TagRulesClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter ruleSetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ruleSetName}", url.PathEscape(ruleSetName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -196,17 +188,18 @@ func (client *TagRulesClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Get a tag rule set for a given monitor resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// ruleSetName - Tag Rule Set resource name -// options - TagRulesClientGetOptions contains the optional parameters for the TagRulesClient.Get method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - ruleSetName - Tag Rule Set resource name +// - options - TagRulesClientGetOptions contains the optional parameters for the TagRulesClient.Get method. func (client *TagRulesClient) Get(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientGetOptions) (TagRulesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, monitorName, ruleSetName, options) if err != nil { return TagRulesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TagRulesClientGetResponse{}, err } @@ -235,7 +228,7 @@ func (client *TagRulesClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter ruleSetName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{ruleSetName}", url.PathEscape(ruleSetName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -256,10 +249,11 @@ func (client *TagRulesClient) getHandleResponse(resp *http.Response) (TagRulesCl } // NewListPager - List the tag rules for a given monitor resource. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - TagRulesClientListOptions contains the optional parameters for the TagRulesClient.List method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - TagRulesClientListOptions contains the optional parameters for the TagRulesClient.NewListPager method. func (client *TagRulesClient) NewListPager(resourceGroupName string, monitorName string, options *TagRulesClientListOptions) *runtime.Pager[TagRulesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[TagRulesClientListResponse]{ More: func(page TagRulesClientListResponse) bool { @@ -276,7 +270,7 @@ func (client *TagRulesClient) NewListPager(resourceGroupName string, monitorName if err != nil { return TagRulesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TagRulesClientListResponse{}, err } @@ -303,7 +297,7 @@ func (client *TagRulesClient) listCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elastic/armelastic/tagrules_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/tagrules_client_example_test.go index 2c3a9aa87425..6ebfe4fefc93 100644 --- a/sdk/resourcemanager/elastic/armelastic/tagrules_client_example_test.go +++ b/sdk/resourcemanager/elastic/armelastic/tagrules_client_example_test.go @@ -2,9 +2,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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic_test @@ -16,80 +25,158 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/TagRules_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/TagRules_List.json func ExampleTagRulesClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewTagRulesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("myResourceGroup", "myMonitor", nil) + pager := clientFactory.NewTagRulesClient().NewListPager("myResourceGroup", "myMonitor", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.MonitoringTagRulesListResponse = armelastic.MonitoringTagRulesListResponse{ + // Value: []*armelastic.MonitoringTagRules{ + // { + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Datadog/monitors/tagRules"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Datadog/monitors/myMonitor/tagRules/default"), + // Properties: &armelastic.MonitoringTagRulesProperties{ + // LogRules: &armelastic.LogRules{ + // FilteringTags: []*armelastic.FilteringTag{ + // { + // Name: to.Ptr("Environment"), + // Action: to.Ptr(armelastic.TagActionInclude), + // Value: to.Ptr("Prod"), + // }, + // { + // Name: to.Ptr("Environment"), + // Action: to.Ptr(armelastic.TagActionExclude), + // Value: to.Ptr("Dev"), + // }}, + // SendAADLogs: to.Ptr(false), + // SendActivityLogs: to.Ptr(true), + // SendSubscriptionLogs: to.Ptr(true), + // }, + // ProvisioningState: to.Ptr(armelastic.ProvisioningStateSucceeded), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/TagRules_CreateOrUpdate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/TagRules_CreateOrUpdate.json func ExampleTagRulesClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewTagRulesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.CreateOrUpdate(ctx, "myResourceGroup", "myMonitor", "default", &armelastic.TagRulesClientCreateOrUpdateOptions{Body: nil}) + res, err := clientFactory.NewTagRulesClient().CreateOrUpdate(ctx, "myResourceGroup", "myMonitor", "default", &armelastic.TagRulesClientCreateOrUpdateOptions{Body: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.MonitoringTagRules = armelastic.MonitoringTagRules{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Datadog/monitors/tagRules"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Datadog/monitors/myMonitor/tagRules/default"), + // Properties: &armelastic.MonitoringTagRulesProperties{ + // LogRules: &armelastic.LogRules{ + // FilteringTags: []*armelastic.FilteringTag{ + // { + // Name: to.Ptr("Environment"), + // Action: to.Ptr(armelastic.TagActionInclude), + // Value: to.Ptr("Prod"), + // }, + // { + // Name: to.Ptr("Environment"), + // Action: to.Ptr(armelastic.TagActionExclude), + // Value: to.Ptr("Dev"), + // }}, + // SendAADLogs: to.Ptr(false), + // SendActivityLogs: to.Ptr(true), + // SendSubscriptionLogs: to.Ptr(true), + // }, + // ProvisioningState: to.Ptr(armelastic.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/TagRules_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/TagRules_Get.json func ExampleTagRulesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewTagRulesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "myResourceGroup", "myMonitor", "default", nil) + res, err := clientFactory.NewTagRulesClient().Get(ctx, "myResourceGroup", "myMonitor", "default", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.MonitoringTagRules = armelastic.MonitoringTagRules{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.Datadog/monitors/tagRules"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Datadog/monitors/myMonitor/tagRules/default"), + // Properties: &armelastic.MonitoringTagRulesProperties{ + // LogRules: &armelastic.LogRules{ + // FilteringTags: []*armelastic.FilteringTag{ + // { + // Name: to.Ptr("Environment"), + // Action: to.Ptr(armelastic.TagActionInclude), + // Value: to.Ptr("Prod"), + // }, + // { + // Name: to.Ptr("Environment"), + // Action: to.Ptr(armelastic.TagActionExclude), + // Value: to.Ptr("Dev"), + // }}, + // SendAADLogs: to.Ptr(false), + // SendActivityLogs: to.Ptr(true), + // SendSubscriptionLogs: to.Ptr(true), + // }, + // ProvisioningState: to.Ptr(armelastic.ProvisioningStateSucceeded), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/TagRules_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/TagRules_Delete.json func ExampleTagRulesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewTagRulesClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "myResourceGroup", "myMonitor", "default", nil) + poller, err := clientFactory.NewTagRulesClient().BeginDelete(ctx, "myResourceGroup", "myMonitor", "default", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/elastic/armelastic/time_rfc3339.go b/sdk/resourcemanager/elastic/armelastic/time_rfc3339.go index 90e750315192..f95524655b97 100644 --- a/sdk/resourcemanager/elastic/armelastic/time_rfc3339.go +++ b/sdk/resourcemanager/elastic/armelastic/time_rfc3339.go @@ -70,7 +70,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/elastic/armelastic/trafficfilters_client.go b/sdk/resourcemanager/elastic/armelastic/trafficfilters_client.go index 9e985e23b41a..6462b4cdb335 100644 --- a/sdk/resourcemanager/elastic/armelastic/trafficfilters_client.go +++ b/sdk/resourcemanager/elastic/armelastic/trafficfilters_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,47 +32,39 @@ import ( // TrafficFiltersClient contains the methods for the TrafficFilters group. // Don't use this type directly, use NewTrafficFiltersClient() instead. type TrafficFiltersClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewTrafficFiltersClient creates a new instance of TrafficFiltersClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewTrafficFiltersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TrafficFiltersClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".TrafficFiltersClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &TrafficFiltersClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Delete - Delete traffic filter from the account. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - TrafficFiltersClientDeleteOptions contains the optional parameters for the TrafficFiltersClient.Delete method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - TrafficFiltersClientDeleteOptions contains the optional parameters for the TrafficFiltersClient.Delete method. func (client *TrafficFiltersClient) Delete(ctx context.Context, resourceGroupName string, monitorName string, options *TrafficFiltersClientDeleteOptions) (TrafficFiltersClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return TrafficFiltersClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return TrafficFiltersClientDeleteResponse{}, err } @@ -99,7 +89,7 @@ func (client *TrafficFiltersClient) deleteCreateRequest(ctx context.Context, res return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elastic/armelastic/trafficfilters_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/trafficfilters_client_example_test.go index c2e1c28c65e8..fe83a902851c 100644 --- a/sdk/resourcemanager/elastic/armelastic/trafficfilters_client_example_test.go +++ b/sdk/resourcemanager/elastic/armelastic/trafficfilters_client_example_test.go @@ -2,9 +2,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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic_test @@ -17,18 +26,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/TrafficFilters_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/TrafficFilters_Delete.json func ExampleTrafficFiltersClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewTrafficFiltersClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, "myResourceGroup", "myMonitor", &armelastic.TrafficFiltersClientDeleteOptions{RulesetID: to.Ptr("31d91b5afb6f4c2eaaf104c97b1991dd")}) + _, err = clientFactory.NewTrafficFiltersClient().Delete(ctx, "myResourceGroup", "myMonitor", &armelastic.TrafficFiltersClientDeleteOptions{RulesetID: to.Ptr("31d91b5afb6f4c2eaaf104c97b1991dd")}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/elastic/armelastic/upgradableversions_client.go b/sdk/resourcemanager/elastic/armelastic/upgradableversions_client.go index 2756ca2a8488..9f45250ea4b4 100644 --- a/sdk/resourcemanager/elastic/armelastic/upgradableversions_client.go +++ b/sdk/resourcemanager/elastic/armelastic/upgradableversions_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,48 +32,40 @@ import ( // UpgradableVersionsClient contains the methods for the UpgradableVersions group. // Don't use this type directly, use NewUpgradableVersionsClient() instead. type UpgradableVersionsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewUpgradableVersionsClient creates a new instance of UpgradableVersionsClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewUpgradableVersionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*UpgradableVersionsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".UpgradableVersionsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &UpgradableVersionsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Details - List of upgradable versions for a given monitor resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - UpgradableVersionsClientDetailsOptions contains the optional parameters for the UpgradableVersionsClient.Details -// method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - UpgradableVersionsClientDetailsOptions contains the optional parameters for the UpgradableVersionsClient.Details +// method. func (client *UpgradableVersionsClient) Details(ctx context.Context, resourceGroupName string, monitorName string, options *UpgradableVersionsClientDetailsOptions) (UpgradableVersionsClientDetailsResponse, error) { req, err := client.detailsCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return UpgradableVersionsClientDetailsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return UpgradableVersionsClientDetailsResponse{}, err } @@ -100,7 +90,7 @@ func (client *UpgradableVersionsClient) detailsCreateRequest(ctx context.Context return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elastic/armelastic/upgradableversions_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/upgradableversions_client_example_test.go index 2d20a4d93ed9..d627eb2c245c 100644 --- a/sdk/resourcemanager/elastic/armelastic/upgradableversions_client_example_test.go +++ b/sdk/resourcemanager/elastic/armelastic/upgradableversions_client_example_test.go @@ -2,9 +2,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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic_test @@ -16,21 +25,28 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/UpgradableVersions_Details.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/UpgradableVersions_Details.json func ExampleUpgradableVersionsClient_Details() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewUpgradableVersionsClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Details(ctx, "myResourceGroup", "myMonitor", nil) + res, err := clientFactory.NewUpgradableVersionsClient().Details(ctx, "myResourceGroup", "myMonitor", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.UpgradableVersionsList = armelastic.UpgradableVersionsList{ + // CurrentVersion: to.Ptr("7.15.0"), + // UpgradableVersions: []*string{ + // to.Ptr("7.15.1"), + // to.Ptr("7.16.0")}, + // } } diff --git a/sdk/resourcemanager/elastic/armelastic/vmcollection_client.go b/sdk/resourcemanager/elastic/armelastic/vmcollection_client.go index 9d408c9e3954..1e006b7ba2ac 100644 --- a/sdk/resourcemanager/elastic/armelastic/vmcollection_client.go +++ b/sdk/resourcemanager/elastic/armelastic/vmcollection_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,47 +32,39 @@ import ( // VMCollectionClient contains the methods for the VMCollection group. // Don't use this type directly, use NewVMCollectionClient() instead. type VMCollectionClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewVMCollectionClient creates a new instance of VMCollectionClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewVMCollectionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VMCollectionClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".VMCollectionClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &VMCollectionClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Update - Update the vm details that will be monitored by the Elastic monitor resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - VMCollectionClientUpdateOptions contains the optional parameters for the VMCollectionClient.Update method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - VMCollectionClientUpdateOptions contains the optional parameters for the VMCollectionClient.Update method. func (client *VMCollectionClient) Update(ctx context.Context, resourceGroupName string, monitorName string, options *VMCollectionClientUpdateOptions) (VMCollectionClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return VMCollectionClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VMCollectionClientUpdateResponse{}, err } @@ -99,7 +89,7 @@ func (client *VMCollectionClient) updateCreateRequest(ctx context.Context, resou return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elastic/armelastic/vmcollection_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/vmcollection_client_example_test.go index 2b7a78b82cd8..9e610064c6d3 100644 --- a/sdk/resourcemanager/elastic/armelastic/vmcollection_client_example_test.go +++ b/sdk/resourcemanager/elastic/armelastic/vmcollection_client_example_test.go @@ -2,9 +2,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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic_test @@ -16,18 +25,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/VMCollection_Update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/VMCollection_Update.json func ExampleVMCollectionClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewVMCollectionClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Update(ctx, "myResourceGroup", "myMonitor", &armelastic.VMCollectionClientUpdateOptions{Body: nil}) + _, err = clientFactory.NewVMCollectionClient().Update(ctx, "myResourceGroup", "myMonitor", &armelastic.VMCollectionClientUpdateOptions{Body: nil}) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/elastic/armelastic/vmhost_client.go b/sdk/resourcemanager/elastic/armelastic/vmhost_client.go index 5fcce2e69f40..141707163c38 100644 --- a/sdk/resourcemanager/elastic/armelastic/vmhost_client.go +++ b/sdk/resourcemanager/elastic/armelastic/vmhost_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,40 +32,32 @@ import ( // VMHostClient contains the methods for the VMHost group. // Don't use this type directly, use NewVMHostClient() instead. type VMHostClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewVMHostClient creates a new instance of VMHostClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewVMHostClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VMHostClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".VMHostClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &VMHostClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - List the vm resources currently being monitored by the Elastic monitor resource. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - VMHostClientListOptions contains the optional parameters for the VMHostClient.List method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - VMHostClientListOptions contains the optional parameters for the VMHostClient.NewListPager method. func (client *VMHostClient) NewListPager(resourceGroupName string, monitorName string, options *VMHostClientListOptions) *runtime.Pager[VMHostClientListResponse] { return runtime.NewPager(runtime.PagingHandler[VMHostClientListResponse]{ More: func(page VMHostClientListResponse) bool { @@ -84,7 +74,7 @@ func (client *VMHostClient) NewListPager(resourceGroupName string, monitorName s if err != nil { return VMHostClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VMHostClientListResponse{}, err } @@ -111,7 +101,7 @@ func (client *VMHostClient) listCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elastic/armelastic/vmhost_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/vmhost_client_example_test.go index 9ed96a8c9e30..c9063c9b7488 100644 --- a/sdk/resourcemanager/elastic/armelastic/vmhost_client_example_test.go +++ b/sdk/resourcemanager/elastic/armelastic/vmhost_client_example_test.go @@ -2,9 +2,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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic_test @@ -16,26 +25,33 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/VMHost_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/VMHost_List.json func ExampleVMHostClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewVMHostClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager("myResourceGroup", "myMonitor", nil) + pager := clientFactory.NewVMHostClient().NewListPager("myResourceGroup", "myMonitor", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.VMHostListResponse = armelastic.VMHostListResponse{ + // Value: []*armelastic.VMResources{ + // { + // VMResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualmachines/myVM"), + // }}, + // } } } diff --git a/sdk/resourcemanager/elastic/armelastic/vmingestion_client.go b/sdk/resourcemanager/elastic/armelastic/vmingestion_client.go index 7c3d1b9734c4..e5cd932e5f44 100644 --- a/sdk/resourcemanager/elastic/armelastic/vmingestion_client.go +++ b/sdk/resourcemanager/elastic/armelastic/vmingestion_client.go @@ -22,8 +22,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -34,47 +32,39 @@ import ( // VMIngestionClient contains the methods for the VMIngestion group. // Don't use this type directly, use NewVMIngestionClient() instead. type VMIngestionClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewVMIngestionClient creates a new instance of VMIngestionClient with the specified values. -// subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000) +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewVMIngestionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VMIngestionClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".VMIngestionClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &VMIngestionClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Details - List the vm ingestion details that will be monitored by the Elastic monitor resource. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-07-01-preview -// resourceGroupName - The name of the resource group to which the Elastic resource belongs. -// monitorName - Monitor resource name -// options - VMIngestionClientDetailsOptions contains the optional parameters for the VMIngestionClient.Details method. +// - resourceGroupName - The name of the resource group to which the Elastic resource belongs. +// - monitorName - Monitor resource name +// - options - VMIngestionClientDetailsOptions contains the optional parameters for the VMIngestionClient.Details method. func (client *VMIngestionClient) Details(ctx context.Context, resourceGroupName string, monitorName string, options *VMIngestionClientDetailsOptions) (VMIngestionClientDetailsResponse, error) { req, err := client.detailsCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return VMIngestionClientDetailsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VMIngestionClientDetailsResponse{}, err } @@ -99,7 +89,7 @@ func (client *VMIngestionClient) detailsCreateRequest(ctx context.Context, resou return nil, errors.New("parameter monitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{monitorName}", url.PathEscape(monitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elastic/armelastic/vmingestion_client_example_test.go b/sdk/resourcemanager/elastic/armelastic/vmingestion_client_example_test.go index ae43631a2b5c..0f1f1ae8375e 100644 --- a/sdk/resourcemanager/elastic/armelastic/vmingestion_client_example_test.go +++ b/sdk/resourcemanager/elastic/armelastic/vmingestion_client_example_test.go @@ -2,9 +2,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. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// 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 armelastic_test @@ -16,21 +25,26 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elastic/armelastic" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/VMIngestion_Details.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/232b858812a4f946a82bc11a81241826f5554fbd/specification/elastic/resource-manager/Microsoft.Elastic/preview/2022-07-01-preview/examples/VMIngestion_Details.json func ExampleVMIngestionClient_Details() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelastic.NewVMIngestionClient("00000000-0000-0000-0000-000000000000", cred, nil) + clientFactory, err := armelastic.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Details(ctx, "myResourceGroup", "myMonitor", nil) + res, err := clientFactory.NewVMIngestionClient().Details(ctx, "myResourceGroup", "myMonitor", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.VMIngestionDetailsResponse = armelastic.VMIngestionDetailsResponse{ + // CloudID: to.Ptr("myid123"), + // IngestionKey: to.Ptr("Vmingeationkey"), + // } } diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/CHANGELOG.md b/sdk/resourcemanager/elasticsan/armelasticsan/CHANGELOG.md index 3c5709f8bbeb..98f1be75e044 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/CHANGELOG.md +++ b/sdk/resourcemanager/elasticsan/armelasticsan/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 0.2.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 0.1.0 (2022-10-21) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elasticsan/armelasticsan` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/README.md b/sdk/resourcemanager/elasticsan/armelasticsan/README.md index ad982695ff8a..8fc4eda8e97a 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/README.md +++ b/sdk/resourcemanager/elasticsan/armelasticsan/README.md @@ -33,23 +33,31 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Elasticsan modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Elasticsan module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armelasticsan.NewVolumesClient(, cred, nil) +clientFactory, err := armelasticsan.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). ```go -options := arm.ClientOptions{ +options := arm.ClientOptions { ClientOptions: azcore.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armelasticsan.NewVolumesClient(, cred, &options) +clientFactory, err := armelasticsan.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewElasticSansClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/autorest.md b/sdk/resourcemanager/elasticsan/armelasticsan/autorest.md index 47e9a6a56cbe..9e2ab04d005b 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/autorest.md +++ b/sdk/resourcemanager/elasticsan/armelasticsan/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.1.0 +module-version: 0.2.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/client_factory.go b/sdk/resourcemanager/elasticsan/armelasticsan/client_factory.go new file mode 100644 index 000000000000..d17ebfb05706 --- /dev/null +++ b/sdk/resourcemanager/elasticsan/armelasticsan/client_factory.go @@ -0,0 +1,64 @@ +//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 armelasticsan + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSKUsClient() *SKUsClient { + subClient, _ := NewSKUsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewElasticSansClient() *ElasticSansClient { + subClient, _ := NewElasticSansClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVolumeGroupsClient() *VolumeGroupsClient { + subClient, _ := NewVolumeGroupsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVolumesClient() *VolumesClient { + subClient, _ := NewVolumesClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/constants.go b/sdk/resourcemanager/elasticsan/armelasticsan/constants.go index 03902965f887..b4c5262987d1 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/constants.go +++ b/sdk/resourcemanager/elasticsan/armelasticsan/constants.go @@ -11,7 +11,7 @@ package armelasticsan const ( moduleName = "armelasticsan" - moduleVersion = "v0.1.0" + moduleVersion = "v0.2.0" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/elasticsans_client.go b/sdk/resourcemanager/elasticsan/armelasticsan/elasticsans_client.go index 527bd64318e8..34dda5ad1077 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/elasticsans_client.go +++ b/sdk/resourcemanager/elasticsan/armelasticsan/elasticsans_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,65 +24,58 @@ import ( // ElasticSansClient contains the methods for the ElasticSans group. // Don't use this type directly, use NewElasticSansClient() instead. type ElasticSansClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewElasticSansClient creates a new instance of ElasticSansClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewElasticSansClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ElasticSansClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ElasticSansClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ElasticSansClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create ElasticSan. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// elasticSanName - The name of the ElasticSan. -// parameters - Elastic San object. -// options - ElasticSansClientBeginCreateOptions contains the optional parameters for the ElasticSansClient.BeginCreate method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - elasticSanName - The name of the ElasticSan. +// - parameters - Elastic San object. +// - options - ElasticSansClientBeginCreateOptions contains the optional parameters for the ElasticSansClient.BeginCreate method. func (client *ElasticSansClient) BeginCreate(ctx context.Context, resourceGroupName string, elasticSanName string, parameters ElasticSan, options *ElasticSansClientBeginCreateOptions) (*runtime.Poller[ElasticSansClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, elasticSanName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ElasticSansClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ElasticSansClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[ElasticSansClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ElasticSansClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create ElasticSan. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview func (client *ElasticSansClient) create(ctx context.Context, resourceGroupName string, elasticSanName string, parameters ElasticSan, options *ElasticSansClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, elasticSanName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -109,7 +100,7 @@ func (client *ElasticSansClient) createCreateRequest(ctx context.Context, resour return nil, errors.New("parameter elasticSanName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{elasticSanName}", url.PathEscape(elasticSanName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -122,33 +113,35 @@ func (client *ElasticSansClient) createCreateRequest(ctx context.Context, resour // BeginDelete - Delete a Elastic San. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// elasticSanName - The name of the ElasticSan. -// options - ElasticSansClientBeginDeleteOptions contains the optional parameters for the ElasticSansClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - elasticSanName - The name of the ElasticSan. +// - options - ElasticSansClientBeginDeleteOptions contains the optional parameters for the ElasticSansClient.BeginDelete method. func (client *ElasticSansClient) BeginDelete(ctx context.Context, resourceGroupName string, elasticSanName string, options *ElasticSansClientBeginDeleteOptions) (*runtime.Poller[ElasticSansClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, elasticSanName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ElasticSansClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ElasticSansClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[ElasticSansClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ElasticSansClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete a Elastic San. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview func (client *ElasticSansClient) deleteOperation(ctx context.Context, resourceGroupName string, elasticSanName string, options *ElasticSansClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, elasticSanName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -173,7 +166,7 @@ func (client *ElasticSansClient) deleteCreateRequest(ctx context.Context, resour return nil, errors.New("parameter elasticSanName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{elasticSanName}", url.PathEscape(elasticSanName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -186,16 +179,17 @@ func (client *ElasticSansClient) deleteCreateRequest(ctx context.Context, resour // Get - Get a ElasticSan. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// elasticSanName - The name of the ElasticSan. -// options - ElasticSansClientGetOptions contains the optional parameters for the ElasticSansClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - elasticSanName - The name of the ElasticSan. +// - options - ElasticSansClientGetOptions contains the optional parameters for the ElasticSansClient.Get method. func (client *ElasticSansClient) Get(ctx context.Context, resourceGroupName string, elasticSanName string, options *ElasticSansClientGetOptions) (ElasticSansClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, elasticSanName, options) if err != nil { return ElasticSansClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ElasticSansClientGetResponse{}, err } @@ -220,7 +214,7 @@ func (client *ElasticSansClient) getCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter elasticSanName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{elasticSanName}", url.PathEscape(elasticSanName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -241,10 +235,11 @@ func (client *ElasticSansClient) getHandleResponse(resp *http.Response) (Elastic } // NewListByResourceGroupPager - Gets a list of ElasticSan in a resource group. +// // Generated from API version 2021-11-20-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - ElasticSansClientListByResourceGroupOptions contains the optional parameters for the ElasticSansClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ElasticSansClientListByResourceGroupOptions contains the optional parameters for the ElasticSansClient.NewListByResourceGroupPager +// method. func (client *ElasticSansClient) NewListByResourceGroupPager(resourceGroupName string, options *ElasticSansClientListByResourceGroupOptions) *runtime.Pager[ElasticSansClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[ElasticSansClientListByResourceGroupResponse]{ More: func(page ElasticSansClientListByResourceGroupResponse) bool { @@ -261,7 +256,7 @@ func (client *ElasticSansClient) NewListByResourceGroupPager(resourceGroupName s if err != nil { return ElasticSansClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ElasticSansClientListByResourceGroupResponse{}, err } @@ -284,7 +279,7 @@ func (client *ElasticSansClient) listByResourceGroupCreateRequest(ctx context.Co return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -305,9 +300,10 @@ func (client *ElasticSansClient) listByResourceGroupHandleResponse(resp *http.Re } // NewListBySubscriptionPager - Gets a list of ElasticSans in a subscription +// // Generated from API version 2021-11-20-preview -// options - ElasticSansClientListBySubscriptionOptions contains the optional parameters for the ElasticSansClient.ListBySubscription -// method. +// - options - ElasticSansClientListBySubscriptionOptions contains the optional parameters for the ElasticSansClient.NewListBySubscriptionPager +// method. func (client *ElasticSansClient) NewListBySubscriptionPager(options *ElasticSansClientListBySubscriptionOptions) *runtime.Pager[ElasticSansClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[ElasticSansClientListBySubscriptionResponse]{ More: func(page ElasticSansClientListBySubscriptionResponse) bool { @@ -324,7 +320,7 @@ func (client *ElasticSansClient) NewListBySubscriptionPager(options *ElasticSans if err != nil { return ElasticSansClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ElasticSansClientListBySubscriptionResponse{}, err } @@ -343,7 +339,7 @@ func (client *ElasticSansClient) listBySubscriptionCreateRequest(ctx context.Con return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -365,34 +361,36 @@ func (client *ElasticSansClient) listBySubscriptionHandleResponse(resp *http.Res // BeginUpdate - Update a Elastic San. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// elasticSanName - The name of the ElasticSan. -// parameters - Elastic San object. -// options - ElasticSansClientBeginUpdateOptions contains the optional parameters for the ElasticSansClient.BeginUpdate method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - elasticSanName - The name of the ElasticSan. +// - parameters - Elastic San object. +// - options - ElasticSansClientBeginUpdateOptions contains the optional parameters for the ElasticSansClient.BeginUpdate method. func (client *ElasticSansClient) BeginUpdate(ctx context.Context, resourceGroupName string, elasticSanName string, parameters Update, options *ElasticSansClientBeginUpdateOptions) (*runtime.Poller[ElasticSansClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, elasticSanName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ElasticSansClientUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ElasticSansClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[ElasticSansClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ElasticSansClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Update a Elastic San. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview func (client *ElasticSansClient) update(ctx context.Context, resourceGroupName string, elasticSanName string, parameters Update, options *ElasticSansClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, elasticSanName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -417,7 +415,7 @@ func (client *ElasticSansClient) updateCreateRequest(ctx context.Context, resour return nil, errors.New("parameter elasticSanName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{elasticSanName}", url.PathEscape(elasticSanName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/elasticsans_client_example_test.go b/sdk/resourcemanager/elasticsan/armelasticsan/elasticsans_client_example_test.go index 7a464b2e5cd0..0d2698ef70c3 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/elasticsans_client_example_test.go +++ b/sdk/resourcemanager/elasticsan/armelasticsan/elasticsans_client_example_test.go @@ -5,6 +5,7 @@ // 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 armelasticsan_test @@ -17,114 +18,214 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elasticsan/armelasticsan" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_ListBySubscription_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_ListBySubscription_MaximumSet_Gen.json func ExampleElasticSansClient_NewListBySubscriptionPager_elasticSansListBySubscriptionMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewElasticSansClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListBySubscriptionPager(nil) + pager := clientFactory.NewElasticSansClient().NewListBySubscriptionPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.List = armelasticsan.List{ + // Value: []*armelasticsan.ElasticSan{ + // { + // Name: to.Ptr("aaaaaaaaaaa"), + // Type: to.Ptr("aaaaaa"), + // ID: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Tags: map[string]*string{ + // "key896": to.Ptr("aaaaaaaaaaaaaaaaaa"), + // }, + // Location: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Properties: &armelasticsan.Properties{ + // AvailabilityZones: []*string{ + // to.Ptr("aaaaaaaaaaaaaaaaa")}, + // BaseSizeTiB: to.Ptr[int64](26), + // ExtendedCapacitySizeTiB: to.Ptr[int64](7), + // ProvisioningState: to.Ptr(armelasticsan.ProvisioningStatesSucceeded), + // SKU: &armelasticsan.SKU{ + // Name: to.Ptr(armelasticsan.SKUNamePremiumLRS), + // Tier: to.Ptr(armelasticsan.SKUTierPremium), + // }, + // TotalIops: to.Ptr[int64](13), + // TotalMBps: to.Ptr[int64](16), + // TotalSizeTiB: to.Ptr[int64](29), + // TotalVolumeSizeGiB: to.Ptr[int64](21), + // VolumeGroupCount: to.Ptr[int64](24), + // }, + // SystemData: &armelasticsan.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // CreatedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaa"), + // CreatedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // LastModifiedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // LastModifiedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_ListBySubscription_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_ListBySubscription_MinimumSet_Gen.json func ExampleElasticSansClient_NewListBySubscriptionPager_elasticSansListBySubscriptionMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewElasticSansClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListBySubscriptionPager(nil) + pager := clientFactory.NewElasticSansClient().NewListBySubscriptionPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.List = armelasticsan.List{ + // Value: []*armelasticsan.ElasticSan{ + // { + // Properties: &armelasticsan.Properties{ + // BaseSizeTiB: to.Ptr[int64](26), + // ExtendedCapacitySizeTiB: to.Ptr[int64](7), + // SKU: &armelasticsan.SKU{ + // Name: to.Ptr(armelasticsan.SKUNamePremiumLRS), + // }, + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_ListByResourceGroup_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_ListByResourceGroup_MaximumSet_Gen.json func ExampleElasticSansClient_NewListByResourceGroupPager_elasticSansListByResourceGroupMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewElasticSansClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("rgelasticsan", nil) + pager := clientFactory.NewElasticSansClient().NewListByResourceGroupPager("rgelasticsan", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.List = armelasticsan.List{ + // Value: []*armelasticsan.ElasticSan{ + // { + // Name: to.Ptr("aaaaaaaaaaa"), + // Type: to.Ptr("aaaaaa"), + // ID: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Tags: map[string]*string{ + // "key896": to.Ptr("aaaaaaaaaaaaaaaaaa"), + // }, + // Location: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Properties: &armelasticsan.Properties{ + // AvailabilityZones: []*string{ + // to.Ptr("aaaaaaaaaaaaaaaaa")}, + // BaseSizeTiB: to.Ptr[int64](26), + // ExtendedCapacitySizeTiB: to.Ptr[int64](7), + // ProvisioningState: to.Ptr(armelasticsan.ProvisioningStatesSucceeded), + // SKU: &armelasticsan.SKU{ + // Name: to.Ptr(armelasticsan.SKUNamePremiumLRS), + // Tier: to.Ptr(armelasticsan.SKUTierPremium), + // }, + // TotalIops: to.Ptr[int64](13), + // TotalMBps: to.Ptr[int64](16), + // TotalSizeTiB: to.Ptr[int64](29), + // TotalVolumeSizeGiB: to.Ptr[int64](21), + // VolumeGroupCount: to.Ptr[int64](24), + // }, + // SystemData: &armelasticsan.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // CreatedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaa"), + // CreatedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // LastModifiedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // LastModifiedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_ListByResourceGroup_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_ListByResourceGroup_MinimumSet_Gen.json func ExampleElasticSansClient_NewListByResourceGroupPager_elasticSansListByResourceGroupMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewElasticSansClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("rgelasticsan", nil) + pager := clientFactory.NewElasticSansClient().NewListByResourceGroupPager("rgelasticsan", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.List = armelasticsan.List{ + // Value: []*armelasticsan.ElasticSan{ + // { + // Properties: &armelasticsan.Properties{ + // BaseSizeTiB: to.Ptr[int64](26), + // ExtendedCapacitySizeTiB: to.Ptr[int64](7), + // SKU: &armelasticsan.SKU{ + // Name: to.Ptr(armelasticsan.SKUNamePremiumLRS), + // }, + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_Create_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_Create_MaximumSet_Gen.json func ExampleElasticSansClient_BeginCreate_elasticSansCreateMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewElasticSansClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", armelasticsan.ElasticSan{ + poller, err := clientFactory.NewElasticSansClient().BeginCreate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", armelasticsan.ElasticSan{ Tags: map[string]*string{ "key896": to.Ptr("aaaaaaaaaaaaaaaaaa"), }, @@ -147,22 +248,56 @@ func ExampleElasticSansClient_BeginCreate_elasticSansCreateMaximumSetGen() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // 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.ElasticSan = armelasticsan.ElasticSan{ + // Name: to.Ptr("aaaaaaaaaaa"), + // Type: to.Ptr("aaaaaa"), + // ID: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Tags: map[string]*string{ + // "key896": to.Ptr("aaaaaaaaaaaaaaaaaa"), + // }, + // Location: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Properties: &armelasticsan.Properties{ + // AvailabilityZones: []*string{ + // to.Ptr("aaaaaaaaaaaaaaaaa")}, + // BaseSizeTiB: to.Ptr[int64](26), + // ExtendedCapacitySizeTiB: to.Ptr[int64](7), + // ProvisioningState: to.Ptr(armelasticsan.ProvisioningStatesSucceeded), + // SKU: &armelasticsan.SKU{ + // Name: to.Ptr(armelasticsan.SKUNamePremiumLRS), + // Tier: to.Ptr(armelasticsan.SKUTierPremium), + // }, + // TotalIops: to.Ptr[int64](13), + // TotalMBps: to.Ptr[int64](16), + // TotalSizeTiB: to.Ptr[int64](29), + // TotalVolumeSizeGiB: to.Ptr[int64](21), + // VolumeGroupCount: to.Ptr[int64](24), + // }, + // SystemData: &armelasticsan.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // CreatedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaa"), + // CreatedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // LastModifiedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // LastModifiedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_Create_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_Create_MinimumSet_Gen.json func ExampleElasticSansClient_BeginCreate_elasticSansCreateMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewElasticSansClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", armelasticsan.ElasticSan{ + poller, err := clientFactory.NewElasticSansClient().BeginCreate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", armelasticsan.ElasticSan{ Properties: &armelasticsan.Properties{ BaseSizeTiB: to.Ptr[int64](26), ExtendedCapacitySizeTiB: to.Ptr[int64](7), @@ -178,22 +313,32 @@ func ExampleElasticSansClient_BeginCreate_elasticSansCreateMinimumSetGen() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // 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.ElasticSan = armelasticsan.ElasticSan{ + // Properties: &armelasticsan.Properties{ + // BaseSizeTiB: to.Ptr[int64](26), + // ExtendedCapacitySizeTiB: to.Ptr[int64](7), + // SKU: &armelasticsan.SKU{ + // Name: to.Ptr(armelasticsan.SKUNamePremiumLRS), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_Update_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_Update_MaximumSet_Gen.json func ExampleElasticSansClient_BeginUpdate_elasticSansUpdateMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewElasticSansClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", armelasticsan.Update{ + poller, err := clientFactory.NewElasticSansClient().BeginUpdate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", armelasticsan.Update{ Properties: &armelasticsan.UpdateProperties{ BaseSizeTiB: to.Ptr[int64](23), ExtendedCapacitySizeTiB: to.Ptr[int64](4), @@ -209,22 +354,56 @@ func ExampleElasticSansClient_BeginUpdate_elasticSansUpdateMaximumSetGen() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // 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.ElasticSan = armelasticsan.ElasticSan{ + // Name: to.Ptr("aaaaaaaaaaa"), + // Type: to.Ptr("aaaaaa"), + // ID: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Tags: map[string]*string{ + // "key896": to.Ptr("aaaaaaaaaaaaaaaaaa"), + // }, + // Location: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Properties: &armelasticsan.Properties{ + // AvailabilityZones: []*string{ + // to.Ptr("aaaaaaaaaaaaaaaaa")}, + // BaseSizeTiB: to.Ptr[int64](26), + // ExtendedCapacitySizeTiB: to.Ptr[int64](7), + // ProvisioningState: to.Ptr(armelasticsan.ProvisioningStatesSucceeded), + // SKU: &armelasticsan.SKU{ + // Name: to.Ptr(armelasticsan.SKUNamePremiumLRS), + // Tier: to.Ptr(armelasticsan.SKUTierPremium), + // }, + // TotalIops: to.Ptr[int64](13), + // TotalMBps: to.Ptr[int64](16), + // TotalSizeTiB: to.Ptr[int64](29), + // TotalVolumeSizeGiB: to.Ptr[int64](21), + // VolumeGroupCount: to.Ptr[int64](24), + // }, + // SystemData: &armelasticsan.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // CreatedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaa"), + // CreatedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // LastModifiedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // LastModifiedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_Update_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_Update_MinimumSet_Gen.json func ExampleElasticSansClient_BeginUpdate_elasticSansUpdateMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewElasticSansClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", armelasticsan.Update{}, nil) + poller, err := clientFactory.NewElasticSansClient().BeginUpdate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", armelasticsan.Update{}, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -232,22 +411,32 @@ func ExampleElasticSansClient_BeginUpdate_elasticSansUpdateMinimumSetGen() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // 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.ElasticSan = armelasticsan.ElasticSan{ + // Properties: &armelasticsan.Properties{ + // BaseSizeTiB: to.Ptr[int64](26), + // ExtendedCapacitySizeTiB: to.Ptr[int64](7), + // SKU: &armelasticsan.SKU{ + // Name: to.Ptr(armelasticsan.SKUNamePremiumLRS), + // }, + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_Delete_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_Delete_MaximumSet_Gen.json func ExampleElasticSansClient_BeginDelete_elasticSansDeleteMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewElasticSansClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", nil) + poller, err := clientFactory.NewElasticSansClient().BeginDelete(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -257,18 +446,18 @@ func ExampleElasticSansClient_BeginDelete_elasticSansDeleteMaximumSetGen() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_Delete_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_Delete_MinimumSet_Gen.json func ExampleElasticSansClient_BeginDelete_elasticSansDeleteMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewElasticSansClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", nil) + poller, err := clientFactory.NewElasticSansClient().BeginDelete(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -278,40 +467,84 @@ func ExampleElasticSansClient_BeginDelete_elasticSansDeleteMinimumSetGen() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_Get_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_Get_MaximumSet_Gen.json func ExampleElasticSansClient_Get_elasticSansGetMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewElasticSansClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", nil) + res, err := clientFactory.NewElasticSansClient().Get(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.ElasticSan = armelasticsan.ElasticSan{ + // Name: to.Ptr("aaaaaaaaaaa"), + // Type: to.Ptr("aaaaaa"), + // ID: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Tags: map[string]*string{ + // "key896": to.Ptr("aaaaaaaaaaaaaaaaaa"), + // }, + // Location: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Properties: &armelasticsan.Properties{ + // AvailabilityZones: []*string{ + // to.Ptr("aaaaaaaaaaaaaaaaa")}, + // BaseSizeTiB: to.Ptr[int64](26), + // ExtendedCapacitySizeTiB: to.Ptr[int64](7), + // ProvisioningState: to.Ptr(armelasticsan.ProvisioningStatesSucceeded), + // SKU: &armelasticsan.SKU{ + // Name: to.Ptr(armelasticsan.SKUNamePremiumLRS), + // Tier: to.Ptr(armelasticsan.SKUTierPremium), + // }, + // TotalIops: to.Ptr[int64](13), + // TotalMBps: to.Ptr[int64](16), + // TotalSizeTiB: to.Ptr[int64](29), + // TotalVolumeSizeGiB: to.Ptr[int64](21), + // VolumeGroupCount: to.Ptr[int64](24), + // }, + // SystemData: &armelasticsan.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // CreatedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaa"), + // CreatedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // LastModifiedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // LastModifiedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_Get_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/ElasticSans_Get_MinimumSet_Gen.json func ExampleElasticSansClient_Get_elasticSansGetMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewElasticSansClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", nil) + res, err := clientFactory.NewElasticSansClient().Get(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.ElasticSan = armelasticsan.ElasticSan{ + // Properties: &armelasticsan.Properties{ + // BaseSizeTiB: to.Ptr[int64](26), + // ExtendedCapacitySizeTiB: to.Ptr[int64](7), + // SKU: &armelasticsan.SKU{ + // Name: to.Ptr(armelasticsan.SKUNamePremiumLRS), + // }, + // }, + // } } diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/go.mod b/sdk/resourcemanager/elasticsan/armelasticsan/go.mod index befd1b812893..016913fb9b38 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/go.mod +++ b/sdk/resourcemanager/elasticsan/armelasticsan/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elasticsan/armelast go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/go.sum b/sdk/resourcemanager/elasticsan/armelasticsan/go.sum index 8828b17b1853..8ba445a8c4da 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/go.sum +++ b/sdk/resourcemanager/elasticsan/armelasticsan/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 h1:BWe8a+f/t+7KY7zH2mqygeUD0t8hNFXe08p1Pb3/jKE= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/models.go b/sdk/resourcemanager/elasticsan/armelasticsan/models.go index a416935ca92b..228cf10d540a 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/models.go +++ b/sdk/resourcemanager/elasticsan/armelasticsan/models.go @@ -58,13 +58,13 @@ type ElasticSansClientGetOptions struct { // placeholder for future optional parameters } -// ElasticSansClientListByResourceGroupOptions contains the optional parameters for the ElasticSansClient.ListByResourceGroup +// ElasticSansClientListByResourceGroupOptions contains the optional parameters for the ElasticSansClient.NewListByResourceGroupPager // method. type ElasticSansClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// ElasticSansClientListBySubscriptionOptions contains the optional parameters for the ElasticSansClient.ListBySubscription +// ElasticSansClientListBySubscriptionOptions contains the optional parameters for the ElasticSansClient.NewListBySubscriptionPager // method. type ElasticSansClientListBySubscriptionOptions struct { // placeholder for future optional parameters @@ -127,7 +127,7 @@ type OperationListResult struct { NextLink *string `json:"nextLink,omitempty"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -232,7 +232,7 @@ type SKULocationInfo struct { Zones []*string `json:"zones,omitempty" azure:"ro"` } -// SKUsClientListOptions contains the optional parameters for the SKUsClient.List method. +// SKUsClientListOptions contains the optional parameters for the SKUsClient.NewListPager method. type SKUsClientListOptions struct { // Specify $filter='location eq ' to filter on location. Filter *string @@ -409,7 +409,7 @@ type VolumeGroupsClientGetOptions struct { // placeholder for future optional parameters } -// VolumeGroupsClientListByElasticSanOptions contains the optional parameters for the VolumeGroupsClient.ListByElasticSan +// VolumeGroupsClientListByElasticSanOptions contains the optional parameters for the VolumeGroupsClient.NewListByElasticSanPager // method. type VolumeGroupsClientListByElasticSanOptions struct { // placeholder for future optional parameters @@ -477,7 +477,8 @@ type VolumesClientGetOptions struct { // placeholder for future optional parameters } -// VolumesClientListByVolumeGroupOptions contains the optional parameters for the VolumesClient.ListByVolumeGroup method. +// VolumesClientListByVolumeGroupOptions contains the optional parameters for the VolumesClient.NewListByVolumeGroupPager +// method. type VolumesClientListByVolumeGroupOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/models_serde.go b/sdk/resourcemanager/elasticsan/armelasticsan/models_serde.go index 218d00d66daf..918d5e6b91c9 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/models_serde.go +++ b/sdk/resourcemanager/elasticsan/armelasticsan/models_serde.go @@ -18,7 +18,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type ElasticSan. func (e ElasticSan) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", e.ID) populate(objectMap, "location", e.Location) populate(objectMap, "name", e.Name) @@ -69,7 +69,7 @@ func (e *ElasticSan) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IscsiTargetInfo. func (i IscsiTargetInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "provisioningState", i.ProvisioningState) populate(objectMap, "status", i.Status) populate(objectMap, "targetIqn", i.TargetIqn) @@ -112,7 +112,7 @@ func (i *IscsiTargetInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type List. func (l List) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", l.NextLink) populate(objectMap, "value", l.Value) return json.Marshal(objectMap) @@ -143,7 +143,7 @@ func (l *List) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type NetworkRuleSet. func (n NetworkRuleSet) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "virtualNetworkRules", n.VirtualNetworkRules) return json.Marshal(objectMap) } @@ -170,7 +170,7 @@ func (n *NetworkRuleSet) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationDisplay. func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", o.Description) populate(objectMap, "operation", o.Operation) populate(objectMap, "provider", o.Provider) @@ -209,7 +209,7 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationListResult. func (o OperationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", o.NextLink) populate(objectMap, "value", o.Value) return json.Marshal(objectMap) @@ -240,7 +240,7 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Properties. func (p Properties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "availabilityZones", p.AvailabilityZones) populate(objectMap, "baseSizeTiB", p.BaseSizeTiB) populate(objectMap, "extendedCapacitySizeTiB", p.ExtendedCapacitySizeTiB) @@ -303,7 +303,7 @@ func (p *Properties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RPOperation. func (r RPOperation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "display", r.Display) populate(objectMap, "isDataAction", r.IsDataAction) populate(objectMap, "name", r.Name) @@ -338,7 +338,7 @@ func (r *RPOperation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SKU. func (s SKU) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", s.Name) populate(objectMap, "tier", s.Tier) return json.Marshal(objectMap) @@ -369,7 +369,7 @@ func (s *SKU) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SKUCapability. func (s SKUCapability) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "name", s.Name) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -400,7 +400,7 @@ func (s *SKUCapability) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SKUInformation. func (s SKUInformation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "capabilities", s.Capabilities) populate(objectMap, "locationInfo", s.LocationInfo) populate(objectMap, "locations", s.Locations) @@ -447,7 +447,7 @@ func (s *SKUInformation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SKUInformationList. func (s SKUInformationList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) } @@ -474,7 +474,7 @@ func (s *SKUInformationList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SKULocationInfo. func (s SKULocationInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "location", s.Location) populate(objectMap, "zones", s.Zones) return json.Marshal(objectMap) @@ -505,7 +505,7 @@ func (s *SKULocationInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SourceCreationData. func (s SourceCreationData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["createSource"] = "None" populate(objectMap, "sourceUri", s.SourceURI) return json.Marshal(objectMap) @@ -536,7 +536,7 @@ func (s *SourceCreationData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) @@ -583,7 +583,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Update. func (u Update) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "properties", u.Properties) populate(objectMap, "tags", u.Tags) return json.Marshal(objectMap) @@ -614,7 +614,7 @@ func (u *Update) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UpdateProperties. func (u UpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "baseSizeTiB", u.BaseSizeTiB) populate(objectMap, "extendedCapacitySizeTiB", u.ExtendedCapacitySizeTiB) return json.Marshal(objectMap) @@ -645,7 +645,7 @@ func (u *UpdateProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VirtualNetworkRule. func (v VirtualNetworkRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) objectMap["action"] = "Allow" populate(objectMap, "state", v.State) populate(objectMap, "id", v.VirtualNetworkResourceID) @@ -680,7 +680,7 @@ func (v *VirtualNetworkRule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Volume. func (v Volume) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", v.ID) populate(objectMap, "name", v.Name) populate(objectMap, "properties", v.Properties) @@ -727,7 +727,7 @@ func (v *Volume) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VolumeGroup. func (v VolumeGroup) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", v.ID) populate(objectMap, "name", v.Name) populate(objectMap, "properties", v.Properties) @@ -774,7 +774,7 @@ func (v *VolumeGroup) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VolumeGroupList. func (v VolumeGroupList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", v.NextLink) populate(objectMap, "value", v.Value) return json.Marshal(objectMap) @@ -805,7 +805,7 @@ func (v *VolumeGroupList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VolumeGroupProperties. func (v VolumeGroupProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "encryption", v.Encryption) populate(objectMap, "networkAcls", v.NetworkACLs) populate(objectMap, "protocolType", v.ProtocolType) @@ -844,7 +844,7 @@ func (v *VolumeGroupProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VolumeGroupUpdate. func (v VolumeGroupUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "properties", v.Properties) populate(objectMap, "tags", v.Tags) return json.Marshal(objectMap) @@ -875,7 +875,7 @@ func (v *VolumeGroupUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VolumeGroupUpdateProperties. func (v VolumeGroupUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "encryption", v.Encryption) populate(objectMap, "networkAcls", v.NetworkACLs) populate(objectMap, "protocolType", v.ProtocolType) @@ -910,7 +910,7 @@ func (v *VolumeGroupUpdateProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VolumeList. func (v VolumeList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", v.NextLink) populate(objectMap, "value", v.Value) return json.Marshal(objectMap) @@ -941,7 +941,7 @@ func (v *VolumeList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VolumeProperties. func (v VolumeProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "creationData", v.CreationData) populate(objectMap, "sizeGiB", v.SizeGiB) populate(objectMap, "storageTarget", v.StorageTarget) @@ -980,7 +980,7 @@ func (v *VolumeProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VolumeUpdate. func (v VolumeUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "properties", v.Properties) populate(objectMap, "tags", v.Tags) return json.Marshal(objectMap) @@ -1011,7 +1011,7 @@ func (v *VolumeUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type VolumeUpdateProperties. func (v VolumeUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "sizeGiB", v.SizeGiB) return json.Marshal(objectMap) } @@ -1036,7 +1036,7 @@ func (v *VolumeUpdateProperties) UnmarshalJSON(data []byte) error { return nil } -func populate(m map[string]interface{}, k string, v interface{}) { +func populate(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { @@ -1046,7 +1046,7 @@ func populate(m map[string]interface{}, k string, v interface{}) { } } -func unpopulate(data json.RawMessage, fn string, v interface{}) error { +func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil } diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/operations_client.go b/sdk/resourcemanager/elasticsan/armelasticsan/operations_client.go index 902fec944795..2ac2fb691ad3 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/operations_client.go +++ b/sdk/resourcemanager/elasticsan/armelasticsan/operations_client.go @@ -13,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -23,35 +21,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Gets a list of ElasticSan operations. +// // Generated from API version 2021-11-20-preview -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - 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 { @@ -62,7 +52,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -77,7 +67,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.ElasticSan/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/operations_client_example_test.go b/sdk/resourcemanager/elasticsan/armelasticsan/operations_client_example_test.go index 4d32e410ff0d..1e4db64e698d 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/operations_client_example_test.go +++ b/sdk/resourcemanager/elasticsan/armelasticsan/operations_client_example_test.go @@ -5,6 +5,7 @@ // 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 armelasticsan_test @@ -16,50 +17,71 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elasticsan/armelasticsan" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Operations_List_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Operations_List_MaximumSet_Gen.json func ExampleOperationsClient_NewListPager_operationsListMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewOperationsClient(cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewOperationsClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.OperationListResult = armelasticsan.OperationListResult{ + // Value: []*armelasticsan.RPOperation{ + // { + // Name: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Display: &armelasticsan.OperationDisplay{ + // Description: to.Ptr("aaaaaaaaaaaaaaaaaaaa"), + // Operation: to.Ptr("aaaaaaaaaaaaaaaaaaaa"), + // Provider: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Resource: to.Ptr("aaaaaaaaaaaaaaa"), + // }, + // IsDataAction: to.Ptr(true), + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Operations_List_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Operations_List_MinimumSet_Gen.json func ExampleOperationsClient_NewListPager_operationsListMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewOperationsClient(cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(nil) + pager := clientFactory.NewOperationsClient().NewListPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.OperationListResult = armelasticsan.OperationListResult{ + // Value: []*armelasticsan.RPOperation{ + // { + // Name: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // }}, + // } } } diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/response_types.go b/sdk/resourcemanager/elasticsan/armelasticsan/response_types.go index decbc26172fc..e0080f3e1709 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/response_types.go +++ b/sdk/resourcemanager/elasticsan/armelasticsan/response_types.go @@ -9,12 +9,12 @@ package armelasticsan -// ElasticSansClientCreateResponse contains the response from method ElasticSansClient.Create. +// ElasticSansClientCreateResponse contains the response from method ElasticSansClient.BeginCreate. type ElasticSansClientCreateResponse struct { ElasticSan } -// ElasticSansClientDeleteResponse contains the response from method ElasticSansClient.Delete. +// ElasticSansClientDeleteResponse contains the response from method ElasticSansClient.BeginDelete. type ElasticSansClientDeleteResponse struct { // placeholder for future response values } @@ -24,37 +24,37 @@ type ElasticSansClientGetResponse struct { ElasticSan } -// ElasticSansClientListByResourceGroupResponse contains the response from method ElasticSansClient.ListByResourceGroup. +// ElasticSansClientListByResourceGroupResponse contains the response from method ElasticSansClient.NewListByResourceGroupPager. type ElasticSansClientListByResourceGroupResponse struct { List } -// ElasticSansClientListBySubscriptionResponse contains the response from method ElasticSansClient.ListBySubscription. +// ElasticSansClientListBySubscriptionResponse contains the response from method ElasticSansClient.NewListBySubscriptionPager. type ElasticSansClientListBySubscriptionResponse struct { List } -// ElasticSansClientUpdateResponse contains the response from method ElasticSansClient.Update. +// ElasticSansClientUpdateResponse contains the response from method ElasticSansClient.BeginUpdate. type ElasticSansClientUpdateResponse struct { ElasticSan } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationListResult } -// SKUsClientListResponse contains the response from method SKUsClient.List. +// SKUsClientListResponse contains the response from method SKUsClient.NewListPager. type SKUsClientListResponse struct { SKUInformationList } -// VolumeGroupsClientCreateResponse contains the response from method VolumeGroupsClient.Create. +// VolumeGroupsClientCreateResponse contains the response from method VolumeGroupsClient.BeginCreate. type VolumeGroupsClientCreateResponse struct { VolumeGroup } -// VolumeGroupsClientDeleteResponse contains the response from method VolumeGroupsClient.Delete. +// VolumeGroupsClientDeleteResponse contains the response from method VolumeGroupsClient.BeginDelete. type VolumeGroupsClientDeleteResponse struct { // placeholder for future response values } @@ -64,22 +64,22 @@ type VolumeGroupsClientGetResponse struct { VolumeGroup } -// VolumeGroupsClientListByElasticSanResponse contains the response from method VolumeGroupsClient.ListByElasticSan. +// VolumeGroupsClientListByElasticSanResponse contains the response from method VolumeGroupsClient.NewListByElasticSanPager. type VolumeGroupsClientListByElasticSanResponse struct { VolumeGroupList } -// VolumeGroupsClientUpdateResponse contains the response from method VolumeGroupsClient.Update. +// VolumeGroupsClientUpdateResponse contains the response from method VolumeGroupsClient.BeginUpdate. type VolumeGroupsClientUpdateResponse struct { VolumeGroup } -// VolumesClientCreateResponse contains the response from method VolumesClient.Create. +// VolumesClientCreateResponse contains the response from method VolumesClient.BeginCreate. type VolumesClientCreateResponse struct { Volume } -// VolumesClientDeleteResponse contains the response from method VolumesClient.Delete. +// VolumesClientDeleteResponse contains the response from method VolumesClient.BeginDelete. type VolumesClientDeleteResponse struct { // placeholder for future response values } @@ -89,12 +89,12 @@ type VolumesClientGetResponse struct { Volume } -// VolumesClientListByVolumeGroupResponse contains the response from method VolumesClient.ListByVolumeGroup. +// VolumesClientListByVolumeGroupResponse contains the response from method VolumesClient.NewListByVolumeGroupPager. type VolumesClientListByVolumeGroupResponse struct { VolumeList } -// VolumesClientUpdateResponse contains the response from method VolumesClient.Update. +// VolumesClientUpdateResponse contains the response from method VolumesClient.BeginUpdate. type VolumesClientUpdateResponse struct { Volume } diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/skus_client.go b/sdk/resourcemanager/elasticsan/armelasticsan/skus_client.go index 8a33877a3058..b50b657c4ed1 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/skus_client.go +++ b/sdk/resourcemanager/elasticsan/armelasticsan/skus_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,38 +24,30 @@ import ( // SKUsClient contains the methods for the SKUs group. // Don't use this type directly, use NewSKUsClient() instead. type SKUsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSKUsClient creates a new instance of SKUsClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSKUsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SKUsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SKUsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SKUsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - List all the available Skus in the region and information related to them +// // Generated from API version 2021-11-20-preview -// options - SKUsClientListOptions contains the optional parameters for the SKUsClient.List method. +// - options - SKUsClientListOptions contains the optional parameters for the SKUsClient.NewListPager method. func (client *SKUsClient) NewListPager(options *SKUsClientListOptions) *runtime.Pager[SKUsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[SKUsClientListResponse]{ More: func(page SKUsClientListResponse) bool { @@ -68,7 +58,7 @@ func (client *SKUsClient) NewListPager(options *SKUsClientListOptions) *runtime. if err != nil { return SKUsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SKUsClientListResponse{}, err } @@ -87,7 +77,7 @@ func (client *SKUsClient) listCreateRequest(ctx context.Context, options *SKUsCl return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/skus_client_example_test.go b/sdk/resourcemanager/elasticsan/armelasticsan/skus_client_example_test.go index 9555327e2b4e..e8b3bbc1fe00 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/skus_client_example_test.go +++ b/sdk/resourcemanager/elasticsan/armelasticsan/skus_client_example_test.go @@ -5,6 +5,7 @@ // 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 armelasticsan_test @@ -17,50 +18,75 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elasticsan/armelasticsan" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Skus_List_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Skus_List_MaximumSet_Gen.json func ExampleSKUsClient_NewListPager_skusListMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewSKUsClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(&armelasticsan.SKUsClientListOptions{Filter: to.Ptr("aaaa")}) + pager := clientFactory.NewSKUsClient().NewListPager(&armelasticsan.SKUsClientListOptions{Filter: to.Ptr("aaaa")}) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.SKUInformationList = armelasticsan.SKUInformationList{ + // Value: []*armelasticsan.SKUInformation{ + // { + // Name: to.Ptr(armelasticsan.SKUNamePremiumLRS), + // Capabilities: []*armelasticsan.SKUCapability{ + // { + // Name: to.Ptr("aaaaaaaaaaaaaaa"), + // Value: to.Ptr("aaaaaaaa"), + // }}, + // LocationInfo: []*armelasticsan.SKULocationInfo{ + // { + // Location: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaa"), + // Zones: []*string{ + // to.Ptr("aaa")}, + // }}, + // Locations: []*string{ + // to.Ptr("aaaaaaaaa")}, + // ResourceType: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Tier: to.Ptr(armelasticsan.SKUTierPremium), + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Skus_List_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Skus_List_MinimumSet_Gen.json func ExampleSKUsClient_NewListPager_skusListMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewSKUsClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListPager(&armelasticsan.SKUsClientListOptions{Filter: nil}) + pager := clientFactory.NewSKUsClient().NewListPager(&armelasticsan.SKUsClientListOptions{Filter: nil}) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.SKUInformationList = armelasticsan.SKUInformationList{ + // } } } diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/time_rfc3339.go b/sdk/resourcemanager/elasticsan/armelasticsan/time_rfc3339.go index 730065b374d4..edaf81c316d5 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/time_rfc3339.go +++ b/sdk/resourcemanager/elasticsan/armelasticsan/time_rfc3339.go @@ -62,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/volumegroups_client.go b/sdk/resourcemanager/elasticsan/armelasticsan/volumegroups_client.go index 184475efb7c1..4126a64befe5 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/volumegroups_client.go +++ b/sdk/resourcemanager/elasticsan/armelasticsan/volumegroups_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,67 +24,60 @@ import ( // VolumeGroupsClient contains the methods for the VolumeGroups group. // Don't use this type directly, use NewVolumeGroupsClient() instead. type VolumeGroupsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewVolumeGroupsClient creates a new instance of VolumeGroupsClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewVolumeGroupsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VolumeGroupsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".VolumeGroupsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &VolumeGroupsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create a Volume Group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// elasticSanName - The name of the ElasticSan. -// volumeGroupName - The name of the VolumeGroup. -// parameters - Volume Group object. -// options - VolumeGroupsClientBeginCreateOptions contains the optional parameters for the VolumeGroupsClient.BeginCreate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - elasticSanName - The name of the ElasticSan. +// - volumeGroupName - The name of the VolumeGroup. +// - parameters - Volume Group object. +// - options - VolumeGroupsClientBeginCreateOptions contains the optional parameters for the VolumeGroupsClient.BeginCreate +// method. func (client *VolumeGroupsClient) BeginCreate(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, parameters VolumeGroup, options *VolumeGroupsClientBeginCreateOptions) (*runtime.Poller[VolumeGroupsClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, elasticSanName, volumeGroupName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[VolumeGroupsClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VolumeGroupsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[VolumeGroupsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VolumeGroupsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create a Volume Group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview func (client *VolumeGroupsClient) create(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, parameters VolumeGroup, options *VolumeGroupsClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, elasticSanName, volumeGroupName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -115,7 +106,7 @@ func (client *VolumeGroupsClient) createCreateRequest(ctx context.Context, resou return nil, errors.New("parameter volumeGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{volumeGroupName}", url.PathEscape(volumeGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -128,35 +119,37 @@ func (client *VolumeGroupsClient) createCreateRequest(ctx context.Context, resou // BeginDelete - Delete an VolumeGroup. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// elasticSanName - The name of the ElasticSan. -// volumeGroupName - The name of the VolumeGroup. -// options - VolumeGroupsClientBeginDeleteOptions contains the optional parameters for the VolumeGroupsClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - elasticSanName - The name of the ElasticSan. +// - volumeGroupName - The name of the VolumeGroup. +// - options - VolumeGroupsClientBeginDeleteOptions contains the optional parameters for the VolumeGroupsClient.BeginDelete +// method. func (client *VolumeGroupsClient) BeginDelete(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, options *VolumeGroupsClientBeginDeleteOptions) (*runtime.Poller[VolumeGroupsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, elasticSanName, volumeGroupName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[VolumeGroupsClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VolumeGroupsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[VolumeGroupsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VolumeGroupsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete an VolumeGroup. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview func (client *VolumeGroupsClient) deleteOperation(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, options *VolumeGroupsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, elasticSanName, volumeGroupName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -185,7 +178,7 @@ func (client *VolumeGroupsClient) deleteCreateRequest(ctx context.Context, resou return nil, errors.New("parameter volumeGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{volumeGroupName}", url.PathEscape(volumeGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -198,17 +191,18 @@ func (client *VolumeGroupsClient) deleteCreateRequest(ctx context.Context, resou // Get - Get an VolumeGroups. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// elasticSanName - The name of the ElasticSan. -// volumeGroupName - The name of the VolumeGroup. -// options - VolumeGroupsClientGetOptions contains the optional parameters for the VolumeGroupsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - elasticSanName - The name of the ElasticSan. +// - volumeGroupName - The name of the VolumeGroup. +// - options - VolumeGroupsClientGetOptions contains the optional parameters for the VolumeGroupsClient.Get method. func (client *VolumeGroupsClient) Get(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, options *VolumeGroupsClientGetOptions) (VolumeGroupsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, elasticSanName, volumeGroupName, options) if err != nil { return VolumeGroupsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VolumeGroupsClientGetResponse{}, err } @@ -237,7 +231,7 @@ func (client *VolumeGroupsClient) getCreateRequest(ctx context.Context, resource return nil, errors.New("parameter volumeGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{volumeGroupName}", url.PathEscape(volumeGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -258,11 +252,12 @@ func (client *VolumeGroupsClient) getHandleResponse(resp *http.Response) (Volume } // NewListByElasticSanPager - List VolumeGroups. +// // Generated from API version 2021-11-20-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// elasticSanName - The name of the ElasticSan. -// options - VolumeGroupsClientListByElasticSanOptions contains the optional parameters for the VolumeGroupsClient.ListByElasticSan -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - elasticSanName - The name of the ElasticSan. +// - options - VolumeGroupsClientListByElasticSanOptions contains the optional parameters for the VolumeGroupsClient.NewListByElasticSanPager +// method. func (client *VolumeGroupsClient) NewListByElasticSanPager(resourceGroupName string, elasticSanName string, options *VolumeGroupsClientListByElasticSanOptions) *runtime.Pager[VolumeGroupsClientListByElasticSanResponse] { return runtime.NewPager(runtime.PagingHandler[VolumeGroupsClientListByElasticSanResponse]{ More: func(page VolumeGroupsClientListByElasticSanResponse) bool { @@ -279,7 +274,7 @@ func (client *VolumeGroupsClient) NewListByElasticSanPager(resourceGroupName str if err != nil { return VolumeGroupsClientListByElasticSanResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VolumeGroupsClientListByElasticSanResponse{}, err } @@ -306,7 +301,7 @@ func (client *VolumeGroupsClient) listByElasticSanCreateRequest(ctx context.Cont return nil, errors.New("parameter elasticSanName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{elasticSanName}", url.PathEscape(elasticSanName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -328,36 +323,38 @@ func (client *VolumeGroupsClient) listByElasticSanHandleResponse(resp *http.Resp // BeginUpdate - Update an VolumeGroup. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// elasticSanName - The name of the ElasticSan. -// volumeGroupName - The name of the VolumeGroup. -// parameters - Volume Group object. -// options - VolumeGroupsClientBeginUpdateOptions contains the optional parameters for the VolumeGroupsClient.BeginUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - elasticSanName - The name of the ElasticSan. +// - volumeGroupName - The name of the VolumeGroup. +// - parameters - Volume Group object. +// - options - VolumeGroupsClientBeginUpdateOptions contains the optional parameters for the VolumeGroupsClient.BeginUpdate +// method. func (client *VolumeGroupsClient) BeginUpdate(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, parameters VolumeGroupUpdate, options *VolumeGroupsClientBeginUpdateOptions) (*runtime.Poller[VolumeGroupsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, elasticSanName, volumeGroupName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[VolumeGroupsClientUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VolumeGroupsClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[VolumeGroupsClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VolumeGroupsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Update an VolumeGroup. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview func (client *VolumeGroupsClient) update(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, parameters VolumeGroupUpdate, options *VolumeGroupsClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, elasticSanName, volumeGroupName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -386,7 +383,7 @@ func (client *VolumeGroupsClient) updateCreateRequest(ctx context.Context, resou return nil, errors.New("parameter volumeGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{volumeGroupName}", url.PathEscape(volumeGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/volumegroups_client_example_test.go b/sdk/resourcemanager/elasticsan/armelasticsan/volumegroups_client_example_test.go index 0970f8bd7a67..23442bca5db6 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/volumegroups_client_example_test.go +++ b/sdk/resourcemanager/elasticsan/armelasticsan/volumegroups_client_example_test.go @@ -5,6 +5,7 @@ // 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 armelasticsan_test @@ -17,66 +18,105 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elasticsan/armelasticsan" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_ListByElasticSan_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_ListByElasticSan_MaximumSet_Gen.json func ExampleVolumeGroupsClient_NewListByElasticSanPager_volumeGroupsListByElasticSanMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumeGroupsClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByElasticSanPager("rgelasticsan", "ti7q-k952-1qB3J_5", nil) + pager := clientFactory.NewVolumeGroupsClient().NewListByElasticSanPager("rgelasticsan", "ti7q-k952-1qB3J_5", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.VolumeGroupList = armelasticsan.VolumeGroupList{ + // Value: []*armelasticsan.VolumeGroup{ + // { + // Name: to.Ptr("aaaaaaaaaaaaaaaaaaaaaa"), + // Type: to.Ptr("aaaaa"), + // ID: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Tags: map[string]*string{ + // "key5933": to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // }, + // Properties: &armelasticsan.VolumeGroupProperties{ + // Encryption: to.Ptr(armelasticsan.EncryptionTypeEncryptionAtRestWithPlatformKey), + // NetworkACLs: &armelasticsan.NetworkRuleSet{ + // VirtualNetworkRules: []*armelasticsan.VirtualNetworkRule{ + // { + // Action: to.Ptr("Allow"), + // VirtualNetworkResourceID: to.Ptr("aaaaaaaaaaaaaaaa"), + // State: to.Ptr(armelasticsan.StateProvisioning), + // }}, + // }, + // ProtocolType: to.Ptr(armelasticsan.StorageTargetTypeIscsi), + // ProvisioningState: to.Ptr(armelasticsan.ProvisioningStatesSucceeded), + // }, + // SystemData: &armelasticsan.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // CreatedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaa"), + // CreatedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // LastModifiedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // LastModifiedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_ListByElasticSan_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_ListByElasticSan_MinimumSet_Gen.json func ExampleVolumeGroupsClient_NewListByElasticSanPager_volumeGroupsListByElasticSanMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumeGroupsClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByElasticSanPager("rgelasticsan", "ti7q-k952-1qB3J_5", nil) + pager := clientFactory.NewVolumeGroupsClient().NewListByElasticSanPager("rgelasticsan", "ti7q-k952-1qB3J_5", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.VolumeGroupList = armelasticsan.VolumeGroupList{ + // Value: []*armelasticsan.VolumeGroup{ + // { + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_Create_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_Create_MaximumSet_Gen.json func ExampleVolumeGroupsClient_BeginCreate_volumeGroupsCreateMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumeGroupsClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", armelasticsan.VolumeGroup{ + poller, err := clientFactory.NewVolumeGroupsClient().BeginCreate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", armelasticsan.VolumeGroup{ Tags: map[string]*string{ "key5933": to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), }, @@ -99,22 +139,52 @@ func ExampleVolumeGroupsClient_BeginCreate_volumeGroupsCreateMaximumSetGen() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // 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.VolumeGroup = armelasticsan.VolumeGroup{ + // Name: to.Ptr("aaaaaaaaaaaaaaaaaaaaaa"), + // Type: to.Ptr("aaaaa"), + // ID: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Tags: map[string]*string{ + // "key5933": to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // }, + // Properties: &armelasticsan.VolumeGroupProperties{ + // Encryption: to.Ptr(armelasticsan.EncryptionTypeEncryptionAtRestWithPlatformKey), + // NetworkACLs: &armelasticsan.NetworkRuleSet{ + // VirtualNetworkRules: []*armelasticsan.VirtualNetworkRule{ + // { + // Action: to.Ptr("Allow"), + // VirtualNetworkResourceID: to.Ptr("aaaaaaaaaaaaaaaa"), + // State: to.Ptr(armelasticsan.StateProvisioning), + // }}, + // }, + // ProtocolType: to.Ptr(armelasticsan.StorageTargetTypeIscsi), + // ProvisioningState: to.Ptr(armelasticsan.ProvisioningStatesSucceeded), + // }, + // SystemData: &armelasticsan.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // CreatedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaa"), + // CreatedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // LastModifiedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // LastModifiedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_Create_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_Create_MinimumSet_Gen.json func ExampleVolumeGroupsClient_BeginCreate_volumeGroupsCreateMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumeGroupsClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", armelasticsan.VolumeGroup{}, nil) + poller, err := clientFactory.NewVolumeGroupsClient().BeginCreate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", armelasticsan.VolumeGroup{}, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -122,22 +192,25 @@ func ExampleVolumeGroupsClient_BeginCreate_volumeGroupsCreateMinimumSetGen() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // 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.VolumeGroup = armelasticsan.VolumeGroup{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_Update_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_Update_MaximumSet_Gen.json func ExampleVolumeGroupsClient_BeginUpdate_volumeGroupsUpdateMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumeGroupsClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", armelasticsan.VolumeGroupUpdate{ + poller, err := clientFactory.NewVolumeGroupsClient().BeginUpdate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", armelasticsan.VolumeGroupUpdate{ Properties: &armelasticsan.VolumeGroupUpdateProperties{ Encryption: to.Ptr(armelasticsan.EncryptionTypeEncryptionAtRestWithPlatformKey), NetworkACLs: &armelasticsan.NetworkRuleSet{ @@ -160,22 +233,52 @@ func ExampleVolumeGroupsClient_BeginUpdate_volumeGroupsUpdateMaximumSetGen() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // 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.VolumeGroup = armelasticsan.VolumeGroup{ + // Name: to.Ptr("aaaaaaaaaaaaaaaaaaaaaa"), + // Type: to.Ptr("aaaaa"), + // ID: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Tags: map[string]*string{ + // "key5933": to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // }, + // Properties: &armelasticsan.VolumeGroupProperties{ + // Encryption: to.Ptr(armelasticsan.EncryptionTypeEncryptionAtRestWithPlatformKey), + // NetworkACLs: &armelasticsan.NetworkRuleSet{ + // VirtualNetworkRules: []*armelasticsan.VirtualNetworkRule{ + // { + // Action: to.Ptr("Allow"), + // VirtualNetworkResourceID: to.Ptr("aaaaaaaaaaaaaaaa"), + // State: to.Ptr(armelasticsan.StateProvisioning), + // }}, + // }, + // ProtocolType: to.Ptr(armelasticsan.StorageTargetTypeIscsi), + // ProvisioningState: to.Ptr(armelasticsan.ProvisioningStatesSucceeded), + // }, + // SystemData: &armelasticsan.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // CreatedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaa"), + // CreatedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // LastModifiedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // LastModifiedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_Update_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_Update_MinimumSet_Gen.json func ExampleVolumeGroupsClient_BeginUpdate_volumeGroupsUpdateMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumeGroupsClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", armelasticsan.VolumeGroupUpdate{}, nil) + poller, err := clientFactory.NewVolumeGroupsClient().BeginUpdate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", armelasticsan.VolumeGroupUpdate{}, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -183,22 +286,25 @@ func ExampleVolumeGroupsClient_BeginUpdate_volumeGroupsUpdateMinimumSetGen() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // 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.VolumeGroup = armelasticsan.VolumeGroup{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_Delete_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_Delete_MaximumSet_Gen.json func ExampleVolumeGroupsClient_BeginDelete_volumeGroupsDeleteMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumeGroupsClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", nil) + poller, err := clientFactory.NewVolumeGroupsClient().BeginDelete(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -208,18 +314,18 @@ func ExampleVolumeGroupsClient_BeginDelete_volumeGroupsDeleteMaximumSetGen() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_Delete_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_Delete_MinimumSet_Gen.json func ExampleVolumeGroupsClient_BeginDelete_volumeGroupsDeleteMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumeGroupsClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", nil) + poller, err := clientFactory.NewVolumeGroupsClient().BeginDelete(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -229,40 +335,73 @@ func ExampleVolumeGroupsClient_BeginDelete_volumeGroupsDeleteMinimumSetGen() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_Get_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_Get_MaximumSet_Gen.json func ExampleVolumeGroupsClient_Get_volumeGroupsGetMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumeGroupsClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", nil) + res, err := clientFactory.NewVolumeGroupsClient().Get(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.VolumeGroup = armelasticsan.VolumeGroup{ + // Name: to.Ptr("aaaaaaaaaaaaaaaaaaaaaa"), + // Type: to.Ptr("aaaaa"), + // ID: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // Tags: map[string]*string{ + // "key5933": to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // }, + // Properties: &armelasticsan.VolumeGroupProperties{ + // Encryption: to.Ptr(armelasticsan.EncryptionTypeEncryptionAtRestWithPlatformKey), + // NetworkACLs: &armelasticsan.NetworkRuleSet{ + // VirtualNetworkRules: []*armelasticsan.VirtualNetworkRule{ + // { + // Action: to.Ptr("Allow"), + // VirtualNetworkResourceID: to.Ptr("aaaaaaaaaaaaaaaa"), + // State: to.Ptr(armelasticsan.StateProvisioning), + // }}, + // }, + // ProtocolType: to.Ptr(armelasticsan.StorageTargetTypeIscsi), + // ProvisioningState: to.Ptr(armelasticsan.ProvisioningStatesSucceeded), + // }, + // SystemData: &armelasticsan.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // CreatedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaa"), + // CreatedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // LastModifiedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // LastModifiedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_Get_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/VolumeGroups_Get_MinimumSet_Gen.json func ExampleVolumeGroupsClient_Get_volumeGroupsGetMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumeGroupsClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", nil) + res, err := clientFactory.NewVolumeGroupsClient().Get(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.VolumeGroup = armelasticsan.VolumeGroup{ + // } } diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/volumes_client.go b/sdk/resourcemanager/elasticsan/armelasticsan/volumes_client.go index 81eef96635fc..471abe5b955b 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/volumes_client.go +++ b/sdk/resourcemanager/elasticsan/armelasticsan/volumes_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,67 +24,60 @@ import ( // VolumesClient contains the methods for the Volumes group. // Don't use this type directly, use NewVolumesClient() instead. type VolumesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewVolumesClient creates a new instance of VolumesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewVolumesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VolumesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".VolumesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &VolumesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Create a Volume. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// elasticSanName - The name of the ElasticSan. -// volumeGroupName - The name of the VolumeGroup. -// volumeName - The name of the Volume. -// parameters - Volume object. -// options - VolumesClientBeginCreateOptions contains the optional parameters for the VolumesClient.BeginCreate method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - elasticSanName - The name of the ElasticSan. +// - volumeGroupName - The name of the VolumeGroup. +// - volumeName - The name of the Volume. +// - parameters - Volume object. +// - options - VolumesClientBeginCreateOptions contains the optional parameters for the VolumesClient.BeginCreate method. func (client *VolumesClient) BeginCreate(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, parameters Volume, options *VolumesClientBeginCreateOptions) (*runtime.Poller[VolumesClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, elasticSanName, volumeGroupName, volumeName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[VolumesClientCreateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VolumesClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[VolumesClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VolumesClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Create a Volume. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview func (client *VolumesClient) create(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, parameters Volume, options *VolumesClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, elasticSanName, volumeGroupName, volumeName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -119,7 +110,7 @@ func (client *VolumesClient) createCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter volumeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{volumeName}", url.PathEscape(volumeName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -132,35 +123,37 @@ func (client *VolumesClient) createCreateRequest(ctx context.Context, resourceGr // BeginDelete - Delete an Volume. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// elasticSanName - The name of the ElasticSan. -// volumeGroupName - The name of the VolumeGroup. -// volumeName - The name of the Volume. -// options - VolumesClientBeginDeleteOptions contains the optional parameters for the VolumesClient.BeginDelete method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - elasticSanName - The name of the ElasticSan. +// - volumeGroupName - The name of the VolumeGroup. +// - volumeName - The name of the Volume. +// - options - VolumesClientBeginDeleteOptions contains the optional parameters for the VolumesClient.BeginDelete method. func (client *VolumesClient) BeginDelete(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, options *VolumesClientBeginDeleteOptions) (*runtime.Poller[VolumesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, elasticSanName, volumeGroupName, volumeName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[VolumesClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VolumesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[VolumesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VolumesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Delete an Volume. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview func (client *VolumesClient) deleteOperation(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, options *VolumesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, elasticSanName, volumeGroupName, volumeName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -193,7 +186,7 @@ func (client *VolumesClient) deleteCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter volumeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{volumeName}", url.PathEscape(volumeName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -206,18 +199,19 @@ func (client *VolumesClient) deleteCreateRequest(ctx context.Context, resourceGr // Get - Get an Volume. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// elasticSanName - The name of the ElasticSan. -// volumeGroupName - The name of the VolumeGroup. -// volumeName - The name of the Volume. -// options - VolumesClientGetOptions contains the optional parameters for the VolumesClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - elasticSanName - The name of the ElasticSan. +// - volumeGroupName - The name of the VolumeGroup. +// - volumeName - The name of the Volume. +// - options - VolumesClientGetOptions contains the optional parameters for the VolumesClient.Get method. func (client *VolumesClient) Get(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, options *VolumesClientGetOptions) (VolumesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, elasticSanName, volumeGroupName, volumeName, options) if err != nil { return VolumesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VolumesClientGetResponse{}, err } @@ -250,7 +244,7 @@ func (client *VolumesClient) getCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter volumeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{volumeName}", url.PathEscape(volumeName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -271,12 +265,13 @@ func (client *VolumesClient) getHandleResponse(resp *http.Response) (VolumesClie } // NewListByVolumeGroupPager - List Volumes in a VolumeGroup. +// // Generated from API version 2021-11-20-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// elasticSanName - The name of the ElasticSan. -// volumeGroupName - The name of the VolumeGroup. -// options - VolumesClientListByVolumeGroupOptions contains the optional parameters for the VolumesClient.ListByVolumeGroup -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - elasticSanName - The name of the ElasticSan. +// - volumeGroupName - The name of the VolumeGroup. +// - options - VolumesClientListByVolumeGroupOptions contains the optional parameters for the VolumesClient.NewListByVolumeGroupPager +// method. func (client *VolumesClient) NewListByVolumeGroupPager(resourceGroupName string, elasticSanName string, volumeGroupName string, options *VolumesClientListByVolumeGroupOptions) *runtime.Pager[VolumesClientListByVolumeGroupResponse] { return runtime.NewPager(runtime.PagingHandler[VolumesClientListByVolumeGroupResponse]{ More: func(page VolumesClientListByVolumeGroupResponse) bool { @@ -293,7 +288,7 @@ func (client *VolumesClient) NewListByVolumeGroupPager(resourceGroupName string, if err != nil { return VolumesClientListByVolumeGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return VolumesClientListByVolumeGroupResponse{}, err } @@ -324,7 +319,7 @@ func (client *VolumesClient) listByVolumeGroupCreateRequest(ctx context.Context, return nil, errors.New("parameter volumeGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{volumeGroupName}", url.PathEscape(volumeGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -346,36 +341,38 @@ func (client *VolumesClient) listByVolumeGroupHandleResponse(resp *http.Response // BeginUpdate - Update an Volume. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// elasticSanName - The name of the ElasticSan. -// volumeGroupName - The name of the VolumeGroup. -// volumeName - The name of the Volume. -// parameters - Volume object. -// options - VolumesClientBeginUpdateOptions contains the optional parameters for the VolumesClient.BeginUpdate method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - elasticSanName - The name of the ElasticSan. +// - volumeGroupName - The name of the VolumeGroup. +// - volumeName - The name of the Volume. +// - parameters - Volume object. +// - options - VolumesClientBeginUpdateOptions contains the optional parameters for the VolumesClient.BeginUpdate method. func (client *VolumesClient) BeginUpdate(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, parameters VolumeUpdate, options *VolumesClientBeginUpdateOptions) (*runtime.Poller[VolumesClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, elasticSanName, volumeGroupName, volumeName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[VolumesClientUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VolumesClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[VolumesClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[VolumesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Update an Volume. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-11-20-preview func (client *VolumesClient) update(ctx context.Context, resourceGroupName string, elasticSanName string, volumeGroupName string, volumeName string, parameters VolumeUpdate, options *VolumesClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, elasticSanName, volumeGroupName, volumeName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -408,7 +405,7 @@ func (client *VolumesClient) updateCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter volumeName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{volumeName}", url.PathEscape(volumeName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/elasticsan/armelasticsan/volumes_client_example_test.go b/sdk/resourcemanager/elasticsan/armelasticsan/volumes_client_example_test.go index 0c9b41cc9616..67789b1cf043 100644 --- a/sdk/resourcemanager/elasticsan/armelasticsan/volumes_client_example_test.go +++ b/sdk/resourcemanager/elasticsan/armelasticsan/volumes_client_example_test.go @@ -5,6 +5,7 @@ // 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 armelasticsan_test @@ -17,18 +18,18 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/elasticsan/armelasticsan" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_Create_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_Create_MaximumSet_Gen.json func ExampleVolumesClient_BeginCreate_volumesCreateMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumesClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", "9132y", armelasticsan.Volume{ + poller, err := clientFactory.NewVolumesClient().BeginCreate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", "9132y", armelasticsan.Volume{ Tags: map[string]*string{ "key7423": to.Ptr("aaaa"), }, @@ -47,22 +48,54 @@ func ExampleVolumesClient_BeginCreate_volumesCreateMaximumSetGen() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // 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.Volume = armelasticsan.Volume{ + // Name: to.Ptr("aaaaaaaaaaaa"), + // Type: to.Ptr("aaaaaaaaaaaaaaaaaaaaa"), + // ID: to.Ptr("aaaaaaaa"), + // Tags: map[string]*string{ + // "key7423": to.Ptr("aaaa"), + // }, + // Properties: &armelasticsan.VolumeProperties{ + // CreationData: &armelasticsan.SourceCreationData{ + // CreateSource: to.Ptr("None"), + // SourceURI: to.Ptr("aaaaaa"), + // }, + // SizeGiB: to.Ptr[int64](22), + // StorageTarget: &armelasticsan.IscsiTargetInfo{ + // ProvisioningState: to.Ptr(armelasticsan.ProvisioningStatesSucceeded), + // Status: to.Ptr(armelasticsan.OperationalStatusInvalid), + // TargetIqn: to.Ptr("aaaaaaaaaaaaaaaaaa"), + // TargetPortalHostname: to.Ptr("aaaaaaa"), + // TargetPortalPort: to.Ptr[int32](23), + // }, + // VolumeID: to.Ptr("aaaaaaaaaa"), + // }, + // SystemData: &armelasticsan.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // CreatedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaa"), + // CreatedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // LastModifiedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // LastModifiedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_Create_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_Create_MinimumSet_Gen.json func ExampleVolumesClient_BeginCreate_volumesCreateMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumesClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", "9132y", armelasticsan.Volume{}, nil) + poller, err := clientFactory.NewVolumesClient().BeginCreate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", "9132y", armelasticsan.Volume{}, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -70,22 +103,25 @@ func ExampleVolumesClient_BeginCreate_volumesCreateMinimumSetGen() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // 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.Volume = armelasticsan.Volume{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_Update_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_Update_MaximumSet_Gen.json func ExampleVolumesClient_BeginUpdate_volumesUpdateMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumesClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", "9132y", armelasticsan.VolumeUpdate{ + poller, err := clientFactory.NewVolumesClient().BeginUpdate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", "9132y", armelasticsan.VolumeUpdate{ Properties: &armelasticsan.VolumeUpdateProperties{ SizeGiB: to.Ptr[int64](9), }, @@ -100,22 +136,54 @@ func ExampleVolumesClient_BeginUpdate_volumesUpdateMaximumSetGen() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // 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.Volume = armelasticsan.Volume{ + // Name: to.Ptr("aaaaaaaaaaaa"), + // Type: to.Ptr("aaaaaaaaaaaaaaaaaaaaa"), + // ID: to.Ptr("aaaaaaaa"), + // Tags: map[string]*string{ + // "key7423": to.Ptr("aaaa"), + // }, + // Properties: &armelasticsan.VolumeProperties{ + // CreationData: &armelasticsan.SourceCreationData{ + // CreateSource: to.Ptr("None"), + // SourceURI: to.Ptr("aaaaaa"), + // }, + // SizeGiB: to.Ptr[int64](22), + // StorageTarget: &armelasticsan.IscsiTargetInfo{ + // ProvisioningState: to.Ptr(armelasticsan.ProvisioningStatesSucceeded), + // Status: to.Ptr(armelasticsan.OperationalStatusInvalid), + // TargetIqn: to.Ptr("aaaaaaaaaaaaaaaaaa"), + // TargetPortalHostname: to.Ptr("aaaaaaa"), + // TargetPortalPort: to.Ptr[int32](23), + // }, + // VolumeID: to.Ptr("aaaaaaaaaa"), + // }, + // SystemData: &armelasticsan.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // CreatedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaa"), + // CreatedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // LastModifiedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // LastModifiedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_Update_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_Update_MinimumSet_Gen.json func ExampleVolumesClient_BeginUpdate_volumesUpdateMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumesClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", "9132y", armelasticsan.VolumeUpdate{}, nil) + poller, err := clientFactory.NewVolumesClient().BeginUpdate(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", "9132y", armelasticsan.VolumeUpdate{}, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -123,22 +191,25 @@ func ExampleVolumesClient_BeginUpdate_volumesUpdateMinimumSetGen() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // 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.Volume = armelasticsan.Volume{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_Delete_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_Delete_MaximumSet_Gen.json func ExampleVolumesClient_BeginDelete_volumesDeleteMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumesClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", "9132y", nil) + poller, err := clientFactory.NewVolumesClient().BeginDelete(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", "9132y", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -148,18 +219,18 @@ func ExampleVolumesClient_BeginDelete_volumesDeleteMaximumSetGen() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_Delete_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_Delete_MinimumSet_Gen.json func ExampleVolumesClient_BeginDelete_volumesDeleteMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumesClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", "9132y", nil) + poller, err := clientFactory.NewVolumesClient().BeginDelete(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", "9132y", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -169,88 +240,164 @@ func ExampleVolumesClient_BeginDelete_volumesDeleteMinimumSetGen() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_Get_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_Get_MaximumSet_Gen.json func ExampleVolumesClient_Get_volumesGetMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumesClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", "9132y", nil) + res, err := clientFactory.NewVolumesClient().Get(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", "9132y", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.Volume = armelasticsan.Volume{ + // Name: to.Ptr("aaaaaaaaaaaa"), + // Type: to.Ptr("aaaaaaaaaaaaaaaaaaaaa"), + // ID: to.Ptr("aaaaaaaa"), + // Tags: map[string]*string{ + // "key7423": to.Ptr("aaaa"), + // }, + // Properties: &armelasticsan.VolumeProperties{ + // CreationData: &armelasticsan.SourceCreationData{ + // CreateSource: to.Ptr("None"), + // SourceURI: to.Ptr("aaaaaa"), + // }, + // SizeGiB: to.Ptr[int64](22), + // StorageTarget: &armelasticsan.IscsiTargetInfo{ + // ProvisioningState: to.Ptr(armelasticsan.ProvisioningStatesSucceeded), + // Status: to.Ptr(armelasticsan.OperationalStatusInvalid), + // TargetIqn: to.Ptr("aaaaaaaaaaaaaaaaaa"), + // TargetPortalHostname: to.Ptr("aaaaaaa"), + // TargetPortalPort: to.Ptr[int32](23), + // }, + // VolumeID: to.Ptr("aaaaaaaaaa"), + // }, + // SystemData: &armelasticsan.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // CreatedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaa"), + // CreatedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // LastModifiedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // LastModifiedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_Get_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_Get_MinimumSet_Gen.json func ExampleVolumesClient_Get_volumesGetMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumesClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", "9132y", nil) + res, err := clientFactory.NewVolumesClient().Get(ctx, "rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", "9132y", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.Volume = armelasticsan.Volume{ + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_ListByVolumeGroup_MaximumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_ListByVolumeGroup_MaximumSet_Gen.json func ExampleVolumesClient_NewListByVolumeGroupPager_volumesListByVolumeGroupMaximumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumesClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByVolumeGroupPager("rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", nil) + pager := clientFactory.NewVolumesClient().NewListByVolumeGroupPager("rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.VolumeList = armelasticsan.VolumeList{ + // Value: []*armelasticsan.Volume{ + // { + // Name: to.Ptr("aaaaaaaaaaaa"), + // Type: to.Ptr("aaaaaaaaaaaaaaaaaaaaa"), + // ID: to.Ptr("aaaaaaaa"), + // Tags: map[string]*string{ + // "key7423": to.Ptr("aaaa"), + // }, + // Properties: &armelasticsan.VolumeProperties{ + // CreationData: &armelasticsan.SourceCreationData{ + // CreateSource: to.Ptr("None"), + // SourceURI: to.Ptr("aaaaaa"), + // }, + // SizeGiB: to.Ptr[int64](22), + // StorageTarget: &armelasticsan.IscsiTargetInfo{ + // ProvisioningState: to.Ptr(armelasticsan.ProvisioningStatesSucceeded), + // Status: to.Ptr(armelasticsan.OperationalStatusInvalid), + // TargetIqn: to.Ptr("aaaaaaaaaaaaaaaaaa"), + // TargetPortalHostname: to.Ptr("aaaaaaa"), + // TargetPortalPort: to.Ptr[int32](23), + // }, + // VolumeID: to.Ptr("aaaaaaaaaa"), + // }, + // SystemData: &armelasticsan.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // CreatedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaa"), + // CreatedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-08T10:39:37.620Z"); return t}()), + // LastModifiedBy: to.Ptr("aaaaaaaaaaaaaaaaaaaaaaaaaaa"), + // LastModifiedByType: to.Ptr(armelasticsan.CreatedByTypeUser), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_ListByVolumeGroup_MinimumSet_Gen.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e1da7cbab8d4f554484dedb676ba7bdbdf6cdf78/specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2021-11-20-preview/examples/Volumes_ListByVolumeGroup_MinimumSet_Gen.json func ExampleVolumesClient_NewListByVolumeGroupPager_volumesListByVolumeGroupMinimumSetGen() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armelasticsan.NewVolumesClient("aaaaaaaaaaaaaaaaaa", cred, nil) + clientFactory, err := armelasticsan.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByVolumeGroupPager("rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", nil) + pager := clientFactory.NewVolumesClient().NewListByVolumeGroupPager("rgelasticsan", "ti7q-k952-1qB3J_5", "u_5I_1j4t3", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.VolumeList = armelasticsan.VolumeList{ + // Value: []*armelasticsan.Volume{ + // { + // }}, + // } } } diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/CHANGELOG.md b/sdk/resourcemanager/engagementfabric/armengagementfabric/CHANGELOG.md index 22bfc4acdb5b..44897b06c7bc 100644 --- a/sdk/resourcemanager/engagementfabric/armengagementfabric/CHANGELOG.md +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 0.2.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 0.1.0 (2022-06-10) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/engagementfabric/armengagementfabric` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 0.1.0, which contains breaking changes. diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/README.md b/sdk/resourcemanager/engagementfabric/armengagementfabric/README.md index b319c3bd4cc9..c2b8ff792f3e 100644 --- a/sdk/resourcemanager/engagementfabric/armengagementfabric/README.md +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/README.md @@ -33,23 +33,31 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Engagement Fabric modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Engagement Fabric module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armengagementfabric.NewClient(, cred, nil) +clientFactory, err := armengagementfabric.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). ```go -options := arm.ClientOptions{ +options := arm.ClientOptions { ClientOptions: azcore.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armengagementfabric.NewClient(, cred, &options) +clientFactory, err := armengagementfabric.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewAccountsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_accounts_client.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/accounts_client.go similarity index 87% rename from sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_accounts_client.go rename to sdk/resourcemanager/engagementfabric/armengagementfabric/accounts_client.go index e931916f6223..46a441972b34 100644 --- a/sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_accounts_client.go +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/accounts_client.go @@ -5,6 +5,7 @@ // 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 armengagementfabric @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // AccountsClient contains the methods for the Accounts group. // Don't use this type directly, use NewAccountsClient() instead. type AccountsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAccountsClient creates a new instance of AccountsClient with the specified values. -// subscriptionID - Subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAccountsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AccountsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AccountsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AccountsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or Update the EngagementFabric account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-01-preview -// resourceGroupName - Resource Group Name -// accountName - Account Name -// account - The EngagementFabric account description -// options - AccountsClientCreateOrUpdateOptions contains the optional parameters for the AccountsClient.CreateOrUpdate method. +// - resourceGroupName - Resource Group Name +// - accountName - Account Name +// - account - The EngagementFabric account description +// - options - AccountsClientCreateOrUpdateOptions contains the optional parameters for the AccountsClient.CreateOrUpdate method. func (client *AccountsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, account Account, options *AccountsClientCreateOrUpdateOptions) (AccountsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, account, options) if err != nil { return AccountsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientCreateOrUpdateResponse{}, err } @@ -91,7 +82,7 @@ func (client *AccountsClient) createOrUpdateCreateRequest(ctx context.Context, r return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -113,16 +104,17 @@ func (client *AccountsClient) createOrUpdateHandleResponse(resp *http.Response) // Delete - Delete the EngagementFabric account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-01-preview -// resourceGroupName - Resource Group Name -// accountName - Account Name -// options - AccountsClientDeleteOptions contains the optional parameters for the AccountsClient.Delete method. +// - resourceGroupName - Resource Group Name +// - accountName - Account Name +// - options - AccountsClientDeleteOptions contains the optional parameters for the AccountsClient.Delete method. func (client *AccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientDeleteOptions) (AccountsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return AccountsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientDeleteResponse{}, err } @@ -147,7 +139,7 @@ func (client *AccountsClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -160,16 +152,17 @@ func (client *AccountsClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Get the EngagementFabric account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-01-preview -// resourceGroupName - Resource Group Name -// accountName - Account Name -// options - AccountsClientGetOptions contains the optional parameters for the AccountsClient.Get method. +// - resourceGroupName - Resource Group Name +// - accountName - Account Name +// - options - AccountsClientGetOptions contains the optional parameters for the AccountsClient.Get method. func (client *AccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientGetOptions) (AccountsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return AccountsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientGetResponse{}, err } @@ -194,7 +187,7 @@ func (client *AccountsClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -215,9 +208,9 @@ func (client *AccountsClient) getHandleResponse(resp *http.Response) (AccountsCl } // NewListPager - List the EngagementFabric accounts in given subscription -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-01-preview -// options - AccountsClientListOptions contains the optional parameters for the AccountsClient.List method. +// - options - AccountsClientListOptions contains the optional parameters for the AccountsClient.NewListPager method. func (client *AccountsClient) NewListPager(options *AccountsClientListOptions) *runtime.Pager[AccountsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AccountsClientListResponse]{ More: func(page AccountsClientListResponse) bool { @@ -228,7 +221,7 @@ func (client *AccountsClient) NewListPager(options *AccountsClientListOptions) * if err != nil { return AccountsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientListResponse{}, err } @@ -247,7 +240,7 @@ func (client *AccountsClient) listCreateRequest(ctx context.Context, options *Ac return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -268,11 +261,11 @@ func (client *AccountsClient) listHandleResponse(resp *http.Response) (AccountsC } // NewListByResourceGroupPager - List EngagementFabric accounts in given resource group -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-01-preview -// resourceGroupName - Resource Group Name -// options - AccountsClientListByResourceGroupOptions contains the optional parameters for the AccountsClient.ListByResourceGroup -// method. +// - resourceGroupName - Resource Group Name +// - options - AccountsClientListByResourceGroupOptions contains the optional parameters for the AccountsClient.NewListByResourceGroupPager +// method. func (client *AccountsClient) NewListByResourceGroupPager(resourceGroupName string, options *AccountsClientListByResourceGroupOptions) *runtime.Pager[AccountsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[AccountsClientListByResourceGroupResponse]{ More: func(page AccountsClientListByResourceGroupResponse) bool { @@ -283,7 +276,7 @@ func (client *AccountsClient) NewListByResourceGroupPager(resourceGroupName stri if err != nil { return AccountsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientListByResourceGroupResponse{}, err } @@ -306,7 +299,7 @@ func (client *AccountsClient) listByResourceGroupCreateRequest(ctx context.Conte return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -328,17 +321,18 @@ func (client *AccountsClient) listByResourceGroupHandleResponse(resp *http.Respo // ListChannelTypes - List available EngagementFabric channel types and functions // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-01-preview -// resourceGroupName - Resource Group Name -// accountName - Account Name -// options - AccountsClientListChannelTypesOptions contains the optional parameters for the AccountsClient.ListChannelTypes -// method. +// - resourceGroupName - Resource Group Name +// - accountName - Account Name +// - options - AccountsClientListChannelTypesOptions contains the optional parameters for the AccountsClient.ListChannelTypes +// method. func (client *AccountsClient) ListChannelTypes(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientListChannelTypesOptions) (AccountsClientListChannelTypesResponse, error) { req, err := client.listChannelTypesCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return AccountsClientListChannelTypesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientListChannelTypesResponse{}, err } @@ -363,7 +357,7 @@ func (client *AccountsClient) listChannelTypesCreateRequest(ctx context.Context, return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -384,11 +378,11 @@ func (client *AccountsClient) listChannelTypesHandleResponse(resp *http.Response } // NewListKeysPager - List keys of the EngagementFabric account -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-01-preview -// resourceGroupName - Resource Group Name -// accountName - Account Name -// options - AccountsClientListKeysOptions contains the optional parameters for the AccountsClient.ListKeys method. +// - resourceGroupName - Resource Group Name +// - accountName - Account Name +// - options - AccountsClientListKeysOptions contains the optional parameters for the AccountsClient.NewListKeysPager method. func (client *AccountsClient) NewListKeysPager(resourceGroupName string, accountName string, options *AccountsClientListKeysOptions) *runtime.Pager[AccountsClientListKeysResponse] { return runtime.NewPager(runtime.PagingHandler[AccountsClientListKeysResponse]{ More: func(page AccountsClientListKeysResponse) bool { @@ -399,7 +393,7 @@ func (client *AccountsClient) NewListKeysPager(resourceGroupName string, account if err != nil { return AccountsClientListKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientListKeysResponse{}, err } @@ -426,7 +420,7 @@ func (client *AccountsClient) listKeysCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -448,17 +442,18 @@ func (client *AccountsClient) listKeysHandleResponse(resp *http.Response) (Accou // RegenerateKey - Regenerate key of the EngagementFabric account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-01-preview -// resourceGroupName - Resource Group Name -// accountName - Account Name -// parameter - Parameters specifying the key to be regenerated -// options - AccountsClientRegenerateKeyOptions contains the optional parameters for the AccountsClient.RegenerateKey method. +// - resourceGroupName - Resource Group Name +// - accountName - Account Name +// - parameter - Parameters specifying the key to be regenerated +// - options - AccountsClientRegenerateKeyOptions contains the optional parameters for the AccountsClient.RegenerateKey method. func (client *AccountsClient) RegenerateKey(ctx context.Context, resourceGroupName string, accountName string, parameter RegenerateKeyParameter, options *AccountsClientRegenerateKeyOptions) (AccountsClientRegenerateKeyResponse, error) { req, err := client.regenerateKeyCreateRequest(ctx, resourceGroupName, accountName, parameter, options) if err != nil { return AccountsClientRegenerateKeyResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientRegenerateKeyResponse{}, err } @@ -483,7 +478,7 @@ func (client *AccountsClient) regenerateKeyCreateRequest(ctx context.Context, re return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -505,17 +500,18 @@ func (client *AccountsClient) regenerateKeyHandleResponse(resp *http.Response) ( // Update - Update EngagementFabric account // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-01-preview -// resourceGroupName - Resource Group Name -// accountName - Account Name -// accountPatch - The account patch -// options - AccountsClientUpdateOptions contains the optional parameters for the AccountsClient.Update method. +// - resourceGroupName - Resource Group Name +// - accountName - Account Name +// - accountPatch - The account patch +// - options - AccountsClientUpdateOptions contains the optional parameters for the AccountsClient.Update method. func (client *AccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, accountPatch AccountPatch, options *AccountsClientUpdateOptions) (AccountsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, accountPatch, options) if err != nil { return AccountsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientUpdateResponse{}, err } @@ -540,7 +536,7 @@ func (client *AccountsClient) updateCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/accounts_client_example_test.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/accounts_client_example_test.go new file mode 100644 index 000000000000..a0f9e4fc3359 --- /dev/null +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/accounts_client_example_test.go @@ -0,0 +1,372 @@ +//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 armengagementfabric_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/engagementfabric/armengagementfabric" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/AccountsGetExample.json +func ExampleAccountsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armengagementfabric.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().Get(ctx, "ExampleRg", "ExampleAccount", 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.Account = armengagementfabric.Account{ + // Name: to.Ptr("ExampleAccount"), + // Type: to.Ptr("Microsoft.EngagementFabric/Accounts"), + // ID: to.Ptr("subscriptions/EDBF0095-A524-4A84-95FB-F72DA41AA6A1/resourceGroups/ExampleRg/providers/Microsoft.EngagementFabric/Accounts/ExampleAccount"), + // Location: to.Ptr("WestUS"), + // SKU: &armengagementfabric.SKU{ + // Name: to.Ptr("B1"), + // Tier: to.Ptr("Basic"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/AccountsCreateOrUpdateExample.json +func ExampleAccountsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armengagementfabric.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().CreateOrUpdate(ctx, "ExampleRg", "ExampleAccount", armengagementfabric.Account{ + Location: to.Ptr("WestUS"), + SKU: &armengagementfabric.SKU{ + Name: to.Ptr("B1"), + }, + }, 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.Account = armengagementfabric.Account{ + // Name: to.Ptr("ExampleAccount"), + // Type: to.Ptr("Microsoft.EngagementFabric/Accounts"), + // ID: to.Ptr("subscriptions/EDBF0095-A524-4A84-95FB-F72DA41AA6A1/resourceGroups/ExampleRg/providers/Microsoft.EngagementFabric/Accounts/ExampleAccount"), + // Location: to.Ptr("WestUS"), + // SKU: &armengagementfabric.SKU{ + // Name: to.Ptr("B1"), + // Tier: to.Ptr("Basic"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/AccountsDeleteExample.json +func ExampleAccountsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armengagementfabric.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewAccountsClient().Delete(ctx, "ExampleRg", "ExampleAccount", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/AccountsUpdateExample.json +func ExampleAccountsClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armengagementfabric.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().Update(ctx, "ExampleRg", "ExampleAccount", armengagementfabric.AccountPatch{ + Tags: map[string]*string{ + "tagName": to.Ptr("tagValue"), + }, + }, 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.Account = armengagementfabric.Account{ + // Name: to.Ptr("ExampleAccount"), + // Type: to.Ptr("Microsoft.EngagementFabric/Accounts"), + // ID: to.Ptr("subscriptions/EDBF0095-A524-4A84-95FB-F72DA41AA6A1/resourceGroups/ExampleRg/providers/Microsoft.EngagementFabric/Accounts/ExampleAccount"), + // Location: to.Ptr("WestUS"), + // SKU: &armengagementfabric.SKU{ + // Name: to.Ptr("B1"), + // Tier: to.Ptr("Basic"), + // }, + // Tags: map[string]*string{ + // "tagName": to.Ptr("tagValue"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/AccountsListExample.json +func ExampleAccountsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armengagementfabric.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAccountsClient().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.AccountList = armengagementfabric.AccountList{ + // Value: []*armengagementfabric.Account{ + // { + // Name: to.Ptr("ExampleAccount"), + // Type: to.Ptr("Microsoft.EngagementFabric/Accounts"), + // ID: to.Ptr("subscriptions/EDBF0095-A524-4A84-95FB-F72DA41AA6A1/resourceGroups/ExampleRg/providers/Microsoft.EngagementFabric/Accounts/ExampleAccount"), + // Location: to.Ptr("WestUS"), + // SKU: &armengagementfabric.SKU{ + // Name: to.Ptr("B1"), + // Tier: to.Ptr("Basic"), + // }, + // }, + // { + // Name: to.Ptr("ExampleAccount2"), + // Type: to.Ptr("Microsoft.EngagementFabric/Accounts"), + // ID: to.Ptr("subscriptions/EDBF0095-A524-4A84-95FB-F72DA41AA6A1/resourceGroups/ExampleRg/providers/Microsoft.EngagementFabric/Accounts/ExampleAccount2"), + // Location: to.Ptr("WestUS"), + // SKU: &armengagementfabric.SKU{ + // Name: to.Ptr("S1"), + // Tier: to.Ptr("Standard"), + // }, + // }, + // { + // Name: to.Ptr("ExampleAccount3"), + // Type: to.Ptr("Microsoft.EngagementFabric/Accounts"), + // ID: to.Ptr("subscriptions/EDBF0095-A524-4A84-95FB-F72DA41AA6A1/resourceGroups/ExampleRg/providers/Microsoft.EngagementFabric/Accounts/ExampleAccount3"), + // Location: to.Ptr("WestUS"), + // SKU: &armengagementfabric.SKU{ + // Name: to.Ptr("P1"), + // Tier: to.Ptr("Premium"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/AccountsListByResourceGroupExample.json +func ExampleAccountsClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armengagementfabric.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAccountsClient().NewListByResourceGroupPager("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.AccountList = armengagementfabric.AccountList{ + // Value: []*armengagementfabric.Account{ + // { + // Name: to.Ptr("ExampleAccount"), + // Type: to.Ptr("Microsoft.EngagementFabric/Accounts"), + // ID: to.Ptr("subscriptions/EDBF0095-A524-4A84-95FB-F72DA41AA6A1/resourceGroups/ExampleRg/providers/Microsoft.EngagementFabric/Accounts/ExampleAccount"), + // Location: to.Ptr("WestUS"), + // SKU: &armengagementfabric.SKU{ + // Name: to.Ptr("B1"), + // Tier: to.Ptr("Basic"), + // }, + // }, + // { + // Name: to.Ptr("ExampleAccount2"), + // Type: to.Ptr("Microsoft.EngagementFabric/Accounts"), + // ID: to.Ptr("subscriptions/EDBF0095-A524-4A84-95FB-F72DA41AA6A1/resourceGroups/ExampleRg/providers/Microsoft.EngagementFabric/Accounts/ExampleAccount2"), + // Location: to.Ptr("WestUS"), + // SKU: &armengagementfabric.SKU{ + // Name: to.Ptr("S1"), + // Tier: to.Ptr("Standard"), + // }, + // }, + // { + // Name: to.Ptr("ExampleAccount3"), + // Type: to.Ptr("Microsoft.EngagementFabric/Accounts"), + // ID: to.Ptr("subscriptions/EDBF0095-A524-4A84-95FB-F72DA41AA6A1/resourceGroups/ExampleRg/providers/Microsoft.EngagementFabric/Accounts/ExampleAccount3"), + // Location: to.Ptr("WestUS"), + // SKU: &armengagementfabric.SKU{ + // Name: to.Ptr("P1"), + // Tier: to.Ptr("Premium"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/AccountsListKeysExample.json +func ExampleAccountsClient_NewListKeysPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armengagementfabric.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAccountsClient().NewListKeysPager("ExampleRg", "ExampleAccount", 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.KeyDescriptionList = armengagementfabric.KeyDescriptionList{ + // Value: []*armengagementfabric.KeyDescription{ + // { + // Name: to.Ptr("Full"), + // Rank: to.Ptr(armengagementfabric.KeyRankPrimaryKey), + // Value: to.Ptr(""), + // }, + // { + // Name: to.Ptr("Full"), + // Rank: to.Ptr(armengagementfabric.KeyRankSecondaryKey), + // Value: to.Ptr(""), + // }, + // { + // Name: to.Ptr("Device"), + // Rank: to.Ptr(armengagementfabric.KeyRankPrimaryKey), + // Value: to.Ptr(""), + // }, + // { + // Name: to.Ptr("Device"), + // Rank: to.Ptr(armengagementfabric.KeyRankSecondaryKey), + // Value: to.Ptr(""), + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/AccountsRegenerateKeyExample.json +func ExampleAccountsClient_RegenerateKey() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armengagementfabric.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().RegenerateKey(ctx, "ExampleRg", "ExampleAccount", armengagementfabric.RegenerateKeyParameter{}, 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.KeyDescription = armengagementfabric.KeyDescription{ + // Name: to.Ptr("Full"), + // Rank: to.Ptr(armengagementfabric.KeyRankPrimaryKey), + // Value: to.Ptr(""), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/AccountsListChannelTypesExample.json +func ExampleAccountsClient_ListChannelTypes() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armengagementfabric.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAccountsClient().ListChannelTypes(ctx, "ExampleRg", "ExampleAccount", 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.ChannelTypeDescriptionList = armengagementfabric.ChannelTypeDescriptionList{ + // Value: []*armengagementfabric.ChannelTypeDescription{ + // { + // ChannelDescription: to.Ptr("Description of mockChannel1"), + // ChannelFunctions: []*string{ + // to.Ptr("MockFunction1"), + // to.Ptr("MockFunction2")}, + // ChannelType: to.Ptr("MockChannel1"), + // }, + // { + // ChannelDescription: to.Ptr("Description of mockChannel2"), + // ChannelFunctions: []*string{ + // to.Ptr("MockFunction1"), + // to.Ptr("MockFunction3")}, + // ChannelType: to.Ptr("MockChannel2"), + // }, + // { + // ChannelDescription: to.Ptr("Description of mockChannel3"), + // ChannelFunctions: []*string{ + // to.Ptr("MockFunction1"), + // to.Ptr("MockFunction2"), + // to.Ptr("MockFunction3")}, + // ChannelType: to.Ptr("MockChannel3"), + // }}, + // } +} diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/autorest.md b/sdk/resourcemanager/engagementfabric/armengagementfabric/autorest.md index 39f9ca7afd2e..18b450aced87 100644 --- a/sdk/resourcemanager/engagementfabric/armengagementfabric/autorest.md +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/engagementfabric/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/engagementfabric/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.1.0 +module-version: 0.2.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_channels_client.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/channels_client.go similarity index 85% rename from sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_channels_client.go rename to sdk/resourcemanager/engagementfabric/armengagementfabric/channels_client.go index 28d445654d4f..ed38363f9a4c 100644 --- a/sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_channels_client.go +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/channels_client.go @@ -5,6 +5,7 @@ // 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 armengagementfabric @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,49 +24,41 @@ import ( // ChannelsClient contains the methods for the Channels group. // Don't use this type directly, use NewChannelsClient() instead. type ChannelsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewChannelsClient creates a new instance of ChannelsClient with the specified values. -// subscriptionID - Subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewChannelsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ChannelsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ChannelsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ChannelsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or Update the EngagementFabric channel // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-01-preview -// resourceGroupName - Resource Group Name -// accountName - Account Name -// channelName - Channel Name -// channel - The EngagementFabric channel description -// options - ChannelsClientCreateOrUpdateOptions contains the optional parameters for the ChannelsClient.CreateOrUpdate method. +// - resourceGroupName - Resource Group Name +// - accountName - Account Name +// - channelName - Channel Name +// - channel - The EngagementFabric channel description +// - options - ChannelsClientCreateOrUpdateOptions contains the optional parameters for the ChannelsClient.CreateOrUpdate method. func (client *ChannelsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, channelName string, channel Channel, options *ChannelsClientCreateOrUpdateOptions) (ChannelsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, channelName, channel, options) if err != nil { return ChannelsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ChannelsClientCreateOrUpdateResponse{}, err } @@ -96,7 +87,7 @@ func (client *ChannelsClient) createOrUpdateCreateRequest(ctx context.Context, r return nil, errors.New("parameter channelName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{channelName}", url.PathEscape(channelName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -118,17 +109,18 @@ func (client *ChannelsClient) createOrUpdateHandleResponse(resp *http.Response) // Delete - Delete the EngagementFabric channel // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-01-preview -// resourceGroupName - Resource Group Name -// accountName - Account Name -// channelName - The EngagementFabric channel name -// options - ChannelsClientDeleteOptions contains the optional parameters for the ChannelsClient.Delete method. +// - resourceGroupName - Resource Group Name +// - accountName - Account Name +// - channelName - The EngagementFabric channel name +// - options - ChannelsClientDeleteOptions contains the optional parameters for the ChannelsClient.Delete method. func (client *ChannelsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, channelName string, options *ChannelsClientDeleteOptions) (ChannelsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, channelName, options) if err != nil { return ChannelsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ChannelsClientDeleteResponse{}, err } @@ -157,7 +149,7 @@ func (client *ChannelsClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter channelName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{channelName}", url.PathEscape(channelName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -170,17 +162,18 @@ func (client *ChannelsClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Get the EngagementFabric channel // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-01-preview -// resourceGroupName - Resource Group Name -// accountName - Account Name -// channelName - Channel Name -// options - ChannelsClientGetOptions contains the optional parameters for the ChannelsClient.Get method. +// - resourceGroupName - Resource Group Name +// - accountName - Account Name +// - channelName - Channel Name +// - options - ChannelsClientGetOptions contains the optional parameters for the ChannelsClient.Get method. func (client *ChannelsClient) Get(ctx context.Context, resourceGroupName string, accountName string, channelName string, options *ChannelsClientGetOptions) (ChannelsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, channelName, options) if err != nil { return ChannelsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ChannelsClientGetResponse{}, err } @@ -209,7 +202,7 @@ func (client *ChannelsClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter channelName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{channelName}", url.PathEscape(channelName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -230,11 +223,12 @@ func (client *ChannelsClient) getHandleResponse(resp *http.Response) (ChannelsCl } // NewListByAccountPager - List the EngagementFabric channels -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-01-preview -// resourceGroupName - Resource Group Name -// accountName - Account Name -// options - ChannelsClientListByAccountOptions contains the optional parameters for the ChannelsClient.ListByAccount method. +// - resourceGroupName - Resource Group Name +// - accountName - Account Name +// - options - ChannelsClientListByAccountOptions contains the optional parameters for the ChannelsClient.NewListByAccountPager +// method. func (client *ChannelsClient) NewListByAccountPager(resourceGroupName string, accountName string, options *ChannelsClientListByAccountOptions) *runtime.Pager[ChannelsClientListByAccountResponse] { return runtime.NewPager(runtime.PagingHandler[ChannelsClientListByAccountResponse]{ More: func(page ChannelsClientListByAccountResponse) bool { @@ -245,7 +239,7 @@ func (client *ChannelsClient) NewListByAccountPager(resourceGroupName string, ac if err != nil { return ChannelsClientListByAccountResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ChannelsClientListByAccountResponse{}, err } @@ -272,7 +266,7 @@ func (client *ChannelsClient) listByAccountCreateRequest(ctx context.Context, re return nil, errors.New("parameter accountName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/channels_client_example_test.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/channels_client_example_test.go new file mode 100644 index 000000000000..55c0b28ae608 --- /dev/null +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/channels_client_example_test.go @@ -0,0 +1,175 @@ +//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 armengagementfabric_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/engagementfabric/armengagementfabric" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/ChannelsGetExample.json +func ExampleChannelsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armengagementfabric.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewChannelsClient().Get(ctx, "ExampleRg", "ExampleAccount", "ExampleChannel", 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.Channel = armengagementfabric.Channel{ + // Name: to.Ptr("ExampleChannel"), + // Type: to.Ptr("Microsoft.EngagementFabric/Accounts/Channels"), + // ID: to.Ptr("subscriptions/EDBF0095-A524-4A84-95FB-F72DA41AA6A1/resourceGroups/ExampleRg/providers/Microsoft.EngagementFabric/Accounts/ExampleAccount/Channels/ExampleChannel"), + // Properties: &armengagementfabric.ChannelProperties{ + // ChannelFunctions: []*string{ + // to.Ptr("MockFunction1"), + // to.Ptr("MockFunction2")}, + // ChannelType: to.Ptr("MockChannel"), + // Credentials: map[string]*string{ + // "AppId": to.Ptr("exampleApp"), + // "AppKey": to.Ptr(""), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/ChannelsCreateOrUpdateExample.json +func ExampleChannelsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armengagementfabric.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewChannelsClient().CreateOrUpdate(ctx, "ExampleRg", "ExampleAccount", "ExampleChannel", armengagementfabric.Channel{ + Properties: &armengagementfabric.ChannelProperties{ + ChannelFunctions: []*string{ + to.Ptr("MockFunction1"), + to.Ptr("MockFunction2")}, + ChannelType: to.Ptr("MockChannel"), + Credentials: map[string]*string{ + "AppId": to.Ptr("exampleApp"), + "AppKey": to.Ptr("exampleAppKey"), + }, + }, + }, 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.Channel = armengagementfabric.Channel{ + // Name: to.Ptr("ExampleChannel"), + // Type: to.Ptr("Microsoft.EngagementFabric/Accounts/Channels"), + // ID: to.Ptr("subscriptions/EDBF0095-A524-4A84-95FB-F72DA41AA6A1/resourceGroups/ExampleRg/providers/Microsoft.EngagementFabric/Accounts/ExampleAccount/Channels/ExampleChannel"), + // Properties: &armengagementfabric.ChannelProperties{ + // ChannelFunctions: []*string{ + // to.Ptr("MockFunction1"), + // to.Ptr("MockFunction2")}, + // ChannelType: to.Ptr("MockChannel"), + // Credentials: map[string]*string{ + // "AppId": to.Ptr("exampleApp"), + // "AppKey": to.Ptr(""), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/ChannelsDeleteExample.json +func ExampleChannelsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armengagementfabric.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewChannelsClient().Delete(ctx, "ExampleRg", "ExampleAccount", "ExampleChannel", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/ChannelsListExample.json +func ExampleChannelsClient_NewListByAccountPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armengagementfabric.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewChannelsClient().NewListByAccountPager("ExampleRg", "ExampleAccount", 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.ChannelList = armengagementfabric.ChannelList{ + // Value: []*armengagementfabric.Channel{ + // { + // Name: to.Ptr("ExampleChannel"), + // Type: to.Ptr("Microsoft.EngagementFabric/Accounts/Channels"), + // ID: to.Ptr("subscriptions/EDBF0095-A524-4A84-95FB-F72DA41AA6A1/resourceGroups/ExampleRg/providers/Microsoft.EngagementFabric/Accounts/ExampleAccount/Channels/ExampleChannel"), + // Properties: &armengagementfabric.ChannelProperties{ + // ChannelFunctions: []*string{ + // to.Ptr("MockFunction1"), + // to.Ptr("MockFunction2")}, + // ChannelType: to.Ptr("MockChannel"), + // Credentials: map[string]*string{ + // "AppId": to.Ptr("exampleApp"), + // "AppKey": to.Ptr(""), + // }, + // }, + // }, + // { + // Name: to.Ptr("ExampleChannel2"), + // Type: to.Ptr("Microsoft.EngagementFabric/Accounts/Channels"), + // ID: to.Ptr("subscriptions/EDBF0095-A524-4A84-95FB-F72DA41AA6A1/resourceGroups/ExampleRg/providers/Microsoft.EngagementFabric/Accounts/ExampleAccount/Channels/ExampleChannel2"), + // Properties: &armengagementfabric.ChannelProperties{ + // ChannelFunctions: []*string{ + // to.Ptr("MockFunction1"), + // to.Ptr("MockFunction3")}, + // ChannelType: to.Ptr("MockChannel2"), + // Credentials: map[string]*string{ + // "AppId": to.Ptr("exampleApp2"), + // "AppKey": to.Ptr(""), + // }, + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_client.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/client.go similarity index 78% rename from sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_client.go rename to sdk/resourcemanager/engagementfabric/armengagementfabric/client.go index 21685d8b2986..7f07950424c7 100644 --- a/sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_client.go +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/client.go @@ -5,6 +5,7 @@ // 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 armengagementfabric @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,47 +24,39 @@ import ( // Client contains the methods for the EngagementFabric group. // Don't use this type directly, use NewClient() instead. type Client struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewClient creates a new instance of Client with the specified values. -// subscriptionID - Subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".Client", moduleVersion, credential, options) if err != nil { return nil, err } client := &Client{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CheckNameAvailability - Check availability of EngagementFabric resource // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-01-preview -// resourceGroupName - Resource Group Name -// parameters - Parameter describing the name to be checked -// options - ClientCheckNameAvailabilityOptions contains the optional parameters for the Client.CheckNameAvailability method. +// - resourceGroupName - Resource Group Name +// - parameters - Parameter describing the name to be checked +// - options - ClientCheckNameAvailabilityOptions contains the optional parameters for the Client.CheckNameAvailability method. func (client *Client) CheckNameAvailability(ctx context.Context, resourceGroupName string, parameters CheckNameAvailabilityParameter, options *ClientCheckNameAvailabilityOptions) (ClientCheckNameAvailabilityResponse, error) { req, err := client.checkNameAvailabilityCreateRequest(ctx, resourceGroupName, parameters, options) if err != nil { return ClientCheckNameAvailabilityResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientCheckNameAvailabilityResponse{}, err } @@ -86,7 +77,7 @@ func (client *Client) checkNameAvailabilityCreateRequest(ctx context.Context, re return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/client_example_test.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/client_example_test.go new file mode 100644 index 000000000000..e73f0af092ff --- /dev/null +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/client_example_test.go @@ -0,0 +1,43 @@ +//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 armengagementfabric_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/engagementfabric/armengagementfabric" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/CheckNameAvailabilityExample.json +func ExampleClient_CheckNameAvailability() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armengagementfabric.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewClient().CheckNameAvailability(ctx, "", armengagementfabric.CheckNameAvailabilityParameter{}, 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.CheckNameAvailabilityResult = armengagementfabric.CheckNameAvailabilityResult{ + // Message: to.Ptr("Account 'ExampleAccount' already exists"), + // NameAvailable: to.Ptr(false), + // Reason: to.Ptr(armengagementfabric.CheckNameUnavailableReasonAlreadyExists), + // } +} diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/client_factory.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/client_factory.go new file mode 100644 index 000000000000..82bb7abc4237 --- /dev/null +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/client_factory.go @@ -0,0 +1,64 @@ +//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 armengagementfabric + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - Subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewAccountsClient() *AccountsClient { + subClient, _ := NewAccountsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewChannelsClient() *ChannelsClient { + subClient, _ := NewChannelsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewClient() *Client { + subClient, _ := NewClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSKUsClient() *SKUsClient { + subClient, _ := NewSKUsClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_constants.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/constants.go similarity index 97% rename from sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_constants.go rename to sdk/resourcemanager/engagementfabric/armengagementfabric/constants.go index 5364b832cbc7..dd616731a0d4 100644 --- a/sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_constants.go +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/constants.go @@ -5,12 +5,13 @@ // 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 armengagementfabric const ( moduleName = "armengagementfabric" - moduleVersion = "v0.1.0" + moduleVersion = "v0.2.0" ) // CheckNameUnavailableReason - The reason of name availability result diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/go.mod b/sdk/resourcemanager/engagementfabric/armengagementfabric/go.mod index d6b0a43daeb0..ff3fcc8eb206 100644 --- a/sdk/resourcemanager/engagementfabric/armengagementfabric/go.mod +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/engagementfabric/ar go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/go.sum b/sdk/resourcemanager/engagementfabric/armengagementfabric/go.sum index 8828b17b1853..8ba445a8c4da 100644 --- a/sdk/resourcemanager/engagementfabric/armengagementfabric/go.sum +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 h1:BWe8a+f/t+7KY7zH2mqygeUD0t8hNFXe08p1Pb3/jKE= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_models.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/models.go similarity index 92% rename from sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_models.go rename to sdk/resourcemanager/engagementfabric/armengagementfabric/models.go index d6b0ab935e89..f86e244c2470 100644 --- a/sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_models.go +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/models.go @@ -5,6 +5,7 @@ // 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 armengagementfabric @@ -56,7 +57,8 @@ type AccountsClientGetOptions struct { // placeholder for future optional parameters } -// AccountsClientListByResourceGroupOptions contains the optional parameters for the AccountsClient.ListByResourceGroup method. +// AccountsClientListByResourceGroupOptions contains the optional parameters for the AccountsClient.NewListByResourceGroupPager +// method. type AccountsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } @@ -66,12 +68,12 @@ type AccountsClientListChannelTypesOptions struct { // placeholder for future optional parameters } -// AccountsClientListKeysOptions contains the optional parameters for the AccountsClient.ListKeys method. +// AccountsClientListKeysOptions contains the optional parameters for the AccountsClient.NewListKeysPager method. type AccountsClientListKeysOptions struct { // placeholder for future optional parameters } -// AccountsClientListOptions contains the optional parameters for the AccountsClient.List method. +// AccountsClientListOptions contains the optional parameters for the AccountsClient.NewListPager method. type AccountsClientListOptions struct { // placeholder for future optional parameters } @@ -152,7 +154,7 @@ type ChannelsClientGetOptions struct { // placeholder for future optional parameters } -// ChannelsClientListByAccountOptions contains the optional parameters for the ChannelsClient.ListByAccount method. +// ChannelsClientListByAccountOptions contains the optional parameters for the ChannelsClient.NewListByAccountPager method. type ChannelsClientListByAccountOptions struct { // placeholder for future optional parameters } @@ -183,27 +185,6 @@ type ClientCheckNameAvailabilityOptions struct { // placeholder for future optional parameters } -// CloudError - The default error response -type CloudError struct { - // Content of the error - Error *CloudErrorBody `json:"error,omitempty"` -} - -// CloudErrorBody - Content of the default error response -type CloudErrorBody struct { - // The error code - Code *string `json:"code,omitempty"` - - // The list of additional details - Details []*CloudErrorBody `json:"details,omitempty"` - - // The error message - Message *string `json:"message,omitempty"` - - // The target of the particular error - Target *string `json:"target,omitempty"` -} - // KeyDescription - The description of the EngagementFabric account key type KeyDescription struct { // READ-ONLY; The name of the key @@ -252,7 +233,7 @@ type OperationList struct { Value []*Operation `json:"value,omitempty" azure:"ro"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -314,7 +295,7 @@ type SKUDescription struct { ResourceType *string `json:"resourceType,omitempty" azure:"ro"` // READ-ONLY; The restrictions because of which SKU cannot be used - Restrictions []interface{} `json:"restrictions,omitempty" azure:"ro"` + Restrictions []any `json:"restrictions,omitempty" azure:"ro"` // READ-ONLY; The price tier of the SKU Tier *string `json:"tier,omitempty" azure:"ro"` @@ -335,7 +316,7 @@ type SKULocationInfoItem struct { Zones []*string `json:"zones,omitempty"` } -// SKUsClientListOptions contains the optional parameters for the SKUsClient.List method. +// SKUsClientListOptions contains the optional parameters for the SKUsClient.NewListPager method. type SKUsClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/models_serde.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/models_serde.go new file mode 100644 index 000000000000..452fa3c2f985 --- /dev/null +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/models_serde.go @@ -0,0 +1,810 @@ +//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 armengagementfabric + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Account. +func (a Account) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "location", a.Location) + populate(objectMap, "name", a.Name) + populate(objectMap, "sku", a.SKU) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Account. +func (a *Account) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &a.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &a.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccountList. +func (a AccountList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountList. +func (a *AccountList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccountPatch. +func (a AccountPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountPatch. +func (a *AccountPatch) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Channel. +func (c Channel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Channel. +func (c *Channel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ChannelList. +func (c ChannelList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChannelList. +func (c *ChannelList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ChannelProperties. +func (c ChannelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelFunctions", c.ChannelFunctions) + populate(objectMap, "channelType", c.ChannelType) + populate(objectMap, "credentials", c.Credentials) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChannelProperties. +func (c *ChannelProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelFunctions": + err = unpopulate(val, "ChannelFunctions", &c.ChannelFunctions) + delete(rawMsg, key) + case "channelType": + err = unpopulate(val, "ChannelType", &c.ChannelType) + delete(rawMsg, key) + case "credentials": + err = unpopulate(val, "Credentials", &c.Credentials) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ChannelTypeDescription. +func (c ChannelTypeDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "channelDescription", c.ChannelDescription) + populate(objectMap, "channelFunctions", c.ChannelFunctions) + populate(objectMap, "channelType", c.ChannelType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChannelTypeDescription. +func (c *ChannelTypeDescription) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "channelDescription": + err = unpopulate(val, "ChannelDescription", &c.ChannelDescription) + delete(rawMsg, key) + case "channelFunctions": + err = unpopulate(val, "ChannelFunctions", &c.ChannelFunctions) + delete(rawMsg, key) + case "channelType": + err = unpopulate(val, "ChannelType", &c.ChannelType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ChannelTypeDescriptionList. +func (c ChannelTypeDescriptionList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ChannelTypeDescriptionList. +func (c *ChannelTypeDescriptionList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityParameter. +func (c CheckNameAvailabilityParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityParameter. +func (c *CheckNameAvailabilityParameter) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityResult. +func (c CheckNameAvailabilityResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", c.Message) + populate(objectMap, "nameAvailable", c.NameAvailable) + populate(objectMap, "reason", c.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityResult. +func (c *CheckNameAvailabilityResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &c.Message) + delete(rawMsg, key) + case "nameAvailable": + err = unpopulate(val, "NameAvailable", &c.NameAvailable) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &c.Reason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyDescription. +func (k KeyDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", k.Name) + populate(objectMap, "rank", k.Rank) + populate(objectMap, "value", k.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyDescription. +func (k *KeyDescription) 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", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &k.Name) + delete(rawMsg, key) + case "rank": + err = unpopulate(val, "Rank", &k.Rank) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &k.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyDescriptionList. +func (k KeyDescriptionList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", k.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyDescriptionList. +func (k *KeyDescriptionList) 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", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &k.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", o.Display) + populate(objectMap, "name", o.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationList. +func (o OperationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationList. +func (o *OperationList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProxyOnlyResource. +func (p ProxyOnlyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyOnlyResource. +func (p *ProxyOnlyResource) 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 "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 RegenerateKeyParameter. +func (r RegenerateKeyParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", r.Name) + populate(objectMap, "rank", r.Rank) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RegenerateKeyParameter. +func (r *RegenerateKeyParameter) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "rank": + err = unpopulate(val, "Rank", &r.Rank) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SKU. +func (s SKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", s.Name) + populate(objectMap, "tier", s.Tier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKU. +func (s *SKU) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "tier": + err = unpopulate(val, "Tier", &s.Tier) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SKUDescription. +func (s SKUDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "locationInfo", s.LocationInfo) + populate(objectMap, "locations", s.Locations) + populate(objectMap, "name", s.Name) + populate(objectMap, "resourceType", s.ResourceType) + populate(objectMap, "restrictions", s.Restrictions) + populate(objectMap, "tier", s.Tier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKUDescription. +func (s *SKUDescription) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "locationInfo": + err = unpopulate(val, "LocationInfo", &s.LocationInfo) + delete(rawMsg, key) + case "locations": + err = unpopulate(val, "Locations", &s.Locations) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &s.ResourceType) + delete(rawMsg, key) + case "restrictions": + err = unpopulate(val, "Restrictions", &s.Restrictions) + delete(rawMsg, key) + case "tier": + err = unpopulate(val, "Tier", &s.Tier) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SKUDescriptionList. +func (s SKUDescriptionList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKUDescriptionList. +func (s *SKUDescriptionList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SKULocationInfoItem. +func (s SKULocationInfoItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "location", s.Location) + populate(objectMap, "zones", s.Zones) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKULocationInfoItem. +func (s *SKULocationInfoItem) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "location": + err = unpopulate(val, "Location", &s.Location) + delete(rawMsg, key) + case "zones": + err = unpopulate(val, "Zones", &s.Zones) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type 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, "sku", t.SKU) + 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 "sku": + err = unpopulate(val, "SKU", &t.SKU) + 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 +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_operations_client.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/operations_client.go similarity index 76% rename from sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_operations_client.go rename to sdk/resourcemanager/engagementfabric/armengagementfabric/operations_client.go index c08be2ed87b6..ae467d403000 100644 --- a/sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_operations_client.go +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/operations_client.go @@ -5,6 +5,7 @@ // 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 armengagementfabric @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,36 +21,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - List operation of EngagementFabric resources -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-01-preview -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - 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 { @@ -62,7 +52,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -77,7 +67,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.EngagementFabric/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/operations_client_example_test.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/operations_client_example_test.go new file mode 100644 index 000000000000..4561720593d6 --- /dev/null +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/operations_client_example_test.go @@ -0,0 +1,154 @@ +//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 armengagementfabric_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/engagementfabric/armengagementfabric" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/OperationsListExample.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 := armengagementfabric.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.OperationList = armengagementfabric.OperationList{ + // Value: []*armengagementfabric.Operation{ + // { + // Name: to.Ptr("Microsoft.EngagementFabric/Accounts/read"), + // Display: &armengagementfabric.OperationDisplay{ + // Description: to.Ptr("List or get the EngagementFabric account"), + // Operation: to.Ptr("List or get the EngagementFabric account"), + // Provider: to.Ptr("Microsoft Customer Engagement Fabric"), + // Resource: to.Ptr("Accounts"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.EngagementFabric/Accounts/write"), + // Display: &armengagementfabric.OperationDisplay{ + // Description: to.Ptr("Create or update the EngagementFabric account"), + // Operation: to.Ptr("Create or update the EngagementFabric account"), + // Provider: to.Ptr("Microsoft Customer Engagement Fabric"), + // Resource: to.Ptr("Accounts"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.EngagementFabric/Accounts/delete"), + // Display: &armengagementfabric.OperationDisplay{ + // Description: to.Ptr("Delete the EngagementFabric account"), + // Operation: to.Ptr("Delete the EngagementFabric account"), + // Provider: to.Ptr("Microsoft Customer Engagement Fabric"), + // Resource: to.Ptr("Accounts"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.EngagementFabric/Accounts/ListKeys/action"), + // Display: &armengagementfabric.OperationDisplay{ + // Description: to.Ptr("Get all keys of the EngagementFabric account"), + // Operation: to.Ptr("Get all keys of the EngagementFabric account"), + // Provider: to.Ptr("Microsoft Customer Engagement Fabric"), + // Resource: to.Ptr("Accounts"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.EngagementFabric/Accounts/RegenerateKey/action"), + // Display: &armengagementfabric.OperationDisplay{ + // Description: to.Ptr("Regenerate the EngagementFabric account key"), + // Operation: to.Ptr("Regenerate the EngagementFabric account key"), + // Provider: to.Ptr("Microsoft Customer Engagement Fabric"), + // Resource: to.Ptr("Accounts"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.EngagementFabric/Accounts/ListChannelTypes/action"), + // Display: &armengagementfabric.OperationDisplay{ + // Description: to.Ptr("List available EngagementFabric channel types and functions"), + // Operation: to.Ptr("List available EngagementFabric channel types and functions"), + // Provider: to.Ptr("Microsoft Customer Engagement Fabric"), + // Resource: to.Ptr("Accounts"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.EngagementFabric/Accounts/Channels/read"), + // Display: &armengagementfabric.OperationDisplay{ + // Description: to.Ptr("List or get the EngagementFabric channel"), + // Operation: to.Ptr("List or get the EngagementFabric channel"), + // Provider: to.Ptr("Microsoft Customer Engagement Fabric"), + // Resource: to.Ptr("Channels"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.EngagementFabric/Accounts/Channels/write"), + // Display: &armengagementfabric.OperationDisplay{ + // Description: to.Ptr("Create or update the EngagementFabric channel"), + // Operation: to.Ptr("Create or update the EngagementFabric channel"), + // Provider: to.Ptr("Microsoft Customer Engagement Fabric"), + // Resource: to.Ptr("Channels"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.EngagementFabric/Accounts/Channels/delete"), + // Display: &armengagementfabric.OperationDisplay{ + // Description: to.Ptr("Delete the EngagementFabric channel"), + // Operation: to.Ptr("Delete the EngagementFabric channel"), + // Provider: to.Ptr("Microsoft Customer Engagement Fabric"), + // Resource: to.Ptr("Channels"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.EngagementFabric/checkNameAvailability/action"), + // Display: &armengagementfabric.OperationDisplay{ + // Description: to.Ptr("Check name availability"), + // Operation: to.Ptr("Check name availability"), + // Provider: to.Ptr("Microsoft Customer Engagement Fabric"), + // Resource: to.Ptr("Accounts"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.EngagementFabric/operations/read"), + // Display: &armengagementfabric.OperationDisplay{ + // Description: to.Ptr("List available operations"), + // Operation: to.Ptr("List available operations"), + // Provider: to.Ptr("Microsoft Customer Engagement Fabric"), + // Resource: to.Ptr("Operations"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.EngagementFabric/skus/read"), + // Display: &armengagementfabric.OperationDisplay{ + // Description: to.Ptr("List available SKUs"), + // Operation: to.Ptr("List available SKUs"), + // Provider: to.Ptr("Microsoft Customer Engagement Fabric"), + // Resource: to.Ptr("Accounts"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_response_types.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/response_types.go similarity index 92% rename from sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_response_types.go rename to sdk/resourcemanager/engagementfabric/armengagementfabric/response_types.go index 20c3fadeb309..3987d01f740c 100644 --- a/sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_response_types.go +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/response_types.go @@ -5,6 +5,7 @@ // 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 armengagementfabric @@ -23,7 +24,7 @@ type AccountsClientGetResponse struct { Account } -// AccountsClientListByResourceGroupResponse contains the response from method AccountsClient.ListByResourceGroup. +// AccountsClientListByResourceGroupResponse contains the response from method AccountsClient.NewListByResourceGroupPager. type AccountsClientListByResourceGroupResponse struct { AccountList } @@ -33,12 +34,12 @@ type AccountsClientListChannelTypesResponse struct { ChannelTypeDescriptionList } -// AccountsClientListKeysResponse contains the response from method AccountsClient.ListKeys. +// AccountsClientListKeysResponse contains the response from method AccountsClient.NewListKeysPager. type AccountsClientListKeysResponse struct { KeyDescriptionList } -// AccountsClientListResponse contains the response from method AccountsClient.List. +// AccountsClientListResponse contains the response from method AccountsClient.NewListPager. type AccountsClientListResponse struct { AccountList } @@ -68,7 +69,7 @@ type ChannelsClientGetResponse struct { Channel } -// ChannelsClientListByAccountResponse contains the response from method ChannelsClient.ListByAccount. +// ChannelsClientListByAccountResponse contains the response from method ChannelsClient.NewListByAccountPager. type ChannelsClientListByAccountResponse struct { ChannelList } @@ -78,12 +79,12 @@ type ClientCheckNameAvailabilityResponse struct { CheckNameAvailabilityResult } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationList } -// SKUsClientListResponse contains the response from method SKUsClient.List. +// SKUsClientListResponse contains the response from method SKUsClient.NewListPager. type SKUsClientListResponse struct { SKUDescriptionList } diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_skus_client.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/skus_client.go similarity index 76% rename from sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_skus_client.go rename to sdk/resourcemanager/engagementfabric/armengagementfabric/skus_client.go index bc1da3ce7a71..363c572f2e7b 100644 --- a/sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_skus_client.go +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/skus_client.go @@ -5,6 +5,7 @@ // 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 armengagementfabric @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,39 +24,30 @@ import ( // SKUsClient contains the methods for the SKUs group. // Don't use this type directly, use NewSKUsClient() instead. type SKUsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSKUsClient creates a new instance of SKUsClient with the specified values. -// subscriptionID - Subscription ID -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Subscription ID +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSKUsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SKUsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SKUsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SKUsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - List available SKUs of EngagementFabric resource -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2018-09-01-preview -// options - SKUsClientListOptions contains the optional parameters for the SKUsClient.List method. +// - options - SKUsClientListOptions contains the optional parameters for the SKUsClient.NewListPager method. func (client *SKUsClient) NewListPager(options *SKUsClientListOptions) *runtime.Pager[SKUsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[SKUsClientListResponse]{ More: func(page SKUsClientListResponse) bool { @@ -68,7 +58,7 @@ func (client *SKUsClient) NewListPager(options *SKUsClientListOptions) *runtime. if err != nil { return SKUsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SKUsClientListResponse{}, err } @@ -87,7 +77,7 @@ func (client *SKUsClient) listCreateRequest(ctx context.Context, options *SKUsCl return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/skus_client_example_test.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/skus_client_example_test.go new file mode 100644 index 000000000000..607a539b6207 --- /dev/null +++ b/sdk/resourcemanager/engagementfabric/armengagementfabric/skus_client_example_test.go @@ -0,0 +1,109 @@ +//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 armengagementfabric_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/engagementfabric/armengagementfabric" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/163e27c0ca7570bc39e00a46f255740d9b3ba3cb/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/SKUsListExample.json +func ExampleSKUsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armengagementfabric.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSKUsClient().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.SKUDescriptionList = armengagementfabric.SKUDescriptionList{ + // Value: []*armengagementfabric.SKUDescription{ + // { + // Name: to.Ptr("B1"), + // LocationInfo: []*armengagementfabric.SKULocationInfoItem{ + // { + // Location: to.Ptr("Central US"), + // }, + // { + // Location: to.Ptr("North Europe"), + // }, + // { + // Location: to.Ptr("West Europe"), + // }}, + // Locations: []*string{ + // to.Ptr("Central US"), + // to.Ptr("North Europe"), + // to.Ptr("West Europe")}, + // ResourceType: to.Ptr("Microsoft.EngagementFabric/Accounts"), + // Restrictions: []any{ + // }, + // Tier: to.Ptr("Basic"), + // }, + // { + // Name: to.Ptr("S1"), + // LocationInfo: []*armengagementfabric.SKULocationInfoItem{ + // { + // Location: to.Ptr("Central US"), + // }, + // { + // Location: to.Ptr("North Europe"), + // }, + // { + // Location: to.Ptr("West Europe"), + // }}, + // Locations: []*string{ + // to.Ptr("Central US"), + // to.Ptr("North Europe"), + // to.Ptr("West Europe")}, + // ResourceType: to.Ptr("Microsoft.EngagementFabric/Accounts"), + // Restrictions: []any{ + // }, + // Tier: to.Ptr("Standard"), + // }, + // { + // Name: to.Ptr("P1"), + // LocationInfo: []*armengagementfabric.SKULocationInfoItem{ + // { + // Location: to.Ptr("Central US"), + // }, + // { + // Location: to.Ptr("North Europe"), + // }, + // { + // Location: to.Ptr("West Europe"), + // }}, + // Locations: []*string{ + // to.Ptr("Central US"), + // to.Ptr("North Europe"), + // to.Ptr("West Europe")}, + // ResourceType: to.Ptr("Microsoft.EngagementFabric/Accounts"), + // Restrictions: []any{ + // }, + // Tier: to.Ptr("Premium"), + // }}, + // } + } +} diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/ze_generated_example_accounts_client_test.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/ze_generated_example_accounts_client_test.go deleted file mode 100644 index 6ea99d793180..000000000000 --- a/sdk/resourcemanager/engagementfabric/armengagementfabric/ze_generated_example_accounts_client_test.go +++ /dev/null @@ -1,235 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armengagementfabric_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/engagementfabric/armengagementfabric" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/AccountsGetExample.json -func ExampleAccountsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armengagementfabric.NewAccountsClient("EDBF0095-A524-4A84-95FB-F72DA41AA6A1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "ExampleRg", - "ExampleAccount", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/AccountsCreateOrUpdateExample.json -func ExampleAccountsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armengagementfabric.NewAccountsClient("EDBF0095-A524-4A84-95FB-F72DA41AA6A1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "ExampleRg", - "ExampleAccount", - armengagementfabric.Account{ - Location: to.Ptr("WestUS"), - SKU: &armengagementfabric.SKU{ - Name: to.Ptr("B1"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/AccountsDeleteExample.json -func ExampleAccountsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armengagementfabric.NewAccountsClient("EDBF0095-A524-4A84-95FB-F72DA41AA6A1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "ExampleRg", - "ExampleAccount", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/AccountsUpdateExample.json -func ExampleAccountsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armengagementfabric.NewAccountsClient("EDBF0095-A524-4A84-95FB-F72DA41AA6A1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "ExampleRg", - "ExampleAccount", - armengagementfabric.AccountPatch{ - Tags: map[string]*string{ - "tagName": to.Ptr("tagValue"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/AccountsListExample.json -func ExampleAccountsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armengagementfabric.NewAccountsClient("EDBF0095-A524-4A84-95FB-F72DA41AA6A1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/AccountsListByResourceGroupExample.json -func ExampleAccountsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armengagementfabric.NewAccountsClient("EDBF0095-A524-4A84-95FB-F72DA41AA6A1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("ExampleRg", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/AccountsListKeysExample.json -func ExampleAccountsClient_NewListKeysPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armengagementfabric.NewAccountsClient("EDBF0095-A524-4A84-95FB-F72DA41AA6A1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListKeysPager("ExampleRg", - "ExampleAccount", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/AccountsRegenerateKeyExample.json -func ExampleAccountsClient_RegenerateKey() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armengagementfabric.NewAccountsClient("EDBF0095-A524-4A84-95FB-F72DA41AA6A1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.RegenerateKey(ctx, - "ExampleRg", - "ExampleAccount", - armengagementfabric.RegenerateKeyParameter{}, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/AccountsListChannelTypesExample.json -func ExampleAccountsClient_ListChannelTypes() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armengagementfabric.NewAccountsClient("EDBF0095-A524-4A84-95FB-F72DA41AA6A1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListChannelTypes(ctx, - "ExampleRg", - "ExampleAccount", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/ze_generated_example_channels_client_test.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/ze_generated_example_channels_client_test.go deleted file mode 100644 index e75977387a4f..000000000000 --- a/sdk/resourcemanager/engagementfabric/armengagementfabric/ze_generated_example_channels_client_test.go +++ /dev/null @@ -1,123 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armengagementfabric_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/engagementfabric/armengagementfabric" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/ChannelsGetExample.json -func ExampleChannelsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armengagementfabric.NewChannelsClient("EDBF0095-A524-4A84-95FB-F72DA41AA6A1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "ExampleRg", - "ExampleAccount", - "ExampleChannel", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/ChannelsCreateOrUpdateExample.json -func ExampleChannelsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armengagementfabric.NewChannelsClient("EDBF0095-A524-4A84-95FB-F72DA41AA6A1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "ExampleRg", - "ExampleAccount", - "ExampleChannel", - armengagementfabric.Channel{ - Properties: &armengagementfabric.ChannelProperties{ - ChannelFunctions: []*string{ - to.Ptr("MockFunction1"), - to.Ptr("MockFunction2")}, - ChannelType: to.Ptr("MockChannel"), - Credentials: map[string]*string{ - "AppId": to.Ptr("exampleApp"), - "AppKey": to.Ptr("exampleAppKey"), - }, - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/ChannelsDeleteExample.json -func ExampleChannelsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armengagementfabric.NewChannelsClient("EDBF0095-A524-4A84-95FB-F72DA41AA6A1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "ExampleRg", - "ExampleAccount", - "ExampleChannel", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/ChannelsListExample.json -func ExampleChannelsClient_NewListByAccountPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armengagementfabric.NewChannelsClient("EDBF0095-A524-4A84-95FB-F72DA41AA6A1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByAccountPager("ExampleRg", - "ExampleAccount", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/ze_generated_example_engagementfabric_client_test.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/ze_generated_example_engagementfabric_client_test.go deleted file mode 100644 index b18c49849a61..000000000000 --- a/sdk/resourcemanager/engagementfabric/armengagementfabric/ze_generated_example_engagementfabric_client_test.go +++ /dev/null @@ -1,39 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armengagementfabric_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/engagementfabric/armengagementfabric" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/CheckNameAvailabilityExample.json -func ExampleClient_CheckNameAvailability() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armengagementfabric.NewClient("EDBF0095-A524-4A84-95FB-F72DA41AA6A1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CheckNameAvailability(ctx, - "", - armengagementfabric.CheckNameAvailabilityParameter{}, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/ze_generated_example_operations_client_test.go deleted file mode 100644 index 786b05fb1886..000000000000 --- a/sdk/resourcemanager/engagementfabric/armengagementfabric/ze_generated_example_operations_client_test.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armengagementfabric_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/engagementfabric/armengagementfabric" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/OperationsListExample.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armengagementfabric.NewOperationsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/ze_generated_example_skus_client_test.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/ze_generated_example_skus_client_test.go deleted file mode 100644 index d646c4a43c76..000000000000 --- a/sdk/resourcemanager/engagementfabric/armengagementfabric/ze_generated_example_skus_client_test.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armengagementfabric_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/engagementfabric/armengagementfabric" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/engagementfabric/resource-manager/Microsoft.EngagementFabric/preview/2018-09-01/examples/SKUsListExample.json -func ExampleSKUsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armengagementfabric.NewSKUsClient("EDBF0095-A524-4A84-95FB-F72DA41AA6A1", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_models_serde.go b/sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_models_serde.go deleted file mode 100644 index bd317ea4512d..000000000000 --- a/sdk/resourcemanager/engagementfabric/armengagementfabric/zz_generated_models_serde.go +++ /dev/null @@ -1,65 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armengagementfabric - -import ( - "encoding/json" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type Account. -func (a Account) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", a.ID) - populate(objectMap, "location", a.Location) - populate(objectMap, "name", a.Name) - populate(objectMap, "sku", a.SKU) - populate(objectMap, "tags", a.Tags) - populate(objectMap, "type", a.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type AccountPatch. -func (a AccountPatch) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", a.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ChannelProperties. -func (c ChannelProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "channelFunctions", c.ChannelFunctions) - populate(objectMap, "channelType", c.ChannelType) - populate(objectMap, "credentials", c.Credentials) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type TrackedResource. -func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) - populate(objectMap, "name", t.Name) - populate(objectMap, "sku", t.SKU) - populate(objectMap, "tags", t.Tags) - populate(objectMap, "type", t.Type) - return json.Marshal(objectMap) -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/CHANGELOG.md b/sdk/resourcemanager/extendedlocation/armextendedlocation/CHANGELOG.md index 572bb1f58b62..77a4b81cb8ca 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/CHANGELOG.md +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0-beta.2 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.1.0-beta.1 (2022-06-28) ### Features Added diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/README.md b/sdk/resourcemanager/extendedlocation/armextendedlocation/README.md index 628221509848..149298861830 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/README.md +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Extended Location modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Extended Location module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armextendedlocation.NewCustomLocationsClient(, cred, nil) +clientFactory, err := armextendedlocation.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armextendedlocation.NewCustomLocationsClient(, cred, &options) +clientFactory, err := armextendedlocation.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewCustomLocationsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/autorest.md b/sdk/resourcemanager/extendedlocation/armextendedlocation/autorest.md index f3015bb99d8a..8c5df8dcebdd 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/autorest.md +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/b8fc2b4ff626aab886f929e49926c6e836548e01/specification/extendedlocation/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/b8fc2b4ff626aab886f929e49926c6e836548e01/specification/extendedlocation/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.1.0-beta.1 +module-version: 1.1.0-beta.2 tag: package-2021-08-31-preview ``` \ No newline at end of file diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/client_factory.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/client_factory.go new file mode 100644 index 000000000000..f8c6e0866bfe --- /dev/null +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/client_factory.go @@ -0,0 +1,49 @@ +//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 armextendedlocation + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewCustomLocationsClient() *CustomLocationsClient { + subClient, _ := NewCustomLocationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewResourceSyncRulesClient() *ResourceSyncRulesClient { + subClient, _ := NewResourceSyncRulesClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/constants.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/constants.go index 3861fe4577db..145d63d9ea1e 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/constants.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/constants.go @@ -11,7 +11,7 @@ package armextendedlocation const ( moduleName = "armextendedlocation" - moduleVersion = "v1.1.0-beta.1" + moduleVersion = "v1.1.0-beta.2" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/customlocations_client.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/customlocations_client.go index 3f6b5b9bf1b6..e355dc3fb6af 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/customlocations_client.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/customlocations_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,66 +24,59 @@ import ( // CustomLocationsClient contains the methods for the CustomLocations group. // Don't use this type directly, use NewCustomLocationsClient() instead. type CustomLocationsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewCustomLocationsClient creates a new instance of CustomLocationsClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewCustomLocationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CustomLocationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".CustomLocationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &CustomLocationsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates a Custom Location in the specified Subscription and Resource Group // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-31-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// resourceName - Custom Locations name. -// parameters - Parameters supplied to create or update a Custom Location. -// options - CustomLocationsClientBeginCreateOrUpdateOptions contains the optional parameters for the CustomLocationsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - Custom Locations name. +// - parameters - Parameters supplied to create or update a Custom Location. +// - options - CustomLocationsClientBeginCreateOrUpdateOptions contains the optional parameters for the CustomLocationsClient.BeginCreateOrUpdate +// method. func (client *CustomLocationsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, parameters CustomLocation, options *CustomLocationsClientBeginCreateOrUpdateOptions) (*runtime.Poller[CustomLocationsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, resourceName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CustomLocationsClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CustomLocationsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CustomLocationsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CustomLocationsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a Custom Location in the specified Subscription and Resource Group // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-31-preview func (client *CustomLocationsClient) createOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, parameters CustomLocation, options *CustomLocationsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, resourceName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -110,7 +101,7 @@ func (client *CustomLocationsClient) createOrUpdateCreateRequest(ctx context.Con return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -123,34 +114,36 @@ func (client *CustomLocationsClient) createOrUpdateCreateRequest(ctx context.Con // BeginDelete - Deletes the Custom Location with the specified Resource Name, Resource Group, and Subscription Id. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-31-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// resourceName - Custom Locations name. -// options - CustomLocationsClientBeginDeleteOptions contains the optional parameters for the CustomLocationsClient.BeginDelete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - Custom Locations name. +// - options - CustomLocationsClientBeginDeleteOptions contains the optional parameters for the CustomLocationsClient.BeginDelete +// method. func (client *CustomLocationsClient) BeginDelete(ctx context.Context, resourceGroupName string, resourceName string, options *CustomLocationsClientBeginDeleteOptions) (*runtime.Poller[CustomLocationsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, resourceName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CustomLocationsClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CustomLocationsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[CustomLocationsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[CustomLocationsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes the Custom Location with the specified Resource Name, Resource Group, and Subscription Id. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-31-preview func (client *CustomLocationsClient) deleteOperation(ctx context.Context, resourceGroupName string, resourceName string, options *CustomLocationsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -175,7 +168,7 @@ func (client *CustomLocationsClient) deleteCreateRequest(ctx context.Context, re return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -189,18 +182,19 @@ func (client *CustomLocationsClient) deleteCreateRequest(ctx context.Context, re // FindTargetResourceGroup - Returns the target resource group associated with the resource sync rules of the Custom Location // that match the rules passed in with the Find Target Resource Group Request. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-31-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// resourceName - Custom Locations name. -// parameters - Parameters of the find target resource group request. -// options - CustomLocationsClientFindTargetResourceGroupOptions contains the optional parameters for the CustomLocationsClient.FindTargetResourceGroup -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - Custom Locations name. +// - parameters - Parameters of the find target resource group request. +// - options - CustomLocationsClientFindTargetResourceGroupOptions contains the optional parameters for the CustomLocationsClient.FindTargetResourceGroup +// method. func (client *CustomLocationsClient) FindTargetResourceGroup(ctx context.Context, resourceGroupName string, resourceName string, parameters CustomLocationFindTargetResourceGroupProperties, options *CustomLocationsClientFindTargetResourceGroupOptions) (CustomLocationsClientFindTargetResourceGroupResponse, error) { req, err := client.findTargetResourceGroupCreateRequest(ctx, resourceGroupName, resourceName, parameters, options) if err != nil { return CustomLocationsClientFindTargetResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomLocationsClientFindTargetResourceGroupResponse{}, err } @@ -225,7 +219,7 @@ func (client *CustomLocationsClient) findTargetResourceGroupCreateRequest(ctx co return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -247,16 +241,17 @@ func (client *CustomLocationsClient) findTargetResourceGroupHandleResponse(resp // Get - Gets the details of the customLocation with a specified resource group and name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-31-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// resourceName - Custom Locations name. -// options - CustomLocationsClientGetOptions contains the optional parameters for the CustomLocationsClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - Custom Locations name. +// - options - CustomLocationsClientGetOptions contains the optional parameters for the CustomLocationsClient.Get method. func (client *CustomLocationsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, options *CustomLocationsClientGetOptions) (CustomLocationsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, resourceName, options) if err != nil { return CustomLocationsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomLocationsClientGetResponse{}, err } @@ -281,7 +276,7 @@ func (client *CustomLocationsClient) getCreateRequest(ctx context.Context, resou 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.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -303,11 +298,11 @@ func (client *CustomLocationsClient) getHandleResponse(resp *http.Response) (Cus // NewListByResourceGroupPager - Gets a list of Custom Locations in the specified subscription and resource group. The operation // returns properties of each Custom Location. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-31-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// options - CustomLocationsClientListByResourceGroupOptions contains the optional parameters for the CustomLocationsClient.ListByResourceGroup -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - CustomLocationsClientListByResourceGroupOptions contains the optional parameters for the CustomLocationsClient.NewListByResourceGroupPager +// method. func (client *CustomLocationsClient) NewListByResourceGroupPager(resourceGroupName string, options *CustomLocationsClientListByResourceGroupOptions) *runtime.Pager[CustomLocationsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[CustomLocationsClientListByResourceGroupResponse]{ More: func(page CustomLocationsClientListByResourceGroupResponse) bool { @@ -324,7 +319,7 @@ func (client *CustomLocationsClient) NewListByResourceGroupPager(resourceGroupNa if err != nil { return CustomLocationsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomLocationsClientListByResourceGroupResponse{}, err } @@ -347,7 +342,7 @@ func (client *CustomLocationsClient) listByResourceGroupCreateRequest(ctx contex return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -369,10 +364,10 @@ func (client *CustomLocationsClient) listByResourceGroupHandleResponse(resp *htt // NewListBySubscriptionPager - Gets a list of Custom Locations in the specified subscription. The operation returns properties // of each Custom Location -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-31-preview -// options - CustomLocationsClientListBySubscriptionOptions contains the optional parameters for the CustomLocationsClient.ListBySubscription -// method. +// - options - CustomLocationsClientListBySubscriptionOptions contains the optional parameters for the CustomLocationsClient.NewListBySubscriptionPager +// method. func (client *CustomLocationsClient) NewListBySubscriptionPager(options *CustomLocationsClientListBySubscriptionOptions) *runtime.Pager[CustomLocationsClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[CustomLocationsClientListBySubscriptionResponse]{ More: func(page CustomLocationsClientListBySubscriptionResponse) bool { @@ -389,7 +384,7 @@ func (client *CustomLocationsClient) NewListBySubscriptionPager(options *CustomL if err != nil { return CustomLocationsClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomLocationsClientListBySubscriptionResponse{}, err } @@ -408,7 +403,7 @@ func (client *CustomLocationsClient) listBySubscriptionCreateRequest(ctx context return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -429,12 +424,12 @@ func (client *CustomLocationsClient) listBySubscriptionHandleResponse(resp *http } // NewListEnabledResourceTypesPager - Gets the list of the Enabled Resource Types. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-31-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// resourceName - Custom Locations name. -// options - CustomLocationsClientListEnabledResourceTypesOptions contains the optional parameters for the CustomLocationsClient.ListEnabledResourceTypes -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - Custom Locations name. +// - options - CustomLocationsClientListEnabledResourceTypesOptions contains the optional parameters for the CustomLocationsClient.NewListEnabledResourceTypesPager +// method. func (client *CustomLocationsClient) NewListEnabledResourceTypesPager(resourceGroupName string, resourceName string, options *CustomLocationsClientListEnabledResourceTypesOptions) *runtime.Pager[CustomLocationsClientListEnabledResourceTypesResponse] { return runtime.NewPager(runtime.PagingHandler[CustomLocationsClientListEnabledResourceTypesResponse]{ More: func(page CustomLocationsClientListEnabledResourceTypesResponse) bool { @@ -451,7 +446,7 @@ func (client *CustomLocationsClient) NewListEnabledResourceTypesPager(resourceGr if err != nil { return CustomLocationsClientListEnabledResourceTypesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomLocationsClientListEnabledResourceTypesResponse{}, err } @@ -478,7 +473,7 @@ func (client *CustomLocationsClient) listEnabledResourceTypesCreateRequest(ctx c 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.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -499,10 +494,10 @@ func (client *CustomLocationsClient) listEnabledResourceTypesHandleResponse(resp } // NewListOperationsPager - Lists all available Custom Locations operations. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-31-preview -// options - CustomLocationsClientListOperationsOptions contains the optional parameters for the CustomLocationsClient.ListOperations -// method. +// - options - CustomLocationsClientListOperationsOptions contains the optional parameters for the CustomLocationsClient.NewListOperationsPager +// method. func (client *CustomLocationsClient) NewListOperationsPager(options *CustomLocationsClientListOperationsOptions) *runtime.Pager[CustomLocationsClientListOperationsResponse] { return runtime.NewPager(runtime.PagingHandler[CustomLocationsClientListOperationsResponse]{ More: func(page CustomLocationsClientListOperationsResponse) bool { @@ -519,7 +514,7 @@ func (client *CustomLocationsClient) NewListOperationsPager(options *CustomLocat if err != nil { return CustomLocationsClientListOperationsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomLocationsClientListOperationsResponse{}, err } @@ -534,7 +529,7 @@ func (client *CustomLocationsClient) NewListOperationsPager(options *CustomLocat // listOperationsCreateRequest creates the ListOperations request. func (client *CustomLocationsClient) listOperationsCreateRequest(ctx context.Context, options *CustomLocationsClientListOperationsOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.ExtendedLocation/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -556,17 +551,18 @@ func (client *CustomLocationsClient) listOperationsHandleResponse(resp *http.Res // Update - Updates a Custom Location with the specified Resource Name in the specified Resource Group and Subscription. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-31-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// resourceName - Custom Locations name. -// parameters - The updatable fields of an existing Custom Location. -// options - CustomLocationsClientUpdateOptions contains the optional parameters for the CustomLocationsClient.Update method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - Custom Locations name. +// - parameters - The updatable fields of an existing Custom Location. +// - options - CustomLocationsClientUpdateOptions contains the optional parameters for the CustomLocationsClient.Update method. func (client *CustomLocationsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, parameters PatchableCustomLocations, options *CustomLocationsClientUpdateOptions) (CustomLocationsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, resourceName, parameters, options) if err != nil { return CustomLocationsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return CustomLocationsClientUpdateResponse{}, err } @@ -591,7 +587,7 @@ func (client *CustomLocationsClient) updateCreateRequest(ctx context.Context, re return nil, errors.New("parameter resourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/customlocations_client_example_test.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/customlocations_client_example_test.go index 69e0efc52f23..4492bbdc10f7 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/customlocations_client_example_test.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/customlocations_client_example_test.go @@ -5,6 +5,7 @@ // 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 armextendedlocation_test @@ -17,133 +18,442 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/extendedlocation/armextendedlocation" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsListOperations.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8fc2b4ff626aab886f929e49926c6e836548e01/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsListOperations.json func ExampleCustomLocationsClient_NewListOperationsPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armextendedlocation.NewCustomLocationsClient("", cred, nil) + clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListOperationsPager(nil) + pager := clientFactory.NewCustomLocationsClient().NewListOperationsPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.CustomLocationOperationsList = armextendedlocation.CustomLocationOperationsList{ + // Value: []*armextendedlocation.CustomLocationOperation{ + // { + // Name: to.Ptr("Microsoft.ExtendedLocation/operations/read"), + // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ + // Description: to.Ptr("Gets list of Available Operations for Custom Locations"), + // Operation: to.Ptr("List Available Operations for Custom Locations"), + // Provider: to.Ptr("Microsoft.ExtendedLocation"), + // Resource: to.Ptr("Operations"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.ExtendedLocation/register/action"), + // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ + // Description: to.Ptr("Registers the subscription for Custom Location resource provider and enables the creation of Custom Location."), + // Operation: to.Ptr("Registers the Custom Location Resource Provider"), + // Provider: to.Ptr("Microsoft.ExtendedLocation"), + // Resource: to.Ptr("Custom Locations Resource Provider"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.ExtendedLocation/unregister/action"), + // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ + // Description: to.Ptr("UnRegisters the subscription for Custom Location resource provider and disables the creation of Custom Location."), + // Operation: to.Ptr("UnRegisters the Custom Location Resource Provider"), + // Provider: to.Ptr("Microsoft.ExtendedLocation"), + // Resource: to.Ptr("Custom Locations Resource Provider"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.ExtendedLocation/customLocations/read"), + // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ + // Description: to.Ptr("Gets an Custom Location resource"), + // Operation: to.Ptr("Get Custom Location"), + // Provider: to.Ptr("Microsoft.ExtendedLocation"), + // Resource: to.Ptr("Custom Locations"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.ExtendedLocation/customLocations/write"), + // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ + // Description: to.Ptr("Creates or Updates Custom Location resource"), + // Operation: to.Ptr("Create or Update Custom Location"), + // Provider: to.Ptr("Microsoft.ExtendedLocation"), + // Resource: to.Ptr("Custom Locations"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.ExtendedLocation/customLocations/deploy/action"), + // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ + // Description: to.Ptr("Deploy permissions to a Custom Location resource"), + // Operation: to.Ptr("Deploy permissions to Custom Location"), + // Provider: to.Ptr("Microsoft.ExtendedLocation"), + // Resource: to.Ptr("Custom Locations"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.ExtendedLocation/customLocations/delete"), + // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ + // Description: to.Ptr("Deletes Custom Location resource"), + // Operation: to.Ptr("Delete Custom Location"), + // Provider: to.Ptr("Microsoft.ExtendedLocation"), + // Resource: to.Ptr("Custom Locations"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.ExtendedLocation/customLocations/enabledresourcetypes/read"), + // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ + // Description: to.Ptr("Gets EnabledResourceTypes for a Custom Location resource"), + // Operation: to.Ptr("Get EnabledResourceTypes for Custom Location"), + // Provider: to.Ptr("Microsoft.ExtendedLocation"), + // Resource: to.Ptr("Custom Locations"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.ExtendedLocation/locations/operationsstatus/read"), + // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ + // Description: to.Ptr("Get result of Custom Location operation"), + // Operation: to.Ptr("Get status of Custom Location operation"), + // Provider: to.Ptr("Microsoft.ExtendedLocation"), + // Resource: to.Ptr("Custom Location Operation Status"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.ExtendedLocation/locations/operationresults/read"), + // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ + // Description: to.Ptr("Get result of Custom Location operation"), + // Operation: to.Ptr("Get the status of Custom Location operation"), + // Provider: to.Ptr("Microsoft.ExtendedLocation"), + // Resource: to.Ptr("Custom Location Operation Result"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.ExtendedLocation/customLocations/resourceSyncRules/read"), + // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ + // Description: to.Ptr("Gets a Resource Sync Rule resource"), + // Operation: to.Ptr("Get Resource Sync Rule"), + // Provider: to.Ptr("Microsoft.ExtendedLocation"), + // Resource: to.Ptr("Resource Sync Rules"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.ExtendedLocation/customLocations/resourceSyncRules/write"), + // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ + // Description: to.Ptr("Creates or Updates a Resource Sync Rule resource"), + // Operation: to.Ptr("Create or Update Resource Sync Rule"), + // Provider: to.Ptr("Microsoft.ExtendedLocation"), + // Resource: to.Ptr("Resource Sync Rules"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.ExtendedLocation/customLocations/resourceSyncRules/delete"), + // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ + // Description: to.Ptr("Deletes Resource Sync Rule resource"), + // Operation: to.Ptr("Delete Resource Sync Rule"), + // Provider: to.Ptr("Microsoft.ExtendedLocation"), + // Resource: to.Ptr("Resource Sync Rules"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr("user,system"), + // }, + // { + // Name: to.Ptr("Microsoft.ExtendedLocation/customLocations/findTargetResourceGroup/action"), + // Display: &armextendedlocation.CustomLocationOperationValueDisplay{ + // Description: to.Ptr("Evaluate Labels Against Resource Sync Rules to Get Target Resource Group"), + // Operation: to.Ptr("Find Target Resource Group Action"), + // Provider: to.Ptr("Microsoft.ExtendedLocation"), + // Resource: to.Ptr("Resource Sync Rules"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr("user,system"), + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsListBySubscription.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8fc2b4ff626aab886f929e49926c6e836548e01/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsListBySubscription.json func ExampleCustomLocationsClient_NewListBySubscriptionPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armextendedlocation.NewCustomLocationsClient("11111111-2222-3333-4444-555555555555", cred, nil) + clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListBySubscriptionPager(nil) + pager := clientFactory.NewCustomLocationsClient().NewListBySubscriptionPager(nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.CustomLocationListResult = armextendedlocation.CustomLocationListResult{ + // Value: []*armextendedlocation.CustomLocation{ + // { + // Name: to.Ptr("customLocation01"), + // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations"), + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/"), + // Location: to.Ptr("West US"), + // Identity: &armextendedlocation.Identity{ + // Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("11111111-1111-1111-1111-111111111111"), + // TenantID: to.Ptr("111111-1111-1111-1111-111111111111"), + // }, + // Properties: &armextendedlocation.CustomLocationProperties{ + // Authentication: &armextendedlocation.CustomLocationPropertiesAuthentication{ + // Type: to.Ptr("KubeConfig"), + // }, + // ClusterExtensionIDs: []*string{ + // to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension")}, + // DisplayName: to.Ptr("customLocationLocation01"), + // HostResourceID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01"), + // Namespace: to.Ptr("namespace01"), + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // SystemData: &armextendedlocation.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // }, + // }, + // { + // Name: to.Ptr("customLocation02"), + // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations"), + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/"), + // Location: to.Ptr("West US"), + // Identity: &armextendedlocation.Identity{ + // Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("11111111-1111-1111-1111-111111111111"), + // TenantID: to.Ptr("111111-1111-1111-1111-111111111111"), + // }, + // Properties: &armextendedlocation.CustomLocationProperties{ + // Authentication: &armextendedlocation.CustomLocationPropertiesAuthentication{ + // Type: to.Ptr("KubeConfig"), + // }, + // ClusterExtensionIDs: []*string{ + // to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster02/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension")}, + // DisplayName: to.Ptr("customLocationLocation02"), + // HostResourceID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster02"), + // Namespace: to.Ptr("namespace02"), + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // SystemData: &armextendedlocation.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsListByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8fc2b4ff626aab886f929e49926c6e836548e01/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsListByResourceGroup.json func ExampleCustomLocationsClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armextendedlocation.NewCustomLocationsClient("11111111-2222-3333-4444-555555555555", cred, nil) + clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("testresourcegroup", - nil) + pager := clientFactory.NewCustomLocationsClient().NewListByResourceGroupPager("testresourcegroup", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.CustomLocationListResult = armextendedlocation.CustomLocationListResult{ + // Value: []*armextendedlocation.CustomLocation{ + // { + // Name: to.Ptr("customLocation01"), + // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations"), + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/"), + // Location: to.Ptr("West US"), + // Identity: &armextendedlocation.Identity{ + // Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("11111111-1111-1111-1111-111111111111"), + // TenantID: to.Ptr("111111-1111-1111-1111-111111111111"), + // }, + // Properties: &armextendedlocation.CustomLocationProperties{ + // Authentication: &armextendedlocation.CustomLocationPropertiesAuthentication{ + // Type: to.Ptr("KubeConfig"), + // }, + // ClusterExtensionIDs: []*string{ + // to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension")}, + // DisplayName: to.Ptr("customLocationLocation01"), + // HostResourceID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01"), + // Namespace: to.Ptr("namespace01"), + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // SystemData: &armextendedlocation.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // }, + // }, + // { + // Name: to.Ptr("customLocation02"), + // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations"), + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/"), + // Location: to.Ptr("West US"), + // Identity: &armextendedlocation.Identity{ + // Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("11111111-1111-1111-1111-111111111111"), + // TenantID: to.Ptr("111111-1111-1111-1111-111111111111"), + // }, + // Properties: &armextendedlocation.CustomLocationProperties{ + // Authentication: &armextendedlocation.CustomLocationPropertiesAuthentication{ + // Type: to.Ptr("KubeConfig"), + // }, + // ClusterExtensionIDs: []*string{ + // to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster02/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension")}, + // DisplayName: to.Ptr("customLocationLocation02"), + // HostResourceID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster02"), + // Namespace: to.Ptr("namespace02"), + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // SystemData: &armextendedlocation.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8fc2b4ff626aab886f929e49926c6e836548e01/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsGet.json func ExampleCustomLocationsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armextendedlocation.NewCustomLocationsClient("11111111-2222-3333-4444-555555555555", cred, nil) + clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, - "testresourcegroup", - "customLocation01", - nil) + res, err := clientFactory.NewCustomLocationsClient().Get(ctx, "testresourcegroup", "customLocation01", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.CustomLocation = armextendedlocation.CustomLocation{ + // Name: to.Ptr("customLocation01"), + // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations"), + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/providers/Microsoft.ExtendedLocation/customLocations/customLocation01"), + // Location: to.Ptr("West US"), + // Identity: &armextendedlocation.Identity{ + // Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("11111111-1111-1111-1111-111111111111"), + // TenantID: to.Ptr("111111-1111-1111-1111-111111111111"), + // }, + // Properties: &armextendedlocation.CustomLocationProperties{ + // Authentication: &armextendedlocation.CustomLocationPropertiesAuthentication{ + // Type: to.Ptr("KubeConfig"), + // }, + // ClusterExtensionIDs: []*string{ + // to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension")}, + // DisplayName: to.Ptr("customLocationLocation01"), + // HostResourceID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01"), + // Namespace: to.Ptr("namespace01"), + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // SystemData: &armextendedlocation.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsCreate_Update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8fc2b4ff626aab886f929e49926c6e836548e01/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsCreate_Update.json func ExampleCustomLocationsClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armextendedlocation.NewCustomLocationsClient("11111111-2222-3333-4444-555555555555", cred, nil) + clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, - "testresourcegroup", - "customLocation01", - armextendedlocation.CustomLocation{ - Location: to.Ptr("West US"), - Identity: &armextendedlocation.Identity{ - Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), - }, - Properties: &armextendedlocation.CustomLocationProperties{ - Authentication: &armextendedlocation.CustomLocationPropertiesAuthentication{ - Type: to.Ptr("KubeConfig"), - Value: to.Ptr(""), - }, - ClusterExtensionIDs: []*string{ - to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedCluster/someCluster/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension")}, - DisplayName: to.Ptr("customLocationLocation01"), - HostResourceID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01"), - Namespace: to.Ptr("namespace01"), + poller, err := clientFactory.NewCustomLocationsClient().BeginCreateOrUpdate(ctx, "testresourcegroup", "customLocation01", armextendedlocation.CustomLocation{ + Location: to.Ptr("West US"), + Identity: &armextendedlocation.Identity{ + Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), + }, + Properties: &armextendedlocation.CustomLocationProperties{ + Authentication: &armextendedlocation.CustomLocationPropertiesAuthentication{ + Type: to.Ptr("KubeConfig"), + Value: to.Ptr(""), }, + ClusterExtensionIDs: []*string{ + to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedCluster/someCluster/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension")}, + DisplayName: to.Ptr("customLocationLocation01"), + HostResourceID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01"), + Namespace: to.Ptr("namespace01"), }, - nil) + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -151,25 +461,53 @@ func ExampleCustomLocationsClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // 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.CustomLocation = armextendedlocation.CustomLocation{ + // Name: to.Ptr("customLocation01"), + // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations"), + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/providers/Microsoft.ExtendedLocation/customLocations/customLocation01"), + // Location: to.Ptr("West US"), + // Identity: &armextendedlocation.Identity{ + // Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("11111111-1111-1111-1111-111111111111"), + // TenantID: to.Ptr("111111-1111-1111-1111-111111111111"), + // }, + // Properties: &armextendedlocation.CustomLocationProperties{ + // Authentication: &armextendedlocation.CustomLocationPropertiesAuthentication{ + // Type: to.Ptr("KubeConfig"), + // }, + // ClusterExtensionIDs: []*string{ + // to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension")}, + // DisplayName: to.Ptr("customLocationLocation01"), + // HostResourceID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01"), + // Namespace: to.Ptr("namespace01"), + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // SystemData: &armextendedlocation.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8fc2b4ff626aab886f929e49926c6e836548e01/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsDelete.json func ExampleCustomLocationsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armextendedlocation.NewCustomLocationsClient("11111111-2222-3333-4444-555555555555", cred, nil) + clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, - "testresourcegroup", - "customLocation01", - nil) + poller, err := clientFactory.NewCustomLocationsClient().BeginDelete(ctx, "testresourcegroup", "customLocation01", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -179,92 +517,183 @@ func ExampleCustomLocationsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsPatch.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8fc2b4ff626aab886f929e49926c6e836548e01/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsPatch.json func ExampleCustomLocationsClient_Update() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armextendedlocation.NewCustomLocationsClient("11111111-2222-3333-4444-555555555555", cred, nil) + clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Update(ctx, - "testresourcegroup", - "customLocation01", - armextendedlocation.PatchableCustomLocations{ - Identity: &armextendedlocation.Identity{ - Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), - }, - Properties: &armextendedlocation.CustomLocationProperties{ - ClusterExtensionIDs: []*string{ - to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension"), - to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/barExtension")}, - }, - Tags: map[string]*string{ - "archv3": to.Ptr(""), - "tier": to.Ptr("testing"), - }, + res, err := clientFactory.NewCustomLocationsClient().Update(ctx, "testresourcegroup", "customLocation01", armextendedlocation.PatchableCustomLocations{ + Identity: &armextendedlocation.Identity{ + Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), + }, + Properties: &armextendedlocation.CustomLocationProperties{ + ClusterExtensionIDs: []*string{ + to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension"), + to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/barExtension")}, }, - nil) + Tags: map[string]*string{ + "archv3": to.Ptr(""), + "tier": to.Ptr("testing"), + }, + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.CustomLocation = armextendedlocation.CustomLocation{ + // Name: to.Ptr("customLocation01"), + // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations"), + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/providers/Microsoft.ExtendedLocation/customLocations/customLocation01"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "archv3": to.Ptr(""), + // "tier": to.Ptr("testing"), + // }, + // Identity: &armextendedlocation.Identity{ + // Type: to.Ptr(armextendedlocation.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("11111111-1111-1111-1111-111111111111"), + // TenantID: to.Ptr("111111-1111-1111-1111-111111111111"), + // }, + // Properties: &armextendedlocation.CustomLocationProperties{ + // Authentication: &armextendedlocation.CustomLocationPropertiesAuthentication{ + // Type: to.Ptr("KubeConfig"), + // }, + // ClusterExtensionIDs: []*string{ + // to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension"), + // to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/barExtension")}, + // DisplayName: to.Ptr("customLocationLocation01"), + // HostResourceID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01"), + // Namespace: to.Ptr("namespace01"), + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // SystemData: &armextendedlocation.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsListEnabledResourceTypes.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8fc2b4ff626aab886f929e49926c6e836548e01/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsListEnabledResourceTypes.json func ExampleCustomLocationsClient_NewListEnabledResourceTypesPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armextendedlocation.NewCustomLocationsClient("11111111-2222-3333-4444-555555555555", cred, nil) + clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListEnabledResourceTypesPager("testresourcegroup", - "customLocation01", - nil) + pager := clientFactory.NewCustomLocationsClient().NewListEnabledResourceTypesPager("testresourcegroup", "customLocation01", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.EnabledResourceTypesListResult = armextendedlocation.EnabledResourceTypesListResult{ + // Value: []*armextendedlocation.EnabledResourceType{ + // { + // Name: to.Ptr("d016ecf26dae90594806aca3c1a6326c668357037f68103587edf2e657824737"), + // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations/enabledResourceTypes"), + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/providers/Microsoft.ExtendedLocation/customLocations/customLocation01/enabledResourceTypes/d016ecf26dae90594806aca3c1a6326c668357037f68103587edf2e657824737"), + // Properties: &armextendedlocation.EnabledResourceTypeProperties{ + // ClusterExtensionID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/providers/Microsoft.Kubernetes/connectedClusters/cldfe2econnectedcluster/providers/Microsoft.KubernetesConfiguration/extensions/vmware-extension"), + // ExtensionType: to.Ptr("arc-vmware"), + // TypesMetadata: []*armextendedlocation.EnabledResourceTypePropertiesTypesMetadataItem{ + // { + // APIVersion: to.Ptr("2020-01-01-preview"), + // ResourceProviderNamespace: to.Ptr("Microsoft.VMware"), + // ResourceType: to.Ptr("virtualMachines"), + // }, + // { + // APIVersion: to.Ptr("2020-01-22-preview"), + // ResourceProviderNamespace: to.Ptr("Microsoft.VMware"), + // ResourceType: to.Ptr("virtualmachines"), + // }}, + // }, + // SystemData: &armextendedlocation.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // }, + // }, + // { + // Name: to.Ptr("266e9d31e5be6be1e919574e25780d5783586d502f0b2cc422e0a228a34e00a6"), + // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations/enabledResourceTypes"), + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/providers/Microsoft.ExtendedLocation/customLocations/customLocation01/enabledResourceTypes/266e9d31e5be6be1e919574e25780d5783586d502f0b2cc422e0a228a34e00a6"), + // Properties: &armextendedlocation.EnabledResourceTypeProperties{ + // ClusterExtensionID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/providers/Microsoft.Kubernetes/connectedClusters/cldfe2econnectedcluster/providers/Microsoft.KubernetesConfiguration/extensions/cassandra-extension"), + // ExtensionType: to.Ptr("cassandradatacentersoperator"), + // TypesMetadata: []*armextendedlocation.EnabledResourceTypePropertiesTypesMetadataItem{ + // { + // APIVersion: to.Ptr("2020-01-01-preview"), + // ResourceProviderNamespace: to.Ptr("Microsoft.Cassandra"), + // ResourceType: to.Ptr("cassandraDataCenters"), + // }, + // { + // APIVersion: to.Ptr("2020-01-22-preview"), + // ResourceProviderNamespace: to.Ptr("Microsoft.Cassandra"), + // ResourceType: to.Ptr("cassandrabackups"), + // }}, + // }, + // SystemData: &armextendedlocation.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsFindTargetResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8fc2b4ff626aab886f929e49926c6e836548e01/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/CustomLocationsFindTargetResourceGroup.json func ExampleCustomLocationsClient_FindTargetResourceGroup() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armextendedlocation.NewCustomLocationsClient("11111111-2222-3333-4444-555555555555", cred, nil) + clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.FindTargetResourceGroup(ctx, - "testresourcegroup", - "customLocation01", - armextendedlocation.CustomLocationFindTargetResourceGroupProperties{ - Labels: map[string]*string{ - "key1": to.Ptr("value1"), - "key2": to.Ptr("value2"), - }, + res, err := clientFactory.NewCustomLocationsClient().FindTargetResourceGroup(ctx, "testresourcegroup", "customLocation01", armextendedlocation.CustomLocationFindTargetResourceGroupProperties{ + Labels: map[string]*string{ + "key1": to.Ptr("value1"), + "key2": to.Ptr("value2"), }, - nil) + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.CustomLocationFindTargetResourceGroupResult = armextendedlocation.CustomLocationFindTargetResourceGroupResult{ + // MatchedResourceSyncRule: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/customLocations/tesla-customlocation-1-chumpishness/resourceSyncRules/test-resource-sync-rule"), + // TargetResourceGroup: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/target-resource-group/"), + // } } diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/go.mod b/sdk/resourcemanager/extendedlocation/armextendedlocation/go.mod index 79221a28d9c0..a17a976e7464 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/go.mod +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/extendedlocation/ar go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/go.sum b/sdk/resourcemanager/extendedlocation/armextendedlocation/go.sum index 8828b17b1853..8ba445a8c4da 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/go.sum +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 h1:BWe8a+f/t+7KY7zH2mqygeUD0t8hNFXe08p1Pb3/jKE= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/models.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/models.go index 619019dc0611..cd1ec0a59b4b 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/models.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/models.go @@ -163,25 +163,25 @@ type CustomLocationsClientGetOptions struct { // placeholder for future optional parameters } -// CustomLocationsClientListByResourceGroupOptions contains the optional parameters for the CustomLocationsClient.ListByResourceGroup +// CustomLocationsClientListByResourceGroupOptions contains the optional parameters for the CustomLocationsClient.NewListByResourceGroupPager // method. type CustomLocationsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// CustomLocationsClientListBySubscriptionOptions contains the optional parameters for the CustomLocationsClient.ListBySubscription +// CustomLocationsClientListBySubscriptionOptions contains the optional parameters for the CustomLocationsClient.NewListBySubscriptionPager // method. type CustomLocationsClientListBySubscriptionOptions struct { // placeholder for future optional parameters } -// CustomLocationsClientListEnabledResourceTypesOptions contains the optional parameters for the CustomLocationsClient.ListEnabledResourceTypes +// CustomLocationsClientListEnabledResourceTypesOptions contains the optional parameters for the CustomLocationsClient.NewListEnabledResourceTypesPager // method. type CustomLocationsClientListEnabledResourceTypesOptions struct { // placeholder for future optional parameters } -// CustomLocationsClientListOperationsOptions contains the optional parameters for the CustomLocationsClient.ListOperations +// CustomLocationsClientListOperationsOptions contains the optional parameters for the CustomLocationsClient.NewListOperationsPager // method. type CustomLocationsClientListOperationsOptions struct { // placeholder for future optional parameters @@ -246,7 +246,7 @@ type EnabledResourceTypesListResult struct { // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. - Info interface{} `json:"info,omitempty" azure:"ro"` + Info any `json:"info,omitempty" azure:"ro"` // READ-ONLY; The additional info type. Type *string `json:"type,omitempty" azure:"ro"` @@ -451,7 +451,7 @@ type ResourceSyncRulesClientGetOptions struct { // placeholder for future optional parameters } -// ResourceSyncRulesClientListByCustomLocationIDOptions contains the optional parameters for the ResourceSyncRulesClient.ListByCustomLocationID +// ResourceSyncRulesClientListByCustomLocationIDOptions contains the optional parameters for the ResourceSyncRulesClient.NewListByCustomLocationIDPager // method. type ResourceSyncRulesClientListByCustomLocationIDOptions struct { // placeholder for future optional parameters diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/models_serde.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/models_serde.go index d5e940cda8fc..0726258ed8d6 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/models_serde.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/models_serde.go @@ -18,7 +18,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type CustomLocation. func (c CustomLocation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", c.ID) populate(objectMap, "identity", c.Identity) populate(objectMap, "location", c.Location) @@ -73,7 +73,7 @@ func (c *CustomLocation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CustomLocationFindTargetResourceGroupProperties. func (c CustomLocationFindTargetResourceGroupProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "labels", c.Labels) return json.Marshal(objectMap) } @@ -100,7 +100,7 @@ func (c *CustomLocationFindTargetResourceGroupProperties) UnmarshalJSON(data []b // MarshalJSON implements the json.Marshaller interface for type CustomLocationFindTargetResourceGroupResult. func (c CustomLocationFindTargetResourceGroupResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "matchedResourceSyncRule", c.MatchedResourceSyncRule) populate(objectMap, "targetResourceGroup", c.TargetResourceGroup) return json.Marshal(objectMap) @@ -131,7 +131,7 @@ func (c *CustomLocationFindTargetResourceGroupResult) UnmarshalJSON(data []byte) // MarshalJSON implements the json.Marshaller interface for type CustomLocationListResult. func (c CustomLocationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -162,7 +162,7 @@ func (c *CustomLocationListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CustomLocationOperation. func (c CustomLocationOperation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "display", c.Display) populate(objectMap, "isDataAction", c.IsDataAction) populate(objectMap, "name", c.Name) @@ -201,7 +201,7 @@ func (c *CustomLocationOperation) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CustomLocationOperationValueDisplay. func (c CustomLocationOperationValueDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", c.Description) populate(objectMap, "operation", c.Operation) populate(objectMap, "provider", c.Provider) @@ -240,7 +240,7 @@ func (c *CustomLocationOperationValueDisplay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CustomLocationOperationsList. func (c CustomLocationOperationsList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -271,7 +271,7 @@ func (c *CustomLocationOperationsList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CustomLocationProperties. func (c CustomLocationProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "authentication", c.Authentication) populate(objectMap, "clusterExtensionIds", c.ClusterExtensionIDs) populate(objectMap, "displayName", c.DisplayName) @@ -322,7 +322,7 @@ func (c *CustomLocationProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CustomLocationPropertiesAuthentication. func (c CustomLocationPropertiesAuthentication) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "type", c.Type) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -353,7 +353,7 @@ func (c *CustomLocationPropertiesAuthentication) UnmarshalJSON(data []byte) erro // MarshalJSON implements the json.Marshaller interface for type EnabledResourceType. func (e EnabledResourceType) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", e.ID) populate(objectMap, "name", e.Name) populate(objectMap, "properties", e.Properties) @@ -396,7 +396,7 @@ func (e *EnabledResourceType) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EnabledResourceTypeProperties. func (e EnabledResourceTypeProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "clusterExtensionId", e.ClusterExtensionID) populate(objectMap, "extensionType", e.ExtensionType) populate(objectMap, "typesMetadata", e.TypesMetadata) @@ -431,7 +431,7 @@ func (e *EnabledResourceTypeProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type EnabledResourceTypePropertiesTypesMetadataItem. func (e EnabledResourceTypePropertiesTypesMetadataItem) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "apiVersion", e.APIVersion) populate(objectMap, "resourceProviderNamespace", e.ResourceProviderNamespace) populate(objectMap, "resourceType", e.ResourceType) @@ -466,7 +466,7 @@ func (e *EnabledResourceTypePropertiesTypesMetadataItem) UnmarshalJSON(data []by // MarshalJSON implements the json.Marshaller interface for type EnabledResourceTypesListResult. func (e EnabledResourceTypesListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", e.NextLink) populate(objectMap, "value", e.Value) return json.Marshal(objectMap) @@ -497,7 +497,7 @@ func (e *EnabledResourceTypesListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "info", &e.Info) populate(objectMap, "type", e.Type) return json.Marshal(objectMap) @@ -528,7 +528,7 @@ func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorDetail. func (e ErrorDetail) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "additionalInfo", e.AdditionalInfo) populate(objectMap, "code", e.Code) populate(objectMap, "details", e.Details) @@ -571,7 +571,7 @@ func (e *ErrorDetail) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorResponse. func (e ErrorResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "error", e.Error) return json.Marshal(objectMap) } @@ -598,7 +598,7 @@ func (e *ErrorResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Identity. func (i Identity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "principalId", i.PrincipalID) populate(objectMap, "tenantId", i.TenantID) populate(objectMap, "type", i.Type) @@ -633,7 +633,7 @@ func (i *Identity) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type MatchExpressionsProperties. func (m MatchExpressionsProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "key", m.Key) populate(objectMap, "operator", m.Operator) populate(objectMap, "values", m.Values) @@ -668,7 +668,7 @@ func (m *MatchExpressionsProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PatchableCustomLocations. func (p PatchableCustomLocations) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "identity", p.Identity) populate(objectMap, "properties", p.Properties) populate(objectMap, "tags", p.Tags) @@ -703,7 +703,7 @@ func (p *PatchableCustomLocations) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PatchableResourceSyncRule. func (p PatchableResourceSyncRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "properties", p.Properties) populate(objectMap, "tags", p.Tags) return json.Marshal(objectMap) @@ -734,7 +734,7 @@ func (p *PatchableResourceSyncRule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ProxyResource. func (p ProxyResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) populate(objectMap, "type", p.Type) @@ -769,7 +769,7 @@ func (p *ProxyResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Resource. func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "name", r.Name) populate(objectMap, "type", r.Type) @@ -804,7 +804,7 @@ func (r *Resource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceSyncRule. func (r ResourceSyncRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "location", r.Location) populate(objectMap, "name", r.Name) @@ -855,7 +855,7 @@ func (r *ResourceSyncRule) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceSyncRuleListResult. func (r ResourceSyncRuleListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", r.NextLink) populate(objectMap, "value", r.Value) return json.Marshal(objectMap) @@ -886,7 +886,7 @@ func (r *ResourceSyncRuleListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceSyncRuleProperties. func (r ResourceSyncRuleProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "priority", r.Priority) populate(objectMap, "provisioningState", r.ProvisioningState) populate(objectMap, "selector", r.Selector) @@ -925,7 +925,7 @@ func (r *ResourceSyncRuleProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ResourceSyncRulePropertiesSelector. func (r ResourceSyncRulePropertiesSelector) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "matchExpressions", r.MatchExpressions) populate(objectMap, "matchLabels", r.MatchLabels) return json.Marshal(objectMap) @@ -956,7 +956,7 @@ func (r *ResourceSyncRulePropertiesSelector) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) @@ -1003,7 +1003,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrackedResource. func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", t.ID) populate(objectMap, "location", t.Location) populate(objectMap, "name", t.Name) @@ -1044,7 +1044,7 @@ func (t *TrackedResource) UnmarshalJSON(data []byte) error { return nil } -func populate(m map[string]interface{}, k string, v interface{}) { +func populate(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { @@ -1054,7 +1054,7 @@ func populate(m map[string]interface{}, k string, v interface{}) { } } -func unpopulate(data json.RawMessage, fn string, v interface{}) error { +func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil } diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/resourcesyncrules_client.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/resourcesyncrules_client.go index 49c045f36e46..1b2b9f4b3715 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/resourcesyncrules_client.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/resourcesyncrules_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,31 +24,22 @@ import ( // ResourceSyncRulesClient contains the methods for the ResourceSyncRules group. // Don't use this type directly, use NewResourceSyncRulesClient() instead. type ResourceSyncRulesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewResourceSyncRulesClient creates a new instance of ResourceSyncRulesClient with the specified values. -// subscriptionID - The ID of the target subscription. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewResourceSyncRulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ResourceSyncRulesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ResourceSyncRulesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ResourceSyncRulesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -58,36 +47,38 @@ func NewResourceSyncRulesClient(subscriptionID string, credential azcore.TokenCr // BeginCreateOrUpdate - Creates or updates a Resource Sync Rule in the parent Custom Location, Subscription Id and Resource // Group // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-31-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// resourceName - Custom Locations name. -// childResourceName - Resource Sync Rule name. -// parameters - Parameters supplied to create or update a Resource Sync Rule. -// options - ResourceSyncRulesClientBeginCreateOrUpdateOptions contains the optional parameters for the ResourceSyncRulesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - Custom Locations name. +// - childResourceName - Resource Sync Rule name. +// - parameters - Parameters supplied to create or update a Resource Sync Rule. +// - options - ResourceSyncRulesClientBeginCreateOrUpdateOptions contains the optional parameters for the ResourceSyncRulesClient.BeginCreateOrUpdate +// method. func (client *ResourceSyncRulesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, childResourceName string, parameters ResourceSyncRule, options *ResourceSyncRulesClientBeginCreateOrUpdateOptions) (*runtime.Poller[ResourceSyncRulesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, resourceName, childResourceName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ResourceSyncRulesClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ResourceSyncRulesClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[ResourceSyncRulesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ResourceSyncRulesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates a Resource Sync Rule in the parent Custom Location, Subscription Id and Resource Group // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-31-preview func (client *ResourceSyncRulesClient) createOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, childResourceName string, parameters ResourceSyncRule, options *ResourceSyncRulesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, resourceName, childResourceName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -116,7 +107,7 @@ func (client *ResourceSyncRulesClient) createOrUpdateCreateRequest(ctx context.C return nil, errors.New("parameter childResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{childResourceName}", url.PathEscape(childResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -130,18 +121,19 @@ func (client *ResourceSyncRulesClient) createOrUpdateCreateRequest(ctx context.C // Delete - Deletes the Resource Sync Rule with the specified Resource Sync Rule Name, Custom Location Resource Name, Resource // Group, and Subscription Id. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-31-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// resourceName - Custom Locations name. -// childResourceName - Resource Sync Rule name. -// options - ResourceSyncRulesClientDeleteOptions contains the optional parameters for the ResourceSyncRulesClient.Delete -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - Custom Locations name. +// - childResourceName - Resource Sync Rule name. +// - options - ResourceSyncRulesClientDeleteOptions contains the optional parameters for the ResourceSyncRulesClient.Delete +// method. func (client *ResourceSyncRulesClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, childResourceName string, options *ResourceSyncRulesClientDeleteOptions) (ResourceSyncRulesClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceName, childResourceName, options) if err != nil { return ResourceSyncRulesClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceSyncRulesClientDeleteResponse{}, err } @@ -170,7 +162,7 @@ func (client *ResourceSyncRulesClient) deleteCreateRequest(ctx context.Context, return nil, errors.New("parameter childResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{childResourceName}", url.PathEscape(childResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -184,17 +176,18 @@ func (client *ResourceSyncRulesClient) deleteCreateRequest(ctx context.Context, // Get - Gets the details of the resourceSyncRule with a specified resource group, subscription id Custom Location resource // name and Resource Sync Rule name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-31-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// resourceName - Custom Locations name. -// childResourceName - Resource Sync Rule name. -// options - ResourceSyncRulesClientGetOptions contains the optional parameters for the ResourceSyncRulesClient.Get method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - Custom Locations name. +// - childResourceName - Resource Sync Rule name. +// - options - ResourceSyncRulesClientGetOptions contains the optional parameters for the ResourceSyncRulesClient.Get method. func (client *ResourceSyncRulesClient) Get(ctx context.Context, resourceGroupName string, resourceName string, childResourceName string, options *ResourceSyncRulesClientGetOptions) (ResourceSyncRulesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, resourceName, childResourceName, options) if err != nil { return ResourceSyncRulesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceSyncRulesClientGetResponse{}, err } @@ -223,7 +216,7 @@ func (client *ResourceSyncRulesClient) getCreateRequest(ctx context.Context, res return nil, errors.New("parameter childResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{childResourceName}", url.PathEscape(childResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -245,12 +238,12 @@ func (client *ResourceSyncRulesClient) getHandleResponse(resp *http.Response) (R // NewListByCustomLocationIDPager - Gets a list of Resource Sync Rules in the specified subscription. The operation returns // properties of each Resource Sync Rule -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-31-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// resourceName - Custom Locations name. -// options - ResourceSyncRulesClientListByCustomLocationIDOptions contains the optional parameters for the ResourceSyncRulesClient.ListByCustomLocationID -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - Custom Locations name. +// - options - ResourceSyncRulesClientListByCustomLocationIDOptions contains the optional parameters for the ResourceSyncRulesClient.NewListByCustomLocationIDPager +// method. func (client *ResourceSyncRulesClient) NewListByCustomLocationIDPager(resourceGroupName string, resourceName string, options *ResourceSyncRulesClientListByCustomLocationIDOptions) *runtime.Pager[ResourceSyncRulesClientListByCustomLocationIDResponse] { return runtime.NewPager(runtime.PagingHandler[ResourceSyncRulesClientListByCustomLocationIDResponse]{ More: func(page ResourceSyncRulesClientListByCustomLocationIDResponse) bool { @@ -267,7 +260,7 @@ func (client *ResourceSyncRulesClient) NewListByCustomLocationIDPager(resourceGr if err != nil { return ResourceSyncRulesClientListByCustomLocationIDResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceSyncRulesClientListByCustomLocationIDResponse{}, err } @@ -294,7 +287,7 @@ func (client *ResourceSyncRulesClient) listByCustomLocationIDCreateRequest(ctx c 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.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -317,37 +310,39 @@ func (client *ResourceSyncRulesClient) listByCustomLocationIDHandleResponse(resp // BeginUpdate - Updates a Resource Sync Rule with the specified Resource Sync Rule name in the specified Resource Group, // Subscription and Custom Location name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-31-preview -// resourceGroupName - The name of the resource group. The name is case insensitive. -// resourceName - Custom Locations name. -// childResourceName - Resource Sync Rule name. -// parameters - The updatable fields of an existing Resource Sync Rule. -// options - ResourceSyncRulesClientBeginUpdateOptions contains the optional parameters for the ResourceSyncRulesClient.BeginUpdate -// method. +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - resourceName - Custom Locations name. +// - childResourceName - Resource Sync Rule name. +// - parameters - The updatable fields of an existing Resource Sync Rule. +// - options - ResourceSyncRulesClientBeginUpdateOptions contains the optional parameters for the ResourceSyncRulesClient.BeginUpdate +// method. func (client *ResourceSyncRulesClient) BeginUpdate(ctx context.Context, resourceGroupName string, resourceName string, childResourceName string, parameters PatchableResourceSyncRule, options *ResourceSyncRulesClientBeginUpdateOptions) (*runtime.Poller[ResourceSyncRulesClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, resourceName, childResourceName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ResourceSyncRulesClientUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ResourceSyncRulesClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[ResourceSyncRulesClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ResourceSyncRulesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates a Resource Sync Rule with the specified Resource Sync Rule name in the specified Resource Group, Subscription // and Custom Location name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2021-08-31-preview func (client *ResourceSyncRulesClient) update(ctx context.Context, resourceGroupName string, resourceName string, childResourceName string, parameters PatchableResourceSyncRule, options *ResourceSyncRulesClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, resourceName, childResourceName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -376,7 +371,7 @@ func (client *ResourceSyncRulesClient) updateCreateRequest(ctx context.Context, return nil, errors.New("parameter childResourceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{childResourceName}", url.PathEscape(childResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/resourcesyncrules_client_example_test.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/resourcesyncrules_client_example_test.go index 80e91abfa435..1d26ab099fcd 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/resourcesyncrules_client_example_test.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/resourcesyncrules_client_example_test.go @@ -5,6 +5,7 @@ // 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 armextendedlocation_test @@ -17,90 +18,177 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/extendedlocation/armextendedlocation" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesListByCustomLocationID.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8fc2b4ff626aab886f929e49926c6e836548e01/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesListByCustomLocationID.json func ExampleResourceSyncRulesClient_NewListByCustomLocationIDPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armextendedlocation.NewResourceSyncRulesClient("11111111-2222-3333-4444-555555555555", cred, nil) + clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByCustomLocationIDPager("testresourcegroup", - "customLocation01", - nil) + pager := clientFactory.NewResourceSyncRulesClient().NewListByCustomLocationIDPager("testresourcegroup", "customLocation01", nil) for pager.More() { - nextResult, err := pager.NextPage(ctx) + page, err := pager.NextPage(ctx) if err != nil { log.Fatalf("failed to advance page: %v", err) } - for _, v := range nextResult.Value { - // TODO: use page item + 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.ResourceSyncRuleListResult = armextendedlocation.ResourceSyncRuleListResult{ + // Value: []*armextendedlocation.ResourceSyncRule{ + // { + // Name: to.Ptr("resourceSyncRule01"), + // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations/resourceSyncRules"), + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/customLocations/customLocation01/resourcesyncrules"), + // Location: to.Ptr("West US"), + // Properties: &armextendedlocation.ResourceSyncRuleProperties{ + // Priority: to.Ptr[int32](999), + // ProvisioningState: to.Ptr("Succeeded"), + // Selector: &armextendedlocation.ResourceSyncRulePropertiesSelector{ + // MatchExpressions: []*armextendedlocation.MatchExpressionsProperties{ + // { + // Key: to.Ptr("key4"), + // Operator: to.Ptr("In"), + // Values: []*string{ + // to.Ptr("value4")}, + // }}, + // MatchLabels: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // TargetResourceGroup: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/"), + // }, + // SystemData: &armextendedlocation.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T18:53:29.0928001Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T18:53:29.0928001Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // }, + // }, + // { + // Name: to.Ptr("resourceSyncRule02"), + // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations/resourceSyncRules"), + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/"), + // Location: to.Ptr("West US"), + // Properties: &armextendedlocation.ResourceSyncRuleProperties{ + // Priority: to.Ptr[int32](999), + // ProvisioningState: to.Ptr("Succeeded"), + // Selector: &armextendedlocation.ResourceSyncRulePropertiesSelector{ + // MatchExpressions: []*armextendedlocation.MatchExpressionsProperties{ + // { + // Key: to.Ptr("key8"), + // Operator: to.Ptr("In"), + // Values: []*string{ + // to.Ptr("value8")}, + // }}, + // MatchLabels: map[string]*string{ + // "key5": to.Ptr("value5"), + // }, + // }, + // TargetResourceGroup: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/amalladi-df-test/"), + // }, + // SystemData: &armextendedlocation.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // }, + // }}, + // } } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesGet.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8fc2b4ff626aab886f929e49926c6e836548e01/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesGet.json func ExampleResourceSyncRulesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armextendedlocation.NewResourceSyncRulesClient("11111111-2222-3333-4444-555555555555", cred, nil) + clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, - "testresourcegroup", - "customLocation01", - "resourceSyncRule01", - nil) + res, err := clientFactory.NewResourceSyncRulesClient().Get(ctx, "testresourcegroup", "customLocation01", "resourceSyncRule01", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } - // TODO: use response item + // 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.ResourceSyncRule = armextendedlocation.ResourceSyncRule{ + // Name: to.Ptr("resourceSyncRule01"), + // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations/resourceSyncRules"), + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/customLocations/customLocation01/resourceSyncRules/resourceSyncRule01"), + // Location: to.Ptr("West US"), + // Properties: &armextendedlocation.ResourceSyncRuleProperties{ + // Priority: to.Ptr[int32](999), + // ProvisioningState: to.Ptr("Succeeded"), + // Selector: &armextendedlocation.ResourceSyncRulePropertiesSelector{ + // MatchExpressions: []*armextendedlocation.MatchExpressionsProperties{ + // { + // Key: to.Ptr("key4"), + // Operator: to.Ptr("In"), + // Values: []*string{ + // to.Ptr("value4")}, + // }}, + // MatchLabels: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // TargetResourceGroup: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup"), + // }, + // SystemData: &armextendedlocation.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-24T18:53:29.0928001Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesCreate_Update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8fc2b4ff626aab886f929e49926c6e836548e01/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesCreate_Update.json func ExampleResourceSyncRulesClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armextendedlocation.NewResourceSyncRulesClient("11111111-2222-3333-4444-555555555555", cred, nil) + clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, - "testresourcegroup", - "customLocation01", - "resourceSyncRule01", - armextendedlocation.ResourceSyncRule{ - Location: to.Ptr("West US"), - Properties: &armextendedlocation.ResourceSyncRuleProperties{ - Priority: to.Ptr[int32](999), - Selector: &armextendedlocation.ResourceSyncRulePropertiesSelector{ - MatchExpressions: []*armextendedlocation.MatchExpressionsProperties{ - { - Key: to.Ptr("key4"), - Operator: to.Ptr("In"), - Values: []*string{ - to.Ptr("value4")}, - }}, - MatchLabels: map[string]*string{ - "key1": to.Ptr("value1"), - }, + poller, err := clientFactory.NewResourceSyncRulesClient().BeginCreateOrUpdate(ctx, "testresourcegroup", "customLocation01", "resourceSyncRule01", armextendedlocation.ResourceSyncRule{ + Location: to.Ptr("West US"), + Properties: &armextendedlocation.ResourceSyncRuleProperties{ + Priority: to.Ptr[int32](999), + Selector: &armextendedlocation.ResourceSyncRulePropertiesSelector{ + MatchExpressions: []*armextendedlocation.MatchExpressionsProperties{ + { + Key: to.Ptr("key4"), + Operator: to.Ptr("In"), + Values: []*string{ + to.Ptr("value4")}, + }}, + MatchLabels: map[string]*string{ + "key1": to.Ptr("value1"), }, - TargetResourceGroup: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup"), }, + TargetResourceGroup: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup"), }, - nil) + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -108,55 +196,78 @@ func ExampleResourceSyncRulesClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // 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.ResourceSyncRule = armextendedlocation.ResourceSyncRule{ + // Name: to.Ptr("resourceSyncRule01"), + // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations/resourceSyncRules"), + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/customLocations/customLocation01/resourcesyncrules/resourceSyncRule01"), + // Location: to.Ptr("West US"), + // Properties: &armextendedlocation.ResourceSyncRuleProperties{ + // Priority: to.Ptr[int32](999), + // ProvisioningState: to.Ptr("Succeeded"), + // Selector: &armextendedlocation.ResourceSyncRulePropertiesSelector{ + // MatchExpressions: []*armextendedlocation.MatchExpressionsProperties{ + // { + // Key: to.Ptr("key4"), + // Operator: to.Ptr("In"), + // Values: []*string{ + // to.Ptr("value4")}, + // }}, + // MatchLabels: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // TargetResourceGroup: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup"), + // }, + // SystemData: &armextendedlocation.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-15T18:53:29.0928001Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-15T18:53:29.0928001Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // }, + // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesDelete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8fc2b4ff626aab886f929e49926c6e836548e01/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesDelete.json func ExampleResourceSyncRulesClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armextendedlocation.NewResourceSyncRulesClient("11111111-2222-3333-4444-555555555555", cred, nil) + clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = client.Delete(ctx, - "testresourcegroup", - "customLocation01", - "resourceSyncRule01", - nil) + _, err = clientFactory.NewResourceSyncRulesClient().Delete(ctx, "testresourcegroup", "customLocation01", "resourceSyncRule01", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesPatch.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8fc2b4ff626aab886f929e49926c6e836548e01/specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/preview/2021-08-31-preview/examples/ResourceSyncRulesPatch.json func ExampleResourceSyncRulesClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armextendedlocation.NewResourceSyncRulesClient("11111111-2222-3333-4444-555555555555", cred, nil) + clientFactory, err := armextendedlocation.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, - "testresourcegroup", - "customLocation01", - "resourceSyncRule01", - armextendedlocation.PatchableResourceSyncRule{ - Properties: &armextendedlocation.ResourceSyncRuleProperties{ - TargetResourceGroup: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/"), - }, - Tags: map[string]*string{ - "tier": to.Ptr("testing"), - }, + poller, err := clientFactory.NewResourceSyncRulesClient().BeginUpdate(ctx, "testresourcegroup", "customLocation01", "resourceSyncRule01", armextendedlocation.PatchableResourceSyncRule{ + Properties: &armextendedlocation.ResourceSyncRuleProperties{ + TargetResourceGroup: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/"), + }, + Tags: map[string]*string{ + "tier": to.Ptr("testing"), }, - nil) + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -164,6 +275,41 @@ func ExampleResourceSyncRulesClient_BeginUpdate() { if err != nil { log.Fatalf("failed to pull the result: %v", err) } - // TODO: use response item + // 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.ResourceSyncRule = armextendedlocation.ResourceSyncRule{ + // Name: to.Ptr("resourceSyncRule01"), + // Type: to.Ptr("Microsoft.ExtendedLocation/customLocations/resourceSyncRules"), + // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/customLocations/customLocation01/resourceSyncRules/resourceSyncRule01"), + // Location: to.Ptr("West US"), + // Tags: map[string]*string{ + // "tier": to.Ptr("testing"), + // }, + // Properties: &armextendedlocation.ResourceSyncRuleProperties{ + // Priority: to.Ptr[int32](999), + // ProvisioningState: to.Ptr("Succeeded"), + // Selector: &armextendedlocation.ResourceSyncRulePropertiesSelector{ + // MatchExpressions: []*armextendedlocation.MatchExpressionsProperties{ + // { + // Key: to.Ptr("key4"), + // Operator: to.Ptr("In"), + // Values: []*string{ + // to.Ptr("value4")}, + // }}, + // MatchLabels: map[string]*string{ + // "key1": to.Ptr("value1"), + // }, + // }, + // TargetResourceGroup: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testrg/"), + // }, + // SystemData: &armextendedlocation.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T23:17:11.7353229Z"); return t}()), + // CreatedBy: to.Ptr("string"), + // CreatedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-16T23:28:00.5870852Z"); return t}()), + // LastModifiedBy: to.Ptr("string"), + // LastModifiedByType: to.Ptr(armextendedlocation.CreatedByTypeApplication), + // }, + // } } diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/response_types.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/response_types.go index b90ce43a1b67..9a93678b3439 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/response_types.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/response_types.go @@ -9,12 +9,12 @@ package armextendedlocation -// CustomLocationsClientCreateOrUpdateResponse contains the response from method CustomLocationsClient.CreateOrUpdate. +// CustomLocationsClientCreateOrUpdateResponse contains the response from method CustomLocationsClient.BeginCreateOrUpdate. type CustomLocationsClientCreateOrUpdateResponse struct { CustomLocation } -// CustomLocationsClientDeleteResponse contains the response from method CustomLocationsClient.Delete. +// CustomLocationsClientDeleteResponse contains the response from method CustomLocationsClient.BeginDelete. type CustomLocationsClientDeleteResponse struct { // placeholder for future response values } @@ -29,22 +29,22 @@ type CustomLocationsClientGetResponse struct { CustomLocation } -// CustomLocationsClientListByResourceGroupResponse contains the response from method CustomLocationsClient.ListByResourceGroup. +// CustomLocationsClientListByResourceGroupResponse contains the response from method CustomLocationsClient.NewListByResourceGroupPager. type CustomLocationsClientListByResourceGroupResponse struct { CustomLocationListResult } -// CustomLocationsClientListBySubscriptionResponse contains the response from method CustomLocationsClient.ListBySubscription. +// CustomLocationsClientListBySubscriptionResponse contains the response from method CustomLocationsClient.NewListBySubscriptionPager. type CustomLocationsClientListBySubscriptionResponse struct { CustomLocationListResult } -// CustomLocationsClientListEnabledResourceTypesResponse contains the response from method CustomLocationsClient.ListEnabledResourceTypes. +// CustomLocationsClientListEnabledResourceTypesResponse contains the response from method CustomLocationsClient.NewListEnabledResourceTypesPager. type CustomLocationsClientListEnabledResourceTypesResponse struct { EnabledResourceTypesListResult } -// CustomLocationsClientListOperationsResponse contains the response from method CustomLocationsClient.ListOperations. +// CustomLocationsClientListOperationsResponse contains the response from method CustomLocationsClient.NewListOperationsPager. type CustomLocationsClientListOperationsResponse struct { CustomLocationOperationsList } @@ -54,7 +54,7 @@ type CustomLocationsClientUpdateResponse struct { CustomLocation } -// ResourceSyncRulesClientCreateOrUpdateResponse contains the response from method ResourceSyncRulesClient.CreateOrUpdate. +// ResourceSyncRulesClientCreateOrUpdateResponse contains the response from method ResourceSyncRulesClient.BeginCreateOrUpdate. type ResourceSyncRulesClientCreateOrUpdateResponse struct { ResourceSyncRule } @@ -69,12 +69,12 @@ type ResourceSyncRulesClientGetResponse struct { ResourceSyncRule } -// ResourceSyncRulesClientListByCustomLocationIDResponse contains the response from method ResourceSyncRulesClient.ListByCustomLocationID. +// ResourceSyncRulesClientListByCustomLocationIDResponse contains the response from method ResourceSyncRulesClient.NewListByCustomLocationIDPager. type ResourceSyncRulesClientListByCustomLocationIDResponse struct { ResourceSyncRuleListResult } -// ResourceSyncRulesClientUpdateResponse contains the response from method ResourceSyncRulesClient.Update. +// ResourceSyncRulesClientUpdateResponse contains the response from method ResourceSyncRulesClient.BeginUpdate. type ResourceSyncRulesClientUpdateResponse struct { ResourceSyncRule } diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/time_rfc3339.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/time_rfc3339.go index 10ff6c2945fa..6121bbbf1a33 100644 --- a/sdk/resourcemanager/extendedlocation/armextendedlocation/time_rfc3339.go +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/time_rfc3339.go @@ -62,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/CHANGELOG.md b/sdk/resourcemanager/fluidrelay/armfluidrelay/CHANGELOG.md index 854f139aac88..167fa0166498 100644 --- a/sdk/resourcemanager/fluidrelay/armfluidrelay/CHANGELOG.md +++ b/sdk/resourcemanager/fluidrelay/armfluidrelay/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2022-07-15) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fluidrelay/armfluidrelay` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 1.0.0, which contains breaking changes. diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/README.md b/sdk/resourcemanager/fluidrelay/armfluidrelay/README.md index e6e5e5c29ed0..52ed66c2e500 100644 --- a/sdk/resourcemanager/fluidrelay/armfluidrelay/README.md +++ b/sdk/resourcemanager/fluidrelay/armfluidrelay/README.md @@ -33,23 +33,31 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Fluidrelay modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Fluidrelay module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armfluidrelay.NewServersClient(, cred, nil) +clientFactory, err := armfluidrelay.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). ```go -options := arm.ClientOptions{ +options := arm.ClientOptions { ClientOptions: azcore.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armfluidrelay.NewServersClient(, cred, &options) +clientFactory, err := armfluidrelay.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewServersClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/autorest.md b/sdk/resourcemanager/fluidrelay/armfluidrelay/autorest.md index 2ff14250b1b7..15ffe89e3bc9 100644 --- a/sdk/resourcemanager/fluidrelay/armfluidrelay/autorest.md +++ b/sdk/resourcemanager/fluidrelay/armfluidrelay/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/432872fac1d0f8edcae98a0e8504afc0ee302710/specification/fluidrelay/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/432872fac1d0f8edcae98a0e8504afc0ee302710/specification/fluidrelay/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 1.1.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/client_factory.go b/sdk/resourcemanager/fluidrelay/armfluidrelay/client_factory.go new file mode 100644 index 000000000000..c67c0559825e --- /dev/null +++ b/sdk/resourcemanager/fluidrelay/armfluidrelay/client_factory.go @@ -0,0 +1,54 @@ +//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 armfluidrelay + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The subscription id (GUID) for this resource. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewServersClient() *ServersClient { + subClient, _ := NewServersClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewContainersClient() *ContainersClient { + subClient, _ := NewContainersClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/constants.go b/sdk/resourcemanager/fluidrelay/armfluidrelay/constants.go index bd7df312c54f..87e36008865f 100644 --- a/sdk/resourcemanager/fluidrelay/armfluidrelay/constants.go +++ b/sdk/resourcemanager/fluidrelay/armfluidrelay/constants.go @@ -11,7 +11,7 @@ package armfluidrelay const ( moduleName = "armfluidrelay" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // CmkIdentityType - Values can be SystemAssigned or UserAssigned diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/containers_client.go b/sdk/resourcemanager/fluidrelay/armfluidrelay/containers_client.go index 0fb05b17fb94..8fd34cae3653 100644 --- a/sdk/resourcemanager/fluidrelay/armfluidrelay/containers_client.go +++ b/sdk/resourcemanager/fluidrelay/armfluidrelay/containers_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // ContainersClient contains the methods for the FluidRelayContainers group. // Don't use this type directly, use NewContainersClient() instead. type ContainersClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewContainersClient creates a new instance of ContainersClient with the specified values. -// subscriptionID - The subscription id (GUID) for this resource. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription id (GUID) for this resource. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewContainersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ContainersClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ContainersClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ContainersClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Delete - Delete a Fluid Relay container. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-06-01 -// resourceGroup - The resource group containing the resource. -// fluidRelayServerName - The Fluid Relay server resource name. -// fluidRelayContainerName - The Fluid Relay container resource name. -// options - ContainersClientDeleteOptions contains the optional parameters for the ContainersClient.Delete method. +// - resourceGroup - The resource group containing the resource. +// - fluidRelayServerName - The Fluid Relay server resource name. +// - fluidRelayContainerName - The Fluid Relay container resource name. +// - options - ContainersClientDeleteOptions contains the optional parameters for the ContainersClient.Delete method. func (client *ContainersClient) Delete(ctx context.Context, resourceGroup string, fluidRelayServerName string, fluidRelayContainerName string, options *ContainersClientDeleteOptions) (ContainersClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroup, fluidRelayServerName, fluidRelayContainerName, options) if err != nil { return ContainersClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ContainersClientDeleteResponse{}, err } @@ -96,7 +86,7 @@ func (client *ContainersClient) deleteCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter fluidRelayContainerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{fluidRelayContainerName}", url.PathEscape(fluidRelayContainerName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -109,17 +99,18 @@ func (client *ContainersClient) deleteCreateRequest(ctx context.Context, resourc // Get - Get a Fluid Relay container. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-06-01 -// resourceGroup - The resource group containing the resource. -// fluidRelayServerName - The Fluid Relay server resource name. -// fluidRelayContainerName - The Fluid Relay container resource name. -// options - ContainersClientGetOptions contains the optional parameters for the ContainersClient.Get method. +// - resourceGroup - The resource group containing the resource. +// - fluidRelayServerName - The Fluid Relay server resource name. +// - fluidRelayContainerName - The Fluid Relay container resource name. +// - options - ContainersClientGetOptions contains the optional parameters for the ContainersClient.Get method. func (client *ContainersClient) Get(ctx context.Context, resourceGroup string, fluidRelayServerName string, fluidRelayContainerName string, options *ContainersClientGetOptions) (ContainersClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroup, fluidRelayServerName, fluidRelayContainerName, options) if err != nil { return ContainersClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ContainersClientGetResponse{}, err } @@ -148,7 +139,7 @@ func (client *ContainersClient) getCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter fluidRelayContainerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{fluidRelayContainerName}", url.PathEscape(fluidRelayContainerName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -169,12 +160,12 @@ func (client *ContainersClient) getHandleResponse(resp *http.Response) (Containe } // NewListByFluidRelayServersPager - List all Fluid Relay containers which are children of a given Fluid Relay server. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-06-01 -// resourceGroup - The resource group containing the resource. -// fluidRelayServerName - The Fluid Relay server resource name. -// options - ContainersClientListByFluidRelayServersOptions contains the optional parameters for the ContainersClient.ListByFluidRelayServers -// method. +// - resourceGroup - The resource group containing the resource. +// - fluidRelayServerName - The Fluid Relay server resource name. +// - options - ContainersClientListByFluidRelayServersOptions contains the optional parameters for the ContainersClient.NewListByFluidRelayServersPager +// method. func (client *ContainersClient) NewListByFluidRelayServersPager(resourceGroup string, fluidRelayServerName string, options *ContainersClientListByFluidRelayServersOptions) *runtime.Pager[ContainersClientListByFluidRelayServersResponse] { return runtime.NewPager(runtime.PagingHandler[ContainersClientListByFluidRelayServersResponse]{ More: func(page ContainersClientListByFluidRelayServersResponse) bool { @@ -191,7 +182,7 @@ func (client *ContainersClient) NewListByFluidRelayServersPager(resourceGroup st if err != nil { return ContainersClientListByFluidRelayServersResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ContainersClientListByFluidRelayServersResponse{}, err } @@ -218,7 +209,7 @@ func (client *ContainersClient) listByFluidRelayServersCreateRequest(ctx context return nil, errors.New("parameter fluidRelayServerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{fluidRelayServerName}", url.PathEscape(fluidRelayServerName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/containers_client_example_test.go b/sdk/resourcemanager/fluidrelay/armfluidrelay/containers_client_example_test.go new file mode 100644 index 000000000000..bd010791d22b --- /dev/null +++ b/sdk/resourcemanager/fluidrelay/armfluidrelay/containers_client_example_test.go @@ -0,0 +1,107 @@ +//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 armfluidrelay_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fluidrelay/armfluidrelay" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/432872fac1d0f8edcae98a0e8504afc0ee302710/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayContainers_Get.json +func ExampleContainersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfluidrelay.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewContainersClient().Get(ctx, "myResourceGroup", "myFluidRelayServer", "myFluidRelayContainer", 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.Container = armfluidrelay.Container{ + // Name: to.Ptr("myFluidRelayContainer"), + // Type: to.Ptr("Microsoft.FluidRelay/fluidRelayServers/fluidRelayContainers"), + // ID: to.Ptr("/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/Microsoft.FluidRelay/fluidRelayServers/myFluidRelayServer/fluidRelayContainers/myFluidRelayContainer"), + // Properties: &armfluidrelay.ContainerProperties{ + // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-21T02:17:01.164Z"); return t}()), + // FrsContainerID: to.Ptr("xxxx-yyyy-xxxxx-yyyy"), + // FrsTenantID: to.Ptr("yyyy-yyyy-yyyyy-yyyy"), + // LastAccessTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-21T02:17:01.164Z"); return t}()), + // ProvisioningState: to.Ptr(armfluidrelay.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/432872fac1d0f8edcae98a0e8504afc0ee302710/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayContainers_Delete.json +func ExampleContainersClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfluidrelay.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewContainersClient().Delete(ctx, "myResourceGroup", "myFluidRelayServer", "myFluidRelayContainer", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/432872fac1d0f8edcae98a0e8504afc0ee302710/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayContainers_ListByFluidRelayServer.json +func ExampleContainersClient_NewListByFluidRelayServersPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfluidrelay.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewContainersClient().NewListByFluidRelayServersPager("myResourceGroup", "myFluidRelayServer", 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.ContainerList = armfluidrelay.ContainerList{ + // Value: []*armfluidrelay.Container{ + // { + // Name: to.Ptr("myFluidRelayContainer"), + // Type: to.Ptr("Microsoft.FluidRelay/fluidRelayServers/fluidRelayContainers"), + // ID: to.Ptr("/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/Microsoft.FluidRelay/fluidRelayServers/myFluidRelayServer/fluidRelayContainers/myFluidRelayContainer"), + // Properties: &armfluidrelay.ContainerProperties{ + // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-21T02:17:01.164Z"); return t}()), + // FrsContainerID: to.Ptr("xxxx-yyyy-xxxxx-yyyy"), + // FrsTenantID: to.Ptr("yyyy-yyyy-yyyyy-yyyy"), + // LastAccessTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-04-21T02:17:01.164Z"); return t}()), + // ProvisioningState: to.Ptr(armfluidrelay.ProvisioningStateSucceeded), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/fluidrelaycontainers_client_example_test.go b/sdk/resourcemanager/fluidrelay/armfluidrelay/fluidrelaycontainers_client_example_test.go deleted file mode 100644 index 087cb179b57e..000000000000 --- a/sdk/resourcemanager/fluidrelay/armfluidrelay/fluidrelaycontainers_client_example_test.go +++ /dev/null @@ -1,87 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armfluidrelay_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fluidrelay/armfluidrelay" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayContainers_Get.json -func ExampleContainersClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfluidrelay.NewContainersClient("xxxx-xxxx-xxxx-xxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "myResourceGroup", - "myFluidRelayServer", - "myFluidRelayContainer", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayContainers_Delete.json -func ExampleContainersClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfluidrelay.NewContainersClient("xxxx-xxxx-xxxx-xxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "myResourceGroup", - "myFluidRelayServer", - "myFluidRelayContainer", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayContainers_ListByFluidRelayServer.json -func ExampleContainersClient_NewListByFluidRelayServersPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfluidrelay.NewContainersClient("xxxx-xxxx-xxxx-xxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByFluidRelayServersPager("myResourceGroup", - "myFluidRelayServer", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/fluidrelayoperations_client_example_test.go b/sdk/resourcemanager/fluidrelay/armfluidrelay/fluidrelayoperations_client_example_test.go deleted file mode 100644 index 162c16847c28..000000000000 --- a/sdk/resourcemanager/fluidrelay/armfluidrelay/fluidrelayoperations_client_example_test.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armfluidrelay_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fluidrelay/armfluidrelay" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServerOperations.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfluidrelay.NewOperationsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/fluidrelayservers_client_example_test.go b/sdk/resourcemanager/fluidrelay/armfluidrelay/fluidrelayservers_client_example_test.go deleted file mode 100644 index 740735311f8a..000000000000 --- a/sdk/resourcemanager/fluidrelay/armfluidrelay/fluidrelayservers_client_example_test.go +++ /dev/null @@ -1,217 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armfluidrelay_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/fluidrelay/armfluidrelay" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_Get.json -func ExampleServersClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfluidrelay.NewServersClient("xxxx-xxxx-xxxx-xxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "myResourceGroup", - "myFluidRelayServer", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_CreateOrUpdate.json -func ExampleServersClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfluidrelay.NewServersClient("xxxx-xxxx-xxxx-xxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "myResourceGroup", - "myFluidRelayServer", - armfluidrelay.Server{ - Location: to.Ptr("west-us"), - Tags: map[string]*string{ - "Category": to.Ptr("sales"), - }, - Identity: &armfluidrelay.Identity{ - Type: to.Ptr(armfluidrelay.ResourceIdentityTypeSystemAssigned), - }, - Properties: &armfluidrelay.ServerProperties{ - Storagesku: to.Ptr(armfluidrelay.StorageSKUBasic), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_Update.json -func ExampleServersClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfluidrelay.NewServersClient("xxxx-xxxx-xxxx-xxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "myResourceGroup", - "myFluidRelayServer", - armfluidrelay.ServerUpdate{ - Tags: map[string]*string{ - "Category": to.Ptr("sales"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_Delete.json -func ExampleServersClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfluidrelay.NewServersClient("xxxx-xxxx-xxxx-xxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "myResourceGroup", - "myFluidRelayServer", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_RegenerateKeys.json -func ExampleServersClient_RegenerateKey() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfluidrelay.NewServersClient("xxxx-xxxx-xxxx-xxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.RegenerateKey(ctx, - "myResourceGroup", - "myFluidRelayServer", - armfluidrelay.RegenerateKeyRequest{ - KeyName: to.Ptr(armfluidrelay.KeyNameKey1), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_ListKeys.json -func ExampleServersClient_ListKeys() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfluidrelay.NewServersClient("xxxx-xxxx-xxxx-xxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListKeys(ctx, - "myResourceGroup", - "myFluidRelayServer", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_ListBySubscription.json -func ExampleServersClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfluidrelay.NewServersClient("xxxx-xxxx-xxxx-xxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListBySubscriptionPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_ListByResourceGroup.json -func ExampleServersClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfluidrelay.NewServersClient("xxxx-xxxx-xxxx-xxxx", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("myResourceGroup", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/go.mod b/sdk/resourcemanager/fluidrelay/armfluidrelay/go.mod index abcf6433a2cb..f6dce6a54091 100644 --- a/sdk/resourcemanager/fluidrelay/armfluidrelay/go.mod +++ b/sdk/resourcemanager/fluidrelay/armfluidrelay/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fluidrelay/armfluid go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/go.sum b/sdk/resourcemanager/fluidrelay/armfluidrelay/go.sum index 8828b17b1853..8ba445a8c4da 100644 --- a/sdk/resourcemanager/fluidrelay/armfluidrelay/go.sum +++ b/sdk/resourcemanager/fluidrelay/armfluidrelay/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 h1:BWe8a+f/t+7KY7zH2mqygeUD0t8hNFXe08p1Pb3/jKE= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/models.go b/sdk/resourcemanager/fluidrelay/armfluidrelay/models.go index 733b75b1e15d..536313510c82 100644 --- a/sdk/resourcemanager/fluidrelay/armfluidrelay/models.go +++ b/sdk/resourcemanager/fluidrelay/armfluidrelay/models.go @@ -66,7 +66,7 @@ type ContainersClientGetOptions struct { // placeholder for future optional parameters } -// ContainersClientListByFluidRelayServersOptions contains the optional parameters for the ContainersClient.ListByFluidRelayServers +// ContainersClientListByFluidRelayServersOptions contains the optional parameters for the ContainersClient.NewListByFluidRelayServersPager // method. type ContainersClientListByFluidRelayServersOptions struct { // placeholder for future optional parameters @@ -117,7 +117,7 @@ type Endpoints struct { // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. - Info interface{} `json:"info,omitempty" azure:"ro"` + Info any `json:"info,omitempty" azure:"ro"` // READ-ONLY; The additional info type. Type *string `json:"type,omitempty" azure:"ro"` @@ -199,7 +199,7 @@ type OperationResult struct { Name *string `json:"name,omitempty"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -334,12 +334,14 @@ type ServersClientGetOptions struct { // placeholder for future optional parameters } -// ServersClientListByResourceGroupOptions contains the optional parameters for the ServersClient.ListByResourceGroup method. +// ServersClientListByResourceGroupOptions contains the optional parameters for the ServersClient.NewListByResourceGroupPager +// method. type ServersClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// ServersClientListBySubscriptionOptions contains the optional parameters for the ServersClient.ListBySubscription method. +// ServersClientListBySubscriptionOptions contains the optional parameters for the ServersClient.NewListBySubscriptionPager +// method. type ServersClientListBySubscriptionOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/models_serde.go b/sdk/resourcemanager/fluidrelay/armfluidrelay/models_serde.go index f07ab7ee91ab..3ea2f185b3be 100644 --- a/sdk/resourcemanager/fluidrelay/armfluidrelay/models_serde.go +++ b/sdk/resourcemanager/fluidrelay/armfluidrelay/models_serde.go @@ -18,7 +18,7 @@ import ( // MarshalJSON implements the json.Marshaller interface for type Container. func (c Container) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", c.ID) populate(objectMap, "name", c.Name) populate(objectMap, "properties", c.Properties) @@ -61,7 +61,7 @@ func (c *Container) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContainerList. func (c ContainerList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", c.NextLink) populate(objectMap, "value", c.Value) return json.Marshal(objectMap) @@ -92,7 +92,7 @@ func (c *ContainerList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ContainerProperties. func (c ContainerProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "creationTime", c.CreationTime) populate(objectMap, "frsContainerId", c.FrsContainerID) populate(objectMap, "frsTenantId", c.FrsTenantID) @@ -135,7 +135,7 @@ func (c *ContainerProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CustomerManagedKeyEncryptionProperties. func (c CustomerManagedKeyEncryptionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "keyEncryptionKeyIdentity", c.KeyEncryptionKeyIdentity) populate(objectMap, "keyEncryptionKeyUrl", c.KeyEncryptionKeyURL) return json.Marshal(objectMap) @@ -166,7 +166,7 @@ func (c *CustomerManagedKeyEncryptionProperties) UnmarshalJSON(data []byte) erro // MarshalJSON implements the json.Marshaller interface for type CustomerManagedKeyEncryptionPropertiesKeyEncryptionKeyIdentity. func (c CustomerManagedKeyEncryptionPropertiesKeyEncryptionKeyIdentity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "identityType", c.IdentityType) populate(objectMap, "userAssignedIdentityResourceId", c.UserAssignedIdentityResourceID) return json.Marshal(objectMap) @@ -197,7 +197,7 @@ func (c *CustomerManagedKeyEncryptionPropertiesKeyEncryptionKeyIdentity) Unmarsh // MarshalJSON implements the json.Marshaller interface for type EncryptionProperties. func (e EncryptionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "customerManagedKeyEncryption", e.CustomerManagedKeyEncryption) return json.Marshal(objectMap) } @@ -224,7 +224,7 @@ func (e *EncryptionProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Endpoints. func (e Endpoints) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "ordererEndpoints", e.OrdererEndpoints) populate(objectMap, "serviceEndpoints", e.ServiceEndpoints) populate(objectMap, "storageEndpoints", e.StorageEndpoints) @@ -259,7 +259,7 @@ func (e *Endpoints) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "info", &e.Info) populate(objectMap, "type", e.Type) return json.Marshal(objectMap) @@ -290,7 +290,7 @@ func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorDetail. func (e ErrorDetail) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "additionalInfo", e.AdditionalInfo) populate(objectMap, "code", e.Code) populate(objectMap, "details", e.Details) @@ -333,7 +333,7 @@ func (e *ErrorDetail) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ErrorResponse. func (e ErrorResponse) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "error", e.Error) return json.Marshal(objectMap) } @@ -360,7 +360,7 @@ func (e *ErrorResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Identity. func (i Identity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "principalId", i.PrincipalID) populate(objectMap, "tenantId", i.TenantID) populate(objectMap, "type", i.Type) @@ -399,7 +399,7 @@ func (i *Identity) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationDisplay. func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "description", o.Description) populate(objectMap, "operation", o.Operation) populate(objectMap, "provider", o.Provider) @@ -438,7 +438,7 @@ func (o *OperationDisplay) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationListResult. func (o OperationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", o.NextLink) populate(objectMap, "value", o.Value) return json.Marshal(objectMap) @@ -469,7 +469,7 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationResult. func (o OperationResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "display", o.Display) populate(objectMap, "isDataAction", o.IsDataAction) populate(objectMap, "name", o.Name) @@ -504,7 +504,7 @@ func (o *OperationResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ProxyResource. func (p ProxyResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", p.ID) populate(objectMap, "name", p.Name) populate(objectMap, "type", p.Type) @@ -539,7 +539,7 @@ func (p *ProxyResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RegenerateKeyRequest. func (r RegenerateKeyRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "keyName", r.KeyName) return json.Marshal(objectMap) } @@ -566,7 +566,7 @@ func (r *RegenerateKeyRequest) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Resource. func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", r.ID) populate(objectMap, "name", r.Name) populate(objectMap, "type", r.Type) @@ -601,7 +601,7 @@ func (r *Resource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Server. func (s Server) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", s.ID) populate(objectMap, "identity", s.Identity) populate(objectMap, "location", s.Location) @@ -656,7 +656,7 @@ func (s *Server) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServerKeys. func (s ServerKeys) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "key1", s.Key1) populate(objectMap, "key2", s.Key2) return json.Marshal(objectMap) @@ -687,7 +687,7 @@ func (s *ServerKeys) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServerList. func (s ServerList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "nextLink", s.NextLink) populate(objectMap, "value", s.Value) return json.Marshal(objectMap) @@ -718,7 +718,7 @@ func (s *ServerList) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServerProperties. func (s ServerProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "encryption", s.Encryption) populate(objectMap, "fluidRelayEndpoints", s.FluidRelayEndpoints) populate(objectMap, "frsTenantId", s.FrsTenantID) @@ -761,7 +761,7 @@ func (s *ServerProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServerUpdate. func (s ServerUpdate) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "identity", s.Identity) populate(objectMap, "location", s.Location) populate(objectMap, "properties", s.Properties) @@ -800,7 +800,7 @@ func (s *ServerUpdate) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ServerUpdateProperties. func (s ServerUpdateProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "encryption", s.Encryption) return json.Marshal(objectMap) } @@ -827,7 +827,7 @@ func (s *ServerUpdateProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) @@ -874,7 +874,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type TrackedResource. func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "id", t.ID) populate(objectMap, "location", t.Location) populate(objectMap, "name", t.Name) @@ -917,7 +917,7 @@ func (t *TrackedResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentitiesValue. func (u UserAssignedIdentitiesValue) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) + objectMap := make(map[string]any) populate(objectMap, "clientId", u.ClientID) populate(objectMap, "principalId", u.PrincipalID) return json.Marshal(objectMap) @@ -946,7 +946,7 @@ func (u *UserAssignedIdentitiesValue) UnmarshalJSON(data []byte) error { return nil } -func populate(m map[string]interface{}, k string, v interface{}) { +func populate(m map[string]any, k string, v any) { if v == nil { return } else if azcore.IsNullValue(v) { @@ -956,7 +956,7 @@ func populate(m map[string]interface{}, k string, v interface{}) { } } -func unpopulate(data json.RawMessage, fn string, v interface{}) error { +func unpopulate(data json.RawMessage, fn string, v any) error { if data == nil { return nil } diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/operations_client.go b/sdk/resourcemanager/fluidrelay/armfluidrelay/operations_client.go index 1325c7b63f3e..f8507212eb2c 100644 --- a/sdk/resourcemanager/fluidrelay/armfluidrelay/operations_client.go +++ b/sdk/resourcemanager/fluidrelay/armfluidrelay/operations_client.go @@ -13,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -23,36 +21,27 @@ import ( // OperationsClient contains the methods for the FluidRelayOperations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - List all operations provided by Microsoft.FluidRelay. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-06-01 -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - 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 { @@ -69,7 +58,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -84,7 +73,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.FluidRelay/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/operations_client_example_test.go b/sdk/resourcemanager/fluidrelay/armfluidrelay/operations_client_example_test.go new file mode 100644 index 000000000000..d19e2b3190a6 --- /dev/null +++ b/sdk/resourcemanager/fluidrelay/armfluidrelay/operations_client_example_test.go @@ -0,0 +1,76 @@ +//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 armfluidrelay_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/fluidrelay/armfluidrelay" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/432872fac1d0f8edcae98a0e8504afc0ee302710/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServerOperations.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 := armfluidrelay.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.OperationListResult = armfluidrelay.OperationListResult{ + // Value: []*armfluidrelay.OperationResult{ + // { + // Name: to.Ptr("Microsoft.FluidRelay/fluidRelayServers/Read"), + // Display: &armfluidrelay.OperationDisplay{ + // Description: to.Ptr("Read fluid relay server"), + // Operation: to.Ptr("Get/List fluid relay server resources"), + // Provider: to.Ptr("Microsoft.FluidRelay"), + // Resource: to.Ptr("fluidRelayServers"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.FluidRelay/fluidRelayServers/Write"), + // Display: &armfluidrelay.OperationDisplay{ + // Description: to.Ptr("Write fluid relay server"), + // Operation: to.Ptr("Create/Update fluid relay server resources"), + // Provider: to.Ptr("Microsoft.FluidRelay"), + // Resource: to.Ptr("fluidRelayServers"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.FluidRelay/fluidRelayServers/Delete"), + // Display: &armfluidrelay.OperationDisplay{ + // Description: to.Ptr("Delete fluid relay server"), + // Operation: to.Ptr("Delete fluid relay server resources"), + // Provider: to.Ptr("Microsoft.FluidRelay"), + // Resource: to.Ptr("fluidRelayServers"), + // }, + // IsDataAction: to.Ptr(false), + // }}, + // } + } +} diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/response_types.go b/sdk/resourcemanager/fluidrelay/armfluidrelay/response_types.go index e66dbcc74387..f550eaf53501 100644 --- a/sdk/resourcemanager/fluidrelay/armfluidrelay/response_types.go +++ b/sdk/resourcemanager/fluidrelay/armfluidrelay/response_types.go @@ -19,12 +19,12 @@ type ContainersClientGetResponse struct { Container } -// ContainersClientListByFluidRelayServersResponse contains the response from method ContainersClient.ListByFluidRelayServers. +// ContainersClientListByFluidRelayServersResponse contains the response from method ContainersClient.NewListByFluidRelayServersPager. type ContainersClientListByFluidRelayServersResponse struct { ContainerList } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationListResult } @@ -44,12 +44,12 @@ type ServersClientGetResponse struct { Server } -// ServersClientListByResourceGroupResponse contains the response from method ServersClient.ListByResourceGroup. +// ServersClientListByResourceGroupResponse contains the response from method ServersClient.NewListByResourceGroupPager. type ServersClientListByResourceGroupResponse struct { ServerList } -// ServersClientListBySubscriptionResponse contains the response from method ServersClient.ListBySubscription. +// ServersClientListBySubscriptionResponse contains the response from method ServersClient.NewListBySubscriptionPager. type ServersClientListBySubscriptionResponse struct { ServerList } diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/servers_client.go b/sdk/resourcemanager/fluidrelay/armfluidrelay/servers_client.go index 3e049f6f3d8e..1ff7494dd287 100644 --- a/sdk/resourcemanager/fluidrelay/armfluidrelay/servers_client.go +++ b/sdk/resourcemanager/fluidrelay/armfluidrelay/servers_client.go @@ -14,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,48 +24,40 @@ import ( // ServersClient contains the methods for the FluidRelayServers group. // Don't use this type directly, use NewServersClient() instead. type ServersClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewServersClient creates a new instance of ServersClient with the specified values. -// subscriptionID - The subscription id (GUID) for this resource. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription id (GUID) for this resource. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewServersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ServersClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ServersClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ServersClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Create or Update a Fluid Relay server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-06-01 -// resourceGroup - The resource group containing the resource. -// fluidRelayServerName - The Fluid Relay server resource name. -// resource - The details of the Fluid Relay server resource. -// options - ServersClientCreateOrUpdateOptions contains the optional parameters for the ServersClient.CreateOrUpdate method. +// - resourceGroup - The resource group containing the resource. +// - fluidRelayServerName - The Fluid Relay server resource name. +// - resource - The details of the Fluid Relay server resource. +// - options - ServersClientCreateOrUpdateOptions contains the optional parameters for the ServersClient.CreateOrUpdate method. func (client *ServersClient) CreateOrUpdate(ctx context.Context, resourceGroup string, fluidRelayServerName string, resource Server, options *ServersClientCreateOrUpdateOptions) (ServersClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroup, fluidRelayServerName, resource, options) if err != nil { return ServersClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServersClientCreateOrUpdateResponse{}, err } @@ -92,7 +82,7 @@ func (client *ServersClient) createOrUpdateCreateRequest(ctx context.Context, re return nil, errors.New("parameter fluidRelayServerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{fluidRelayServerName}", url.PathEscape(fluidRelayServerName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -114,16 +104,17 @@ func (client *ServersClient) createOrUpdateHandleResponse(resp *http.Response) ( // Delete - Delete a Fluid Relay server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-06-01 -// resourceGroup - The resource group containing the resource. -// fluidRelayServerName - The Fluid Relay server resource name. -// options - ServersClientDeleteOptions contains the optional parameters for the ServersClient.Delete method. +// - resourceGroup - The resource group containing the resource. +// - fluidRelayServerName - The Fluid Relay server resource name. +// - options - ServersClientDeleteOptions contains the optional parameters for the ServersClient.Delete method. func (client *ServersClient) Delete(ctx context.Context, resourceGroup string, fluidRelayServerName string, options *ServersClientDeleteOptions) (ServersClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroup, fluidRelayServerName, options) if err != nil { return ServersClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServersClientDeleteResponse{}, err } @@ -148,7 +139,7 @@ func (client *ServersClient) deleteCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter fluidRelayServerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{fluidRelayServerName}", url.PathEscape(fluidRelayServerName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -161,16 +152,17 @@ func (client *ServersClient) deleteCreateRequest(ctx context.Context, resourceGr // Get - Get a Fluid Relay server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-06-01 -// resourceGroup - The resource group containing the resource. -// fluidRelayServerName - The Fluid Relay server resource name. -// options - ServersClientGetOptions contains the optional parameters for the ServersClient.Get method. +// - resourceGroup - The resource group containing the resource. +// - fluidRelayServerName - The Fluid Relay server resource name. +// - options - ServersClientGetOptions contains the optional parameters for the ServersClient.Get method. func (client *ServersClient) Get(ctx context.Context, resourceGroup string, fluidRelayServerName string, options *ServersClientGetOptions) (ServersClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroup, fluidRelayServerName, options) if err != nil { return ServersClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServersClientGetResponse{}, err } @@ -195,7 +187,7 @@ func (client *ServersClient) getCreateRequest(ctx context.Context, resourceGroup return nil, errors.New("parameter fluidRelayServerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{fluidRelayServerName}", url.PathEscape(fluidRelayServerName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -216,11 +208,11 @@ func (client *ServersClient) getHandleResponse(resp *http.Response) (ServersClie } // NewListByResourceGroupPager - List all Fluid Relay servers in a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-06-01 -// resourceGroup - The resource group containing the resource. -// options - ServersClientListByResourceGroupOptions contains the optional parameters for the ServersClient.ListByResourceGroup -// method. +// - resourceGroup - The resource group containing the resource. +// - options - ServersClientListByResourceGroupOptions contains the optional parameters for the ServersClient.NewListByResourceGroupPager +// method. func (client *ServersClient) NewListByResourceGroupPager(resourceGroup string, options *ServersClientListByResourceGroupOptions) *runtime.Pager[ServersClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[ServersClientListByResourceGroupResponse]{ More: func(page ServersClientListByResourceGroupResponse) bool { @@ -237,7 +229,7 @@ func (client *ServersClient) NewListByResourceGroupPager(resourceGroup string, o if err != nil { return ServersClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServersClientListByResourceGroupResponse{}, err } @@ -260,7 +252,7 @@ func (client *ServersClient) listByResourceGroupCreateRequest(ctx context.Contex return nil, errors.New("parameter resourceGroup cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroup}", url.PathEscape(resourceGroup)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -281,10 +273,10 @@ func (client *ServersClient) listByResourceGroupHandleResponse(resp *http.Respon } // NewListBySubscriptionPager - List all Fluid Relay servers in a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-06-01 -// options - ServersClientListBySubscriptionOptions contains the optional parameters for the ServersClient.ListBySubscription -// method. +// - options - ServersClientListBySubscriptionOptions contains the optional parameters for the ServersClient.NewListBySubscriptionPager +// method. func (client *ServersClient) NewListBySubscriptionPager(options *ServersClientListBySubscriptionOptions) *runtime.Pager[ServersClientListBySubscriptionResponse] { return runtime.NewPager(runtime.PagingHandler[ServersClientListBySubscriptionResponse]{ More: func(page ServersClientListBySubscriptionResponse) bool { @@ -301,7 +293,7 @@ func (client *ServersClient) NewListBySubscriptionPager(options *ServersClientLi if err != nil { return ServersClientListBySubscriptionResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServersClientListBySubscriptionResponse{}, err } @@ -320,7 +312,7 @@ func (client *ServersClient) listBySubscriptionCreateRequest(ctx context.Context return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -342,16 +334,17 @@ func (client *ServersClient) listBySubscriptionHandleResponse(resp *http.Respons // ListKeys - Get primary and secondary key for this server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-06-01 -// resourceGroup - The resource group containing the resource. -// fluidRelayServerName - The Fluid Relay server resource name. -// options - ServersClientListKeysOptions contains the optional parameters for the ServersClient.ListKeys method. +// - resourceGroup - The resource group containing the resource. +// - fluidRelayServerName - The Fluid Relay server resource name. +// - options - ServersClientListKeysOptions contains the optional parameters for the ServersClient.ListKeys method. func (client *ServersClient) ListKeys(ctx context.Context, resourceGroup string, fluidRelayServerName string, options *ServersClientListKeysOptions) (ServersClientListKeysResponse, error) { req, err := client.listKeysCreateRequest(ctx, resourceGroup, fluidRelayServerName, options) if err != nil { return ServersClientListKeysResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServersClientListKeysResponse{}, err } @@ -376,7 +369,7 @@ func (client *ServersClient) listKeysCreateRequest(ctx context.Context, resource return nil, errors.New("parameter fluidRelayServerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{fluidRelayServerName}", url.PathEscape(fluidRelayServerName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -398,17 +391,18 @@ func (client *ServersClient) listKeysHandleResponse(resp *http.Response) (Server // RegenerateKey - Regenerate the primary or secondary key for this server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-06-01 -// resourceGroup - The resource group containing the resource. -// fluidRelayServerName - The Fluid Relay server resource name. -// parameters - The details of which keys to generate. -// options - ServersClientRegenerateKeyOptions contains the optional parameters for the ServersClient.RegenerateKey method. +// - resourceGroup - The resource group containing the resource. +// - fluidRelayServerName - The Fluid Relay server resource name. +// - parameters - The details of which keys to generate. +// - options - ServersClientRegenerateKeyOptions contains the optional parameters for the ServersClient.RegenerateKey method. func (client *ServersClient) RegenerateKey(ctx context.Context, resourceGroup string, fluidRelayServerName string, parameters RegenerateKeyRequest, options *ServersClientRegenerateKeyOptions) (ServersClientRegenerateKeyResponse, error) { req, err := client.regenerateKeyCreateRequest(ctx, resourceGroup, fluidRelayServerName, parameters, options) if err != nil { return ServersClientRegenerateKeyResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServersClientRegenerateKeyResponse{}, err } @@ -433,7 +427,7 @@ func (client *ServersClient) regenerateKeyCreateRequest(ctx context.Context, res return nil, errors.New("parameter fluidRelayServerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{fluidRelayServerName}", url.PathEscape(fluidRelayServerName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -455,17 +449,18 @@ func (client *ServersClient) regenerateKeyHandleResponse(resp *http.Response) (S // Update - Update a Fluid Relay server. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-06-01 -// resourceGroup - The resource group containing the resource. -// fluidRelayServerName - The Fluid Relay server resource name. -// resource - The details of the Fluid Relay server resource included in update calls. -// options - ServersClientUpdateOptions contains the optional parameters for the ServersClient.Update method. +// - resourceGroup - The resource group containing the resource. +// - fluidRelayServerName - The Fluid Relay server resource name. +// - resource - The details of the Fluid Relay server resource included in update calls. +// - options - ServersClientUpdateOptions contains the optional parameters for the ServersClient.Update method. func (client *ServersClient) Update(ctx context.Context, resourceGroup string, fluidRelayServerName string, resource ServerUpdate, options *ServersClientUpdateOptions) (ServersClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroup, fluidRelayServerName, resource, options) if err != nil { return ServersClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ServersClientUpdateResponse{}, err } @@ -490,7 +485,7 @@ func (client *ServersClient) updateCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter fluidRelayServerName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{fluidRelayServerName}", url.PathEscape(fluidRelayServerName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/servers_client_example_test.go b/sdk/resourcemanager/fluidrelay/armfluidrelay/servers_client_example_test.go new file mode 100644 index 000000000000..3b90bff408b6 --- /dev/null +++ b/sdk/resourcemanager/fluidrelay/armfluidrelay/servers_client_example_test.go @@ -0,0 +1,464 @@ +//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 armfluidrelay_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/fluidrelay/armfluidrelay" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/432872fac1d0f8edcae98a0e8504afc0ee302710/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_Get.json +func ExampleServersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfluidrelay.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServersClient().Get(ctx, "myResourceGroup", "myFluidRelayServer", 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.Server = armfluidrelay.Server{ + // Name: to.Ptr("myFluidRelayServer"), + // Type: to.Ptr("Microsoft.FluidRelay/fluidRelayServers"), + // ID: to.Ptr("/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/Microsoft.FluidRelay/fluidRelayServers/myFluidRelayServer"), + // Location: to.Ptr("west-us"), + // Properties: &armfluidrelay.ServerProperties{ + // FluidRelayEndpoints: &armfluidrelay.Endpoints{ + // OrdererEndpoints: []*string{ + // to.Ptr("https://www.contoso.org/orderer")}, + // ServiceEndpoints: []*string{ + // to.Ptr("https://www.afd.contoso.org")}, + // StorageEndpoints: []*string{ + // to.Ptr("https://www.contoso.org/storage")}, + // }, + // FrsTenantID: to.Ptr("yyyy-yyyy-yyyyy-yyyy"), + // ProvisioningState: to.Ptr(armfluidrelay.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/432872fac1d0f8edcae98a0e8504afc0ee302710/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_CreateOrUpdate.json +func ExampleServersClient_CreateOrUpdate_createAFluidRelayServer() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfluidrelay.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServersClient().CreateOrUpdate(ctx, "myResourceGroup", "myFluidRelayServer", armfluidrelay.Server{ + Location: to.Ptr("west-us"), + Tags: map[string]*string{ + "Category": to.Ptr("sales"), + }, + Identity: &armfluidrelay.Identity{ + Type: to.Ptr(armfluidrelay.ResourceIdentityTypeSystemAssigned), + }, + Properties: &armfluidrelay.ServerProperties{ + Storagesku: to.Ptr(armfluidrelay.StorageSKUBasic), + }, + }, 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.Server = armfluidrelay.Server{ + // Name: to.Ptr("myFluidRelayServer"), + // Type: to.Ptr("Microsoft.FluidRelay/fluidRelayServers"), + // ID: to.Ptr("/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/Microsoft.FluidRelay/fluidRelayServers/myFluidRelayServer"), + // Location: to.Ptr("west-us"), + // Identity: &armfluidrelay.Identity{ + // Type: to.Ptr(armfluidrelay.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Properties: &armfluidrelay.ServerProperties{ + // FluidRelayEndpoints: &armfluidrelay.Endpoints{ + // OrdererEndpoints: []*string{ + // to.Ptr("https://www.contoso.org/orderer")}, + // ServiceEndpoints: []*string{ + // to.Ptr("https://www.afd.contoso.org")}, + // StorageEndpoints: []*string{ + // to.Ptr("https://www.contoso.org/storage")}, + // }, + // FrsTenantID: to.Ptr("yyyy-yyyy-yyyyy-yyyy"), + // ProvisioningState: to.Ptr(armfluidrelay.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/432872fac1d0f8edcae98a0e8504afc0ee302710/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_CreateWithAmi.json +func ExampleServersClient_CreateOrUpdate_createAFluidRelayServerWithAmi() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfluidrelay.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServersClient().CreateOrUpdate(ctx, "myResourceGroup", "myFluidRelayServer", armfluidrelay.Server{ + Location: to.Ptr("west-us"), + Tags: map[string]*string{ + "Category": to.Ptr("sales"), + }, + Identity: &armfluidrelay.Identity{ + Type: to.Ptr(armfluidrelay.ResourceIdentityTypeSystemAssignedUserAssigned), + UserAssignedIdentities: map[string]*armfluidrelay.UserAssignedIdentitiesValue{ + "/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {}, + "/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2": {}, + }, + }, + Properties: &armfluidrelay.ServerProperties{ + Storagesku: to.Ptr(armfluidrelay.StorageSKUBasic), + }, + }, 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.Server = armfluidrelay.Server{ + // Name: to.Ptr("myFluidRelayServer"), + // Type: to.Ptr("Microsoft.FluidRelay/fluidRelayServers"), + // ID: to.Ptr("/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/Microsoft.FluidRelay/fluidRelayServers/myFluidRelayServer"), + // Location: to.Ptr("west-us"), + // Identity: &armfluidrelay.Identity{ + // Type: to.Ptr(armfluidrelay.ResourceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // UserAssignedIdentities: map[string]*armfluidrelay.UserAssignedIdentitiesValue{ + // "/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armfluidrelay.UserAssignedIdentitiesValue{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // "/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2": &armfluidrelay.UserAssignedIdentitiesValue{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Properties: &armfluidrelay.ServerProperties{ + // FluidRelayEndpoints: &armfluidrelay.Endpoints{ + // OrdererEndpoints: []*string{ + // to.Ptr("https://www.contoso.org/orderer")}, + // ServiceEndpoints: []*string{ + // to.Ptr("https://www.afd.contoso.org")}, + // StorageEndpoints: []*string{ + // to.Ptr("https://www.contoso.org/storage")}, + // }, + // FrsTenantID: to.Ptr("yyyy-yyyy-yyyyy-yyyy"), + // ProvisioningState: to.Ptr(armfluidrelay.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/432872fac1d0f8edcae98a0e8504afc0ee302710/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_CreateWithCmk.json +func ExampleServersClient_CreateOrUpdate_createAFluidRelayServerWithCmk() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfluidrelay.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServersClient().CreateOrUpdate(ctx, "myResourceGroup", "myFluidRelayServer", armfluidrelay.Server{ + Location: to.Ptr("west-us"), + Tags: map[string]*string{ + "Category": to.Ptr("sales"), + }, + Identity: &armfluidrelay.Identity{ + Type: to.Ptr(armfluidrelay.ResourceIdentityTypeUserAssigned), + UserAssignedIdentities: map[string]*armfluidrelay.UserAssignedIdentitiesValue{ + "/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityForCMK": {}, + }, + }, + Properties: &armfluidrelay.ServerProperties{ + Encryption: &armfluidrelay.EncryptionProperties{ + CustomerManagedKeyEncryption: &armfluidrelay.CustomerManagedKeyEncryptionProperties{ + KeyEncryptionKeyIdentity: &armfluidrelay.CustomerManagedKeyEncryptionPropertiesKeyEncryptionKeyIdentity{ + IdentityType: to.Ptr(armfluidrelay.CmkIdentityTypeUserAssigned), + UserAssignedIdentityResourceID: to.Ptr("/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityForCMK"), + }, + KeyEncryptionKeyURL: to.Ptr("https://contosovault.vault.azure.net/keys/contosokek"), + }, + }, + Storagesku: to.Ptr(armfluidrelay.StorageSKUBasic), + }, + }, 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.Server = armfluidrelay.Server{ + // Name: to.Ptr("myFluidRelayServer"), + // Type: to.Ptr("Microsoft.FluidRelay/fluidRelayServers"), + // ID: to.Ptr("/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/Microsoft.FluidRelay/fluidRelayServers/myFluidRelayServer"), + // Location: to.Ptr("west-us"), + // Identity: &armfluidrelay.Identity{ + // Type: to.Ptr(armfluidrelay.ResourceIdentityTypeUserAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // UserAssignedIdentities: map[string]*armfluidrelay.UserAssignedIdentitiesValue{ + // "/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityForCMK": &armfluidrelay.UserAssignedIdentitiesValue{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Properties: &armfluidrelay.ServerProperties{ + // Encryption: &armfluidrelay.EncryptionProperties{ + // CustomerManagedKeyEncryption: &armfluidrelay.CustomerManagedKeyEncryptionProperties{ + // KeyEncryptionKeyIdentity: &armfluidrelay.CustomerManagedKeyEncryptionPropertiesKeyEncryptionKeyIdentity{ + // IdentityType: to.Ptr(armfluidrelay.CmkIdentityTypeUserAssigned), + // UserAssignedIdentityResourceID: to.Ptr("/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityForCMK"), + // }, + // KeyEncryptionKeyURL: to.Ptr("https://contosovault.vault.azure.net/keys/contosokek"), + // }, + // }, + // FluidRelayEndpoints: &armfluidrelay.Endpoints{ + // OrdererEndpoints: []*string{ + // to.Ptr("https://www.contoso.org/orderer")}, + // ServiceEndpoints: []*string{ + // to.Ptr("https://www.afd.contoso.org")}, + // StorageEndpoints: []*string{ + // to.Ptr("https://www.contoso.org/storage")}, + // }, + // FrsTenantID: to.Ptr("yyyy-yyyy-yyyyy-yyyy"), + // ProvisioningState: to.Ptr(armfluidrelay.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/432872fac1d0f8edcae98a0e8504afc0ee302710/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_Update.json +func ExampleServersClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfluidrelay.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServersClient().Update(ctx, "myResourceGroup", "myFluidRelayServer", armfluidrelay.ServerUpdate{ + Tags: map[string]*string{ + "Category": to.Ptr("sales"), + }, + }, 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.Server = armfluidrelay.Server{ + // Name: to.Ptr("myFluidRelayServer"), + // Type: to.Ptr("Microsoft.FluidRelay/fluidRelayServers"), + // ID: to.Ptr("/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/Microsoft.FluidRelay/fluidRelayServers/myFluidRelayServer"), + // Location: to.Ptr("west-us"), + // Tags: map[string]*string{ + // "Category": to.Ptr("sales"), + // }, + // Properties: &armfluidrelay.ServerProperties{ + // FluidRelayEndpoints: &armfluidrelay.Endpoints{ + // OrdererEndpoints: []*string{ + // to.Ptr("https://www.contoso.org/orderer")}, + // ServiceEndpoints: []*string{ + // to.Ptr("https://www.afd.contoso.org")}, + // StorageEndpoints: []*string{ + // to.Ptr("https://www.contoso.org/storage")}, + // }, + // FrsTenantID: to.Ptr("yyyy-yyyy-yyyyy-yyyy"), + // ProvisioningState: to.Ptr(armfluidrelay.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/432872fac1d0f8edcae98a0e8504afc0ee302710/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_Delete.json +func ExampleServersClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfluidrelay.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewServersClient().Delete(ctx, "myResourceGroup", "myFluidRelayServer", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/432872fac1d0f8edcae98a0e8504afc0ee302710/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_RegenerateKeys.json +func ExampleServersClient_RegenerateKey() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfluidrelay.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServersClient().RegenerateKey(ctx, "myResourceGroup", "myFluidRelayServer", armfluidrelay.RegenerateKeyRequest{ + KeyName: to.Ptr(armfluidrelay.KeyNameKey1), + }, 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.ServerKeys = armfluidrelay.ServerKeys{ + // Key1: to.Ptr("xxx-xxxx-xxxxx-xxxx"), + // Key2: to.Ptr("yyy-yyyy-yyyyy-yyyy"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/432872fac1d0f8edcae98a0e8504afc0ee302710/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_ListKeys.json +func ExampleServersClient_ListKeys() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfluidrelay.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewServersClient().ListKeys(ctx, "myResourceGroup", "myFluidRelayServer", 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.ServerKeys = armfluidrelay.ServerKeys{ + // Key1: to.Ptr("xxx-xxxx-xxxxx-xxxx"), + // Key2: to.Ptr("yyy-yyyy-yyyyy-yyyy"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/432872fac1d0f8edcae98a0e8504afc0ee302710/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_ListBySubscription.json +func ExampleServersClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfluidrelay.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewServersClient().NewListBySubscriptionPager(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.ServerList = armfluidrelay.ServerList{ + // Value: []*armfluidrelay.Server{ + // { + // Name: to.Ptr("myFluidRelayServer"), + // Type: to.Ptr("Microsoft.FluidRelay/fluidRelayServers"), + // ID: to.Ptr("/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/Microsoft.FluidRelay/fluidRelayServers/myFluidRelayServer"), + // Location: to.Ptr("west-us"), + // Properties: &armfluidrelay.ServerProperties{ + // FluidRelayEndpoints: &armfluidrelay.Endpoints{ + // OrdererEndpoints: []*string{ + // to.Ptr("https://www.contoso.org/orderer")}, + // ServiceEndpoints: []*string{ + // to.Ptr("https://www.afd.contoso.org")}, + // StorageEndpoints: []*string{ + // to.Ptr("https://www.contoso.org/storage")}, + // }, + // FrsTenantID: to.Ptr("yyyy-yyyy-yyyyy-yyyy"), + // ProvisioningState: to.Ptr(armfluidrelay.ProvisioningStateSucceeded), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/432872fac1d0f8edcae98a0e8504afc0ee302710/specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_ListByResourceGroup.json +func ExampleServersClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfluidrelay.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewServersClient().NewListByResourceGroupPager("myResourceGroup", 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.ServerList = armfluidrelay.ServerList{ + // Value: []*armfluidrelay.Server{ + // { + // Name: to.Ptr("myFluidRelayServer"), + // Type: to.Ptr("Microsoft.FluidRelay/fluidRelayServers"), + // ID: to.Ptr("/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/Microsoft.FluidRelay/fluidRelayServers/myFluidRelayServer"), + // Location: to.Ptr("west-us"), + // Properties: &armfluidrelay.ServerProperties{ + // FluidRelayEndpoints: &armfluidrelay.Endpoints{ + // OrdererEndpoints: []*string{ + // to.Ptr("https://www.contoso.org/orderer")}, + // ServiceEndpoints: []*string{ + // to.Ptr("https://www.afd.contoso.org")}, + // StorageEndpoints: []*string{ + // to.Ptr("https://www.contoso.org/storage")}, + // }, + // FrsTenantID: to.Ptr("yyyy-yyyy-yyyyy-yyyy"), + // ProvisioningState: to.Ptr(armfluidrelay.ProvisioningStateSucceeded), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/fluidrelay/armfluidrelay/time_rfc3339.go b/sdk/resourcemanager/fluidrelay/armfluidrelay/time_rfc3339.go index 5c2e817ba062..99d21ba2cd59 100644 --- a/sdk/resourcemanager/fluidrelay/armfluidrelay/time_rfc3339.go +++ b/sdk/resourcemanager/fluidrelay/armfluidrelay/time_rfc3339.go @@ -62,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/CHANGELOG.md b/sdk/resourcemanager/frontdoor/armfrontdoor/CHANGELOG.md index e13b1c9f70d8..7a2db9e5bbc4 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/CHANGELOG.md +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2022-05-18) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/frontdoor/armfrontdoor` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 1.0.0, which contains breaking changes. diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/README.md b/sdk/resourcemanager/frontdoor/armfrontdoor/README.md index 3beb544851f6..92ca8230d649 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/README.md +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Front Door modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Front Door module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armfrontdoor.NewFrontDoorsClient(, cred, nil) +clientFactory, err := armfrontdoor.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armfrontdoor.NewFrontDoorsClient(, cred, &options) +clientFactory, err := armfrontdoor.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewFrontDoorsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/autorest.md b/sdk/resourcemanager/frontdoor/armfrontdoor/autorest.md index 3bce7b5adbc6..230e37eb21b8 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/autorest.md +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 1.1.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/client_factory.go b/sdk/resourcemanager/frontdoor/armfrontdoor/client_factory.go new file mode 100644 index 000000000000..9a79dfcc8c32 --- /dev/null +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/client_factory.go @@ -0,0 +1,100 @@ +//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 armfrontdoor + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription +// ID forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewNetworkExperimentProfilesClient() *NetworkExperimentProfilesClient { + subClient, _ := NewNetworkExperimentProfilesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPreconfiguredEndpointsClient() *PreconfiguredEndpointsClient { + subClient, _ := NewPreconfiguredEndpointsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewExperimentsClient() *ExperimentsClient { + subClient, _ := NewExperimentsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewReportsClient() *ReportsClient { + subClient, _ := NewReportsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewNameAvailabilityClient() *NameAvailabilityClient { + subClient, _ := NewNameAvailabilityClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewNameAvailabilityWithSubscriptionClient() *NameAvailabilityWithSubscriptionClient { + subClient, _ := NewNameAvailabilityWithSubscriptionClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewFrontDoorsClient() *FrontDoorsClient { + subClient, _ := NewFrontDoorsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewFrontendEndpointsClient() *FrontendEndpointsClient { + subClient, _ := NewFrontendEndpointsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewEndpointsClient() *EndpointsClient { + subClient, _ := NewEndpointsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewRulesEnginesClient() *RulesEnginesClient { + subClient, _ := NewRulesEnginesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPoliciesClient() *PoliciesClient { + subClient, _ := NewPoliciesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewManagedRuleSetsClient() *ManagedRuleSetsClient { + subClient, _ := NewManagedRuleSetsClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_constants.go b/sdk/resourcemanager/frontdoor/armfrontdoor/constants.go similarity index 99% rename from sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_constants.go rename to sdk/resourcemanager/frontdoor/armfrontdoor/constants.go index 9f6f3aed1329..d108cb0e2f51 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_constants.go +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/constants.go @@ -5,12 +5,13 @@ // 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 armfrontdoor const ( moduleName = "armfrontdoor" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // ActionType - Defines the action to take on rule match. diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_endpoints_client.go b/sdk/resourcemanager/frontdoor/armfrontdoor/endpoints_client.go similarity index 71% rename from sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_endpoints_client.go rename to sdk/resourcemanager/frontdoor/armfrontdoor/endpoints_client.go index 85f6e3655e1b..c08b6b21386c 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_endpoints_client.go +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/endpoints_client.go @@ -5,6 +5,7 @@ // 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 armfrontdoor @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,69 +24,62 @@ import ( // EndpointsClient contains the methods for the Endpoints group. // Don't use this type directly, use NewEndpointsClient() instead. type EndpointsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewEndpointsClient creates a new instance of EndpointsClient with the specified values. -// subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription -// ID forms part of the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription +// ID forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewEndpointsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EndpointsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".EndpointsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &EndpointsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginPurgeContent - Removes a content from Front Door. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// frontDoorName - Name of the Front Door which is globally unique. -// contentFilePaths - The path to the content to be purged. Path can be a full URL, e.g. '/pictures/city.png' which removes -// a single file, or a directory with a wildcard, e.g. '/pictures/*' which removes all folders and -// files in the directory. -// options - EndpointsClientBeginPurgeContentOptions contains the optional parameters for the EndpointsClient.BeginPurgeContent -// method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - frontDoorName - Name of the Front Door which is globally unique. +// - contentFilePaths - The path to the content to be purged. Path can be a full URL, e.g. '/pictures/city.png' which removes +// a single file, or a directory with a wildcard, e.g. '/pictures/*' which removes all folders and +// files in the directory. +// - options - EndpointsClientBeginPurgeContentOptions contains the optional parameters for the EndpointsClient.BeginPurgeContent +// method. func (client *EndpointsClient) BeginPurgeContent(ctx context.Context, resourceGroupName string, frontDoorName string, contentFilePaths PurgeParameters, options *EndpointsClientBeginPurgeContentOptions) (*runtime.Poller[EndpointsClientPurgeContentResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.purgeContent(ctx, resourceGroupName, frontDoorName, contentFilePaths, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[EndpointsClientPurgeContentResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[EndpointsClientPurgeContentResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[EndpointsClientPurgeContentResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[EndpointsClientPurgeContentResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // PurgeContent - Removes a content from Front Door. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 func (client *EndpointsClient) purgeContent(ctx context.Context, resourceGroupName string, frontDoorName string, contentFilePaths PurgeParameters, options *EndpointsClientBeginPurgeContentOptions) (*http.Response, error) { req, err := client.purgeContentCreateRequest(ctx, resourceGroupName, frontDoorName, contentFilePaths, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -112,7 +104,7 @@ func (client *EndpointsClient) purgeContentCreateRequest(ctx context.Context, re return nil, errors.New("parameter frontDoorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{frontDoorName}", url.PathEscape(frontDoorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_endpoints_client_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/endpoints_client_example_test.go similarity index 69% rename from sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_endpoints_client_test.go rename to sdk/resourcemanager/frontdoor/armfrontdoor/endpoints_client_example_test.go index 8022dc8b52fb..02cbd1a7966c 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_endpoints_client_test.go +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/endpoints_client_example_test.go @@ -5,6 +5,7 @@ // 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 armfrontdoor_test @@ -17,26 +18,22 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/frontdoor/armfrontdoor" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorPurgeContent.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorPurgeContent.json func ExampleEndpointsClient_BeginPurgeContent() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) } ctx := context.Background() - client, err := armfrontdoor.NewEndpointsClient("subid", cred, nil) + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginPurgeContent(ctx, - "rg1", - "frontDoor1", - armfrontdoor.PurgeParameters{ - ContentPaths: []*string{ - to.Ptr("/pictures.aspx"), - to.Ptr("/pictures/*")}, - }, - nil) + poller, err := clientFactory.NewEndpointsClient().BeginPurgeContent(ctx, "rg1", "frontDoor1", armfrontdoor.PurgeParameters{ + ContentPaths: []*string{ + to.Ptr("/pictures.aspx"), + to.Ptr("/pictures/*")}, + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_experiments_client.go b/sdk/resourcemanager/frontdoor/armfrontdoor/experiments_client.go similarity index 82% rename from sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_experiments_client.go rename to sdk/resourcemanager/frontdoor/armfrontdoor/experiments_client.go index a18c5192e3f3..9e32d8561bfe 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_experiments_client.go +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/experiments_client.go @@ -5,6 +5,7 @@ // 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 armfrontdoor @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,66 +24,59 @@ import ( // ExperimentsClient contains the methods for the Experiments group. // Don't use this type directly, use NewExperimentsClient() instead. type ExperimentsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewExperimentsClient creates a new instance of ExperimentsClient with the specified values. -// subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription -// ID forms part of the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription +// ID forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewExperimentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExperimentsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ExperimentsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ExperimentsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates or updates an Experiment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// profileName - The Profile identifier associated with the Tenant and Partner -// experimentName - The Experiment identifier associated with the Experiment -// parameters - The Experiment resource -// options - ExperimentsClientBeginCreateOrUpdateOptions contains the optional parameters for the ExperimentsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - profileName - The Profile identifier associated with the Tenant and Partner +// - experimentName - The Experiment identifier associated with the Experiment +// - parameters - The Experiment resource +// - options - ExperimentsClientBeginCreateOrUpdateOptions contains the optional parameters for the ExperimentsClient.BeginCreateOrUpdate +// method. func (client *ExperimentsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, profileName string, experimentName string, parameters Experiment, options *ExperimentsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ExperimentsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, profileName, experimentName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[ExperimentsClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[ExperimentsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ExperimentsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ExperimentsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates or updates an Experiment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 func (client *ExperimentsClient) createOrUpdate(ctx context.Context, resourceGroupName string, profileName string, experimentName string, parameters Experiment, options *ExperimentsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, profileName, experimentName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -113,7 +105,7 @@ func (client *ExperimentsClient) createOrUpdateCreateRequest(ctx context.Context return nil, errors.New("parameter experimentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -126,32 +118,34 @@ func (client *ExperimentsClient) createOrUpdateCreateRequest(ctx context.Context // BeginDelete - Deletes an Experiment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// profileName - The Profile identifier associated with the Tenant and Partner -// experimentName - The Experiment identifier associated with the Experiment -// options - ExperimentsClientBeginDeleteOptions contains the optional parameters for the ExperimentsClient.BeginDelete method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - profileName - The Profile identifier associated with the Tenant and Partner +// - experimentName - The Experiment identifier associated with the Experiment +// - options - ExperimentsClientBeginDeleteOptions contains the optional parameters for the ExperimentsClient.BeginDelete method. func (client *ExperimentsClient) BeginDelete(ctx context.Context, resourceGroupName string, profileName string, experimentName string, options *ExperimentsClientBeginDeleteOptions) (*runtime.Poller[ExperimentsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, profileName, experimentName, options) if err != nil { return nil, err } - return runtime.NewPoller[ExperimentsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[ExperimentsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ExperimentsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ExperimentsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes an Experiment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 func (client *ExperimentsClient) deleteOperation(ctx context.Context, resourceGroupName string, profileName string, experimentName string, options *ExperimentsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, profileName, experimentName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -180,7 +174,7 @@ func (client *ExperimentsClient) deleteCreateRequest(ctx context.Context, resour return nil, errors.New("parameter experimentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -193,17 +187,18 @@ func (client *ExperimentsClient) deleteCreateRequest(ctx context.Context, resour // Get - Gets an Experiment by ExperimentName // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// profileName - The Profile identifier associated with the Tenant and Partner -// experimentName - The Experiment identifier associated with the Experiment -// options - ExperimentsClientGetOptions contains the optional parameters for the ExperimentsClient.Get method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - profileName - The Profile identifier associated with the Tenant and Partner +// - experimentName - The Experiment identifier associated with the Experiment +// - options - ExperimentsClientGetOptions contains the optional parameters for the ExperimentsClient.Get method. func (client *ExperimentsClient) Get(ctx context.Context, resourceGroupName string, profileName string, experimentName string, options *ExperimentsClientGetOptions) (ExperimentsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, profileName, experimentName, options) if err != nil { return ExperimentsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExperimentsClientGetResponse{}, err } @@ -232,7 +227,7 @@ func (client *ExperimentsClient) getCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter experimentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -253,12 +248,12 @@ func (client *ExperimentsClient) getHandleResponse(resp *http.Response) (Experim } // NewListByProfilePager - Gets a list of Experiments -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// profileName - The Profile identifier associated with the Tenant and Partner -// options - ExperimentsClientListByProfileOptions contains the optional parameters for the ExperimentsClient.ListByProfile -// method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - profileName - The Profile identifier associated with the Tenant and Partner +// - options - ExperimentsClientListByProfileOptions contains the optional parameters for the ExperimentsClient.NewListByProfilePager +// method. func (client *ExperimentsClient) NewListByProfilePager(resourceGroupName string, profileName string, options *ExperimentsClientListByProfileOptions) *runtime.Pager[ExperimentsClientListByProfileResponse] { return runtime.NewPager(runtime.PagingHandler[ExperimentsClientListByProfileResponse]{ More: func(page ExperimentsClientListByProfileResponse) bool { @@ -275,7 +270,7 @@ func (client *ExperimentsClient) NewListByProfilePager(resourceGroupName string, if err != nil { return ExperimentsClientListByProfileResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ExperimentsClientListByProfileResponse{}, err } @@ -302,7 +297,7 @@ func (client *ExperimentsClient) listByProfileCreateRequest(ctx context.Context, return nil, errors.New("parameter profileName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{profileName}", url.PathEscape(profileName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -324,33 +319,35 @@ func (client *ExperimentsClient) listByProfileHandleResponse(resp *http.Response // BeginUpdate - Updates an Experiment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// profileName - The Profile identifier associated with the Tenant and Partner -// experimentName - The Experiment identifier associated with the Experiment -// parameters - The Experiment Update Model -// options - ExperimentsClientBeginUpdateOptions contains the optional parameters for the ExperimentsClient.BeginUpdate method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - profileName - The Profile identifier associated with the Tenant and Partner +// - experimentName - The Experiment identifier associated with the Experiment +// - parameters - The Experiment Update Model +// - options - ExperimentsClientBeginUpdateOptions contains the optional parameters for the ExperimentsClient.BeginUpdate method. func (client *ExperimentsClient) BeginUpdate(ctx context.Context, resourceGroupName string, profileName string, experimentName string, parameters ExperimentUpdateModel, options *ExperimentsClientBeginUpdateOptions) (*runtime.Poller[ExperimentsClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, profileName, experimentName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[ExperimentsClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[ExperimentsClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ExperimentsClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ExperimentsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates an Experiment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 func (client *ExperimentsClient) update(ctx context.Context, resourceGroupName string, profileName string, experimentName string, parameters ExperimentUpdateModel, options *ExperimentsClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, profileName, experimentName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -379,7 +376,7 @@ func (client *ExperimentsClient) updateCreateRequest(ctx context.Context, resour return nil, errors.New("parameter experimentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/experiments_client_example_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/experiments_client_example_test.go new file mode 100644 index 000000000000..f18bb24644a3 --- /dev/null +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/experiments_client_example_test.go @@ -0,0 +1,246 @@ +//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 armfrontdoor_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/frontdoor/armfrontdoor" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentListExperiments.json +func ExampleExperimentsClient_NewListByProfilePager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewExperimentsClient().NewListByProfilePager("MyResourceGroup", "MyProfile", 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.ExperimentList = armfrontdoor.ExperimentList{ + // Value: []*armfrontdoor.Experiment{ + // { + // Name: to.Ptr("MyExperiment"), + // ID: to.Ptr("/subscriptions/subId/resourceGroups/MyResourceGroup/providers/Microsoft.Network/NetworkExperimentProfiles/MyProfile/Experiments"), + // Properties: &armfrontdoor.ExperimentProperties{ + // Description: to.Ptr("this is my first experiment!"), + // EnabledState: to.Ptr(armfrontdoor.StateEnabled), + // EndpointA: &armfrontdoor.Endpoint{ + // Name: to.Ptr("endpoint A"), + // Endpoint: to.Ptr("endpointA.net"), + // }, + // EndpointB: &armfrontdoor.Endpoint{ + // Name: to.Ptr("endpoint B"), + // Endpoint: to.Ptr("endpointB.net"), + // }, + // ResourceState: to.Ptr(armfrontdoor.NetworkExperimentResourceStateCreating), + // ScriptFileURI: to.Ptr("www.myScript.com"), + // Status: to.Ptr("ongoing"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentGetExperiment.json +func ExampleExperimentsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewExperimentsClient().Get(ctx, "MyResourceGroup", "MyProfile", "MyExperiment", 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.Experiment = armfrontdoor.Experiment{ + // Name: to.Ptr("MyExperiment"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/MyResourceGroup/providers/Microsoft.Network/NetworkExperimentProfiles/MyProfile/Experiments/MyExperiment"), + // Location: to.Ptr("WestUs"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armfrontdoor.ExperimentProperties{ + // Description: to.Ptr("this is my first experiment!"), + // EnabledState: to.Ptr(armfrontdoor.StateEnabled), + // EndpointA: &armfrontdoor.Endpoint{ + // Name: to.Ptr("endpoint A"), + // Endpoint: to.Ptr("endpointA.net"), + // }, + // EndpointB: &armfrontdoor.Endpoint{ + // Name: to.Ptr("endpoint B"), + // Endpoint: to.Ptr("endpointB.net"), + // }, + // ResourceState: to.Ptr(armfrontdoor.NetworkExperimentResourceStateCreating), + // ScriptFileURI: to.Ptr("www.myScript.com"), + // Status: to.Ptr("ongoing"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentCreateExperiment.json +func ExampleExperimentsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewExperimentsClient().BeginCreateOrUpdate(ctx, "MyResourceGroup", "MyProfile", "MyExperiment", armfrontdoor.Experiment{ + Properties: &armfrontdoor.ExperimentProperties{ + Description: to.Ptr("this is my first experiment!"), + EnabledState: to.Ptr(armfrontdoor.StateEnabled), + EndpointA: &armfrontdoor.Endpoint{ + Name: to.Ptr("endpoint A"), + Endpoint: to.Ptr("endpointA.net"), + }, + EndpointB: &armfrontdoor.Endpoint{ + Name: to.Ptr("endpoint B"), + Endpoint: to.Ptr("endpointB.net"), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Experiment = armfrontdoor.Experiment{ + // Name: to.Ptr("MyExperiment"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/MyResourceGroup/providers/Microsoft.Network/NetworkExperimentProfiles/MyProfile/Experiments/MyExperiment"), + // Location: to.Ptr("WestUs"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armfrontdoor.ExperimentProperties{ + // Description: to.Ptr("this is my first experiment!"), + // EnabledState: to.Ptr(armfrontdoor.StateEnabled), + // EndpointA: &armfrontdoor.Endpoint{ + // Name: to.Ptr("endpoint A"), + // Endpoint: to.Ptr("endpointA.net"), + // }, + // EndpointB: &armfrontdoor.Endpoint{ + // Name: to.Ptr("endpoint B"), + // Endpoint: to.Ptr("endpointB.net"), + // }, + // ResourceState: to.Ptr(armfrontdoor.NetworkExperimentResourceStateCreating), + // ScriptFileURI: to.Ptr("www.myScript.com"), + // Status: to.Ptr("ongoing"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentUpdateExperiment.json +func ExampleExperimentsClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewExperimentsClient().BeginUpdate(ctx, "MyResourceGroup", "MyProfile", "MyExperiment", armfrontdoor.ExperimentUpdateModel{ + Properties: &armfrontdoor.ExperimentUpdateProperties{ + Description: to.Ptr("string"), + EnabledState: to.Ptr(armfrontdoor.StateEnabled), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Experiment = armfrontdoor.Experiment{ + // Name: to.Ptr("MyExperiment"), + // Type: to.Ptr("Microsoft.Network/NetworkExperimentprofiles"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/MyResourceGroup/providers/Microsoft.Network/NetworkExperimentProfiles/MyProfile/Experiments/MyExperiment"), + // Location: to.Ptr("WestUs"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armfrontdoor.ExperimentProperties{ + // Description: to.Ptr("this is my first experiment!"), + // EnabledState: to.Ptr(armfrontdoor.StateEnabled), + // EndpointA: &armfrontdoor.Endpoint{ + // Name: to.Ptr("endpoint A"), + // Endpoint: to.Ptr("endpointA.net"), + // }, + // EndpointB: &armfrontdoor.Endpoint{ + // Name: to.Ptr("endpoint B"), + // Endpoint: to.Ptr("endpointB.net"), + // }, + // ResourceState: to.Ptr(armfrontdoor.NetworkExperimentResourceStateCreating), + // ScriptFileURI: to.Ptr("www.myScript.com"), + // Status: to.Ptr("ongoing"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentDeleteExperiment.json +func ExampleExperimentsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewExperimentsClient().BeginDelete(ctx, "MyResourceGroup", "MyProfile", "MyExperiment", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_frontdoors_client.go b/sdk/resourcemanager/frontdoor/armfrontdoor/frontdoors_client.go similarity index 84% rename from sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_frontdoors_client.go rename to sdk/resourcemanager/frontdoor/armfrontdoor/frontdoors_client.go index 4c66ac09bebe..9792da5c0c6d 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_frontdoors_client.go +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/frontdoors_client.go @@ -5,6 +5,7 @@ // 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 armfrontdoor @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,67 +24,60 @@ import ( // FrontDoorsClient contains the methods for the FrontDoors group. // Don't use this type directly, use NewFrontDoorsClient() instead. type FrontDoorsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewFrontDoorsClient creates a new instance of FrontDoorsClient with the specified values. -// subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription -// ID forms part of the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription +// ID forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewFrontDoorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FrontDoorsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".FrontDoorsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &FrontDoorsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates a new Front Door with a Front Door name under the specified subscription and resource group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// frontDoorName - Name of the Front Door which is globally unique. -// frontDoorParameters - Front Door properties needed to create a new Front Door. -// options - FrontDoorsClientBeginCreateOrUpdateOptions contains the optional parameters for the FrontDoorsClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - frontDoorName - Name of the Front Door which is globally unique. +// - frontDoorParameters - Front Door properties needed to create a new Front Door. +// - options - FrontDoorsClientBeginCreateOrUpdateOptions contains the optional parameters for the FrontDoorsClient.BeginCreateOrUpdate +// method. func (client *FrontDoorsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, frontDoorName string, frontDoorParameters FrontDoor, options *FrontDoorsClientBeginCreateOrUpdateOptions) (*runtime.Poller[FrontDoorsClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, frontDoorName, frontDoorParameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[FrontDoorsClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FrontDoorsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[FrontDoorsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[FrontDoorsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates a new Front Door with a Front Door name under the specified subscription and resource group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 func (client *FrontDoorsClient) createOrUpdate(ctx context.Context, resourceGroupName string, frontDoorName string, frontDoorParameters FrontDoor, options *FrontDoorsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, frontDoorName, frontDoorParameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -110,7 +102,7 @@ func (client *FrontDoorsClient) createOrUpdateCreateRequest(ctx context.Context, return nil, errors.New("parameter frontDoorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{frontDoorName}", url.PathEscape(frontDoorName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -123,33 +115,35 @@ func (client *FrontDoorsClient) createOrUpdateCreateRequest(ctx context.Context, // BeginDelete - Deletes an existing Front Door with the specified parameters. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// frontDoorName - Name of the Front Door which is globally unique. -// options - FrontDoorsClientBeginDeleteOptions contains the optional parameters for the FrontDoorsClient.BeginDelete method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - frontDoorName - Name of the Front Door which is globally unique. +// - options - FrontDoorsClientBeginDeleteOptions contains the optional parameters for the FrontDoorsClient.BeginDelete method. func (client *FrontDoorsClient) BeginDelete(ctx context.Context, resourceGroupName string, frontDoorName string, options *FrontDoorsClientBeginDeleteOptions) (*runtime.Poller[FrontDoorsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, frontDoorName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[FrontDoorsClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FrontDoorsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[FrontDoorsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[FrontDoorsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes an existing Front Door with the specified parameters. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 func (client *FrontDoorsClient) deleteOperation(ctx context.Context, resourceGroupName string, frontDoorName string, options *FrontDoorsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, frontDoorName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -174,7 +168,7 @@ func (client *FrontDoorsClient) deleteCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter frontDoorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{frontDoorName}", url.PathEscape(frontDoorName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -187,16 +181,17 @@ func (client *FrontDoorsClient) deleteCreateRequest(ctx context.Context, resourc // Get - Gets a Front Door with the specified Front Door name under the specified subscription and resource group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// frontDoorName - Name of the Front Door which is globally unique. -// options - FrontDoorsClientGetOptions contains the optional parameters for the FrontDoorsClient.Get method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - frontDoorName - Name of the Front Door which is globally unique. +// - options - FrontDoorsClientGetOptions contains the optional parameters for the FrontDoorsClient.Get method. func (client *FrontDoorsClient) Get(ctx context.Context, resourceGroupName string, frontDoorName string, options *FrontDoorsClientGetOptions) (FrontDoorsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, frontDoorName, options) if err != nil { return FrontDoorsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FrontDoorsClientGetResponse{}, err } @@ -221,7 +216,7 @@ func (client *FrontDoorsClient) getCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter frontDoorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{frontDoorName}", url.PathEscape(frontDoorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -242,9 +237,9 @@ func (client *FrontDoorsClient) getHandleResponse(resp *http.Response) (FrontDoo } // NewListPager - Lists all of the Front Doors within an Azure subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// options - FrontDoorsClientListOptions contains the optional parameters for the FrontDoorsClient.List method. +// - options - FrontDoorsClientListOptions contains the optional parameters for the FrontDoorsClient.NewListPager method. func (client *FrontDoorsClient) NewListPager(options *FrontDoorsClientListOptions) *runtime.Pager[FrontDoorsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[FrontDoorsClientListResponse]{ More: func(page FrontDoorsClientListResponse) bool { @@ -261,7 +256,7 @@ func (client *FrontDoorsClient) NewListPager(options *FrontDoorsClientListOption if err != nil { return FrontDoorsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FrontDoorsClientListResponse{}, err } @@ -280,7 +275,7 @@ func (client *FrontDoorsClient) listCreateRequest(ctx context.Context, options * return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -301,11 +296,11 @@ func (client *FrontDoorsClient) listHandleResponse(resp *http.Response) (FrontDo } // NewListByResourceGroupPager - Lists all of the Front Doors within a resource group under a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// options - FrontDoorsClientListByResourceGroupOptions contains the optional parameters for the FrontDoorsClient.ListByResourceGroup -// method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - options - FrontDoorsClientListByResourceGroupOptions contains the optional parameters for the FrontDoorsClient.NewListByResourceGroupPager +// method. func (client *FrontDoorsClient) NewListByResourceGroupPager(resourceGroupName string, options *FrontDoorsClientListByResourceGroupOptions) *runtime.Pager[FrontDoorsClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[FrontDoorsClientListByResourceGroupResponse]{ More: func(page FrontDoorsClientListByResourceGroupResponse) bool { @@ -322,7 +317,7 @@ func (client *FrontDoorsClient) NewListByResourceGroupPager(resourceGroupName st if err != nil { return FrontDoorsClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FrontDoorsClientListByResourceGroupResponse{}, err } @@ -345,7 +340,7 @@ func (client *FrontDoorsClient) listByResourceGroupCreateRequest(ctx context.Con return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -367,18 +362,19 @@ func (client *FrontDoorsClient) listByResourceGroupHandleResponse(resp *http.Res // ValidateCustomDomain - Validates the custom domain mapping to ensure it maps to the correct Front Door endpoint in DNS. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// frontDoorName - Name of the Front Door which is globally unique. -// customDomainProperties - Custom domain to be validated. -// options - FrontDoorsClientValidateCustomDomainOptions contains the optional parameters for the FrontDoorsClient.ValidateCustomDomain -// method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - frontDoorName - Name of the Front Door which is globally unique. +// - customDomainProperties - Custom domain to be validated. +// - options - FrontDoorsClientValidateCustomDomainOptions contains the optional parameters for the FrontDoorsClient.ValidateCustomDomain +// method. func (client *FrontDoorsClient) ValidateCustomDomain(ctx context.Context, resourceGroupName string, frontDoorName string, customDomainProperties ValidateCustomDomainInput, options *FrontDoorsClientValidateCustomDomainOptions) (FrontDoorsClientValidateCustomDomainResponse, error) { req, err := client.validateCustomDomainCreateRequest(ctx, resourceGroupName, frontDoorName, customDomainProperties, options) if err != nil { return FrontDoorsClientValidateCustomDomainResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FrontDoorsClientValidateCustomDomainResponse{}, err } @@ -403,7 +399,7 @@ func (client *FrontDoorsClient) validateCustomDomainCreateRequest(ctx context.Co return nil, errors.New("parameter frontDoorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{frontDoorName}", url.PathEscape(frontDoorName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/frontdoors_client_example_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/frontdoors_client_example_test.go new file mode 100644 index 000000000000..39285fac8a40 --- /dev/null +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/frontdoors_client_example_test.go @@ -0,0 +1,987 @@ +//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 armfrontdoor_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/frontdoor/armfrontdoor" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorListAll.json +func ExampleFrontDoorsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFrontDoorsClient().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.ListResult = armfrontdoor.ListResult{ + // Value: []*armfrontdoor.FrontDoor{ + // { + // Name: to.Ptr("frontDoor1"), + // Type: to.Ptr("Microsoft.Network/frontDoor"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armfrontdoor.Properties{ + // BackendPools: []*armfrontdoor.BackendPool{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1"), + // Name: to.Ptr("backendPool1"), + // Properties: &armfrontdoor.BackendPoolProperties{ + // Backends: []*armfrontdoor.Backend{ + // { + // Address: to.Ptr("w3.contoso.com"), + // EnabledState: to.Ptr(armfrontdoor.BackendEnabledStateEnabled), + // HTTPPort: to.Ptr[int32](80), + // HTTPSPort: to.Ptr[int32](443), + // Priority: to.Ptr[int32](2), + // Weight: to.Ptr[int32](1), + // }, + // { + // Address: to.Ptr("contoso.com.website-us-west-2.othercloud.net"), + // EnabledState: to.Ptr(armfrontdoor.BackendEnabledStateEnabled), + // HTTPPort: to.Ptr[int32](80), + // HTTPSPort: to.Ptr[int32](443), + // Priority: to.Ptr[int32](1), + // PrivateEndpointStatus: to.Ptr(armfrontdoor.PrivateEndpointStatusApproved), + // PrivateLinkApprovalMessage: to.Ptr("Please approve the connection request for this Private Link"), + // PrivateLinkLocation: to.Ptr("eastus"), + // PrivateLinkResourceID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.Network/privateLinkServices/pls1"), + // Weight: to.Ptr[int32](2), + // }, + // { + // Address: to.Ptr("10.0.1.5"), + // EnabledState: to.Ptr(armfrontdoor.BackendEnabledStateEnabled), + // HTTPPort: to.Ptr[int32](80), + // HTTPSPort: to.Ptr[int32](443), + // Priority: to.Ptr[int32](1), + // PrivateEndpointStatus: to.Ptr(armfrontdoor.PrivateEndpointStatusApproved), + // PrivateLinkAlias: to.Ptr("APPSERVER.d84e61f0-0870-4d24-9746-7438fa0019d1.westus2.azure.privatelinkservice"), + // PrivateLinkApprovalMessage: to.Ptr("Please approve the connection request for this Private Link"), + // Weight: to.Ptr[int32](1), + // }}, + // HealthProbeSettings: &armfrontdoor.SubResource{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/healthProbeSettings/healthProbeSettings1"), + // }, + // LoadBalancingSettings: &armfrontdoor.SubResource{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/loadBalancingSettings/loadBalancingSettings1"), + // }, + // }, + // }}, + // BackendPoolsSettings: &armfrontdoor.BackendPoolsSettings{ + // EnforceCertificateNameCheck: to.Ptr(armfrontdoor.EnforceCertificateNameCheckEnabledStateEnabled), + // }, + // EnabledState: to.Ptr(armfrontdoor.FrontDoorEnabledStateEnabled), + // FrontendEndpoints: []*armfrontdoor.FrontendEndpoint{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/frontendEndpoint1"), + // Name: to.Ptr("frontendEndpoint1"), + // Properties: &armfrontdoor.FrontendEndpointProperties{ + // HostName: to.Ptr("www.contoso.com"), + // SessionAffinityEnabledState: to.Ptr(armfrontdoor.SessionAffinityEnabledStateEnabled), + // SessionAffinityTTLSeconds: to.Ptr[int32](60), + // WebApplicationFirewallPolicyLink: &armfrontdoor.FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), + // }, + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/default"), + // Name: to.Ptr("default"), + // Properties: &armfrontdoor.FrontendEndpointProperties{ + // HostName: to.Ptr("frontDoor1.azurefd.net"), + // }, + // }}, + // HealthProbeSettings: []*armfrontdoor.HealthProbeSettingsModel{ + // { + // Name: to.Ptr("healthProbeSettings1"), + // Properties: &armfrontdoor.HealthProbeSettingsProperties{ + // Path: to.Ptr("/"), + // EnabledState: to.Ptr(armfrontdoor.HealthProbeEnabledEnabled), + // HealthProbeMethod: to.Ptr(armfrontdoor.FrontDoorHealthProbeMethodHEAD), + // IntervalInSeconds: to.Ptr[int32](120), + // Protocol: to.Ptr(armfrontdoor.FrontDoorProtocolHTTP), + // }, + // }}, + // LoadBalancingSettings: []*armfrontdoor.LoadBalancingSettingsModel{ + // { + // Name: to.Ptr("loadBalancingSettings1"), + // Properties: &armfrontdoor.LoadBalancingSettingsProperties{ + // SampleSize: to.Ptr[int32](4), + // SuccessfulSamplesRequired: to.Ptr[int32](2), + // }, + // }}, + // RoutingRules: []*armfrontdoor.RoutingRule{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/routingRules/routingRule1"), + // Name: to.Ptr("routingRule1"), + // Properties: &armfrontdoor.RoutingRuleProperties{ + // AcceptedProtocols: []*armfrontdoor.FrontDoorProtocol{ + // to.Ptr(armfrontdoor.FrontDoorProtocolHTTP)}, + // EnabledState: to.Ptr(armfrontdoor.RoutingRuleEnabledStateEnabled), + // FrontendEndpoints: []*armfrontdoor.SubResource{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/frontendEndpoint1"), + // }, + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/default"), + // }}, + // PatternsToMatch: []*string{ + // to.Ptr("/*")}, + // RouteConfiguration: &armfrontdoor.ForwardingConfiguration{ + // ODataType: to.Ptr("#Microsoft.Azure.FrontDoor.Models.FrontdoorForwardingConfiguration"), + // BackendPool: &armfrontdoor.SubResource{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1"), + // }, + // CustomForwardingPath: to.Ptr(""), + // ForwardingProtocol: to.Ptr(armfrontdoor.FrontDoorForwardingProtocolMatchRequest), + // }, + // RulesEngine: &armfrontdoor.SubResource{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/rulesEngines/rulesEngine1"), + // }, + // WebApplicationFirewallPolicyLink: &armfrontdoor.RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), + // }, + // }, + // }}, + // Cname: to.Ptr("frontDoor1.azurefd.net"), + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armfrontdoor.FrontDoorResourceStateEnabled), + // RulesEngines: []*armfrontdoor.RulesEngine{ + // { + // Name: to.Ptr("rulesEngine1"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/routingRules/rulesEngine1"), + // Properties: &armfrontdoor.RulesEngineProperties{ + // Rules: []*armfrontdoor.RulesEngineRule{ + // { + // Name: to.Ptr("Rule1"), + // Action: &armfrontdoor.RulesEngineAction{ + // RouteConfigurationOverride: &armfrontdoor.RedirectConfiguration{ + // ODataType: to.Ptr("#Microsoft.Azure.FrontDoor.Models.FrontdoorRedirectConfiguration"), + // CustomFragment: to.Ptr("fragment"), + // CustomHost: to.Ptr("www.bing.com"), + // CustomPath: to.Ptr("/api"), + // CustomQueryString: to.Ptr("a=b"), + // RedirectProtocol: to.Ptr(armfrontdoor.FrontDoorRedirectProtocolHTTPSOnly), + // RedirectType: to.Ptr(armfrontdoor.FrontDoorRedirectTypeMoved), + // }, + // }, + // MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ + // { + // RulesEngineMatchValue: []*string{ + // to.Ptr("CH")}, + // RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariableRemoteAddr), + // RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorGeoMatch), + // }}, + // MatchProcessingBehavior: to.Ptr(armfrontdoor.MatchProcessingBehaviorStop), + // Priority: to.Ptr[int32](1), + // }, + // { + // Name: to.Ptr("Rule2"), + // Action: &armfrontdoor.RulesEngineAction{ + // ResponseHeaderActions: []*armfrontdoor.HeaderAction{ + // { + // HeaderActionType: to.Ptr(armfrontdoor.HeaderActionTypeOverwrite), + // HeaderName: to.Ptr("Cache-Control"), + // Value: to.Ptr("public, max-age=31536000"), + // }}, + // }, + // MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ + // { + // RulesEngineMatchValue: []*string{ + // to.Ptr("jpg")}, + // RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariable("FilenameExtension")), + // RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorEqual), + // Transforms: []*armfrontdoor.Transform{ + // to.Ptr(armfrontdoor.TransformLowercase)}, + // }}, + // Priority: to.Ptr[int32](2), + // }}, + // }, + // }}, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorList.json +func ExampleFrontDoorsClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFrontDoorsClient().NewListByResourceGroupPager("rg1", 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.ListResult = armfrontdoor.ListResult{ + // Value: []*armfrontdoor.FrontDoor{ + // { + // Name: to.Ptr("frontDoor1"), + // Type: to.Ptr("Microsoft.Network/frontDoor"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armfrontdoor.Properties{ + // BackendPools: []*armfrontdoor.BackendPool{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1"), + // Name: to.Ptr("backendPool1"), + // Properties: &armfrontdoor.BackendPoolProperties{ + // Backends: []*armfrontdoor.Backend{ + // { + // Address: to.Ptr("w3.contoso.com"), + // EnabledState: to.Ptr(armfrontdoor.BackendEnabledStateEnabled), + // HTTPPort: to.Ptr[int32](80), + // HTTPSPort: to.Ptr[int32](443), + // Priority: to.Ptr[int32](2), + // Weight: to.Ptr[int32](1), + // }, + // { + // Address: to.Ptr("contoso.com.website-us-west-2.othercloud.net"), + // EnabledState: to.Ptr(armfrontdoor.BackendEnabledStateEnabled), + // HTTPPort: to.Ptr[int32](80), + // HTTPSPort: to.Ptr[int32](443), + // Priority: to.Ptr[int32](1), + // PrivateEndpointStatus: to.Ptr(armfrontdoor.PrivateEndpointStatusApproved), + // PrivateLinkApprovalMessage: to.Ptr("Please approve the connection request for this Private Link"), + // PrivateLinkLocation: to.Ptr("eastus"), + // PrivateLinkResourceID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.Network/privateLinkServices/pls1"), + // Weight: to.Ptr[int32](2), + // }, + // { + // Address: to.Ptr("10.0.1.5"), + // EnabledState: to.Ptr(armfrontdoor.BackendEnabledStateEnabled), + // HTTPPort: to.Ptr[int32](80), + // HTTPSPort: to.Ptr[int32](443), + // Priority: to.Ptr[int32](1), + // PrivateEndpointStatus: to.Ptr(armfrontdoor.PrivateEndpointStatusApproved), + // PrivateLinkAlias: to.Ptr("APPSERVER.d84e61f0-0870-4d24-9746-7438fa0019d1.westus2.azure.privatelinkservice"), + // PrivateLinkApprovalMessage: to.Ptr("Please approve the connection request for this Private Link"), + // Weight: to.Ptr[int32](1), + // }}, + // HealthProbeSettings: &armfrontdoor.SubResource{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/healthProbeSettings/healthProbeSettings1"), + // }, + // LoadBalancingSettings: &armfrontdoor.SubResource{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/loadBalancingSettings/loadBalancingSettings1"), + // }, + // }, + // }}, + // BackendPoolsSettings: &armfrontdoor.BackendPoolsSettings{ + // EnforceCertificateNameCheck: to.Ptr(armfrontdoor.EnforceCertificateNameCheckEnabledStateEnabled), + // SendRecvTimeoutSeconds: to.Ptr[int32](60), + // }, + // EnabledState: to.Ptr(armfrontdoor.FrontDoorEnabledStateEnabled), + // FrontendEndpoints: []*armfrontdoor.FrontendEndpoint{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/frontendEndpoint1"), + // Name: to.Ptr("frontendEndpoint1"), + // Properties: &armfrontdoor.FrontendEndpointProperties{ + // HostName: to.Ptr("www.contoso.com"), + // SessionAffinityEnabledState: to.Ptr(armfrontdoor.SessionAffinityEnabledStateEnabled), + // SessionAffinityTTLSeconds: to.Ptr[int32](60), + // WebApplicationFirewallPolicyLink: &armfrontdoor.FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), + // }, + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/default"), + // Name: to.Ptr("default"), + // Properties: &armfrontdoor.FrontendEndpointProperties{ + // HostName: to.Ptr("frontDoor1.azurefd.net"), + // }, + // }}, + // HealthProbeSettings: []*armfrontdoor.HealthProbeSettingsModel{ + // { + // Name: to.Ptr("healthProbeSettings1"), + // Properties: &armfrontdoor.HealthProbeSettingsProperties{ + // Path: to.Ptr("/"), + // EnabledState: to.Ptr(armfrontdoor.HealthProbeEnabledEnabled), + // HealthProbeMethod: to.Ptr(armfrontdoor.FrontDoorHealthProbeMethodHEAD), + // IntervalInSeconds: to.Ptr[int32](120), + // Protocol: to.Ptr(armfrontdoor.FrontDoorProtocolHTTP), + // }, + // }}, + // LoadBalancingSettings: []*armfrontdoor.LoadBalancingSettingsModel{ + // { + // Name: to.Ptr("loadBalancingSettings1"), + // Properties: &armfrontdoor.LoadBalancingSettingsProperties{ + // SampleSize: to.Ptr[int32](4), + // SuccessfulSamplesRequired: to.Ptr[int32](2), + // }, + // }}, + // RoutingRules: []*armfrontdoor.RoutingRule{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/routingRules/routingRule1"), + // Name: to.Ptr("routingRule1"), + // Properties: &armfrontdoor.RoutingRuleProperties{ + // AcceptedProtocols: []*armfrontdoor.FrontDoorProtocol{ + // to.Ptr(armfrontdoor.FrontDoorProtocolHTTP)}, + // EnabledState: to.Ptr(armfrontdoor.RoutingRuleEnabledStateEnabled), + // FrontendEndpoints: []*armfrontdoor.SubResource{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/frontendEndpoint1"), + // }, + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/default"), + // }}, + // PatternsToMatch: []*string{ + // to.Ptr("/*")}, + // RouteConfiguration: &armfrontdoor.ForwardingConfiguration{ + // ODataType: to.Ptr("#Microsoft.Azure.FrontDoor.Models.FrontdoorForwardingConfiguration"), + // BackendPool: &armfrontdoor.SubResource{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1"), + // }, + // CustomForwardingPath: to.Ptr(""), + // ForwardingProtocol: to.Ptr(armfrontdoor.FrontDoorForwardingProtocolMatchRequest), + // }, + // RulesEngine: &armfrontdoor.SubResource{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/rulesEngines/rulesEngine1"), + // }, + // WebApplicationFirewallPolicyLink: &armfrontdoor.RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), + // }, + // }, + // }}, + // Cname: to.Ptr("frontDoor1.azurefd.net"), + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armfrontdoor.FrontDoorResourceStateEnabled), + // RulesEngines: []*armfrontdoor.RulesEngine{ + // { + // Name: to.Ptr("rulesEngine1"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/routingRules/rulesEngine1"), + // Properties: &armfrontdoor.RulesEngineProperties{ + // Rules: []*armfrontdoor.RulesEngineRule{ + // { + // Name: to.Ptr("Rule1"), + // Action: &armfrontdoor.RulesEngineAction{ + // RouteConfigurationOverride: &armfrontdoor.RedirectConfiguration{ + // ODataType: to.Ptr("#Microsoft.Azure.FrontDoor.Models.FrontdoorRedirectConfiguration"), + // CustomFragment: to.Ptr("fragment"), + // CustomHost: to.Ptr("www.bing.com"), + // CustomPath: to.Ptr("/api"), + // CustomQueryString: to.Ptr("a=b"), + // RedirectProtocol: to.Ptr(armfrontdoor.FrontDoorRedirectProtocolHTTPSOnly), + // RedirectType: to.Ptr(armfrontdoor.FrontDoorRedirectTypeMoved), + // }, + // }, + // MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ + // { + // RulesEngineMatchValue: []*string{ + // to.Ptr("CH")}, + // RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariableRemoteAddr), + // RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorGeoMatch), + // }}, + // MatchProcessingBehavior: to.Ptr(armfrontdoor.MatchProcessingBehaviorStop), + // Priority: to.Ptr[int32](1), + // }, + // { + // Name: to.Ptr("Rule2"), + // Action: &armfrontdoor.RulesEngineAction{ + // ResponseHeaderActions: []*armfrontdoor.HeaderAction{ + // { + // HeaderActionType: to.Ptr(armfrontdoor.HeaderActionTypeOverwrite), + // HeaderName: to.Ptr("Cache-Control"), + // Value: to.Ptr("public, max-age=31536000"), + // }}, + // }, + // MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ + // { + // RulesEngineMatchValue: []*string{ + // to.Ptr("jpg")}, + // RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariable("FilenameExtension")), + // RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorEqual), + // Transforms: []*armfrontdoor.Transform{ + // to.Ptr(armfrontdoor.TransformLowercase)}, + // }}, + // Priority: to.Ptr[int32](2), + // }}, + // }, + // }}, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorGet.json +func ExampleFrontDoorsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFrontDoorsClient().Get(ctx, "rg1", "frontDoor1", 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.FrontDoor = armfrontdoor.FrontDoor{ + // Name: to.Ptr("frontDoor1"), + // Type: to.Ptr("Microsoft.Network/frontDoor"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armfrontdoor.Properties{ + // BackendPools: []*armfrontdoor.BackendPool{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1"), + // Name: to.Ptr("backendPool1"), + // Properties: &armfrontdoor.BackendPoolProperties{ + // Backends: []*armfrontdoor.Backend{ + // { + // Address: to.Ptr("w3.contoso.com"), + // EnabledState: to.Ptr(armfrontdoor.BackendEnabledStateEnabled), + // HTTPPort: to.Ptr[int32](80), + // HTTPSPort: to.Ptr[int32](443), + // Priority: to.Ptr[int32](2), + // Weight: to.Ptr[int32](1), + // }, + // { + // Address: to.Ptr("contoso.com.website-us-west-2.othercloud.net"), + // EnabledState: to.Ptr(armfrontdoor.BackendEnabledStateEnabled), + // HTTPPort: to.Ptr[int32](80), + // HTTPSPort: to.Ptr[int32](443), + // Priority: to.Ptr[int32](1), + // PrivateEndpointStatus: to.Ptr(armfrontdoor.PrivateEndpointStatusApproved), + // PrivateLinkApprovalMessage: to.Ptr("Please approve the connection request for this Private Link"), + // PrivateLinkLocation: to.Ptr("eastus"), + // PrivateLinkResourceID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.Network/privateLinkServices/pls1"), + // Weight: to.Ptr[int32](2), + // }, + // { + // Address: to.Ptr("10.0.1.5"), + // EnabledState: to.Ptr(armfrontdoor.BackendEnabledStateEnabled), + // HTTPPort: to.Ptr[int32](80), + // HTTPSPort: to.Ptr[int32](443), + // Priority: to.Ptr[int32](1), + // PrivateEndpointStatus: to.Ptr(armfrontdoor.PrivateEndpointStatusApproved), + // PrivateLinkAlias: to.Ptr("APPSERVER.d84e61f0-0870-4d24-9746-7438fa0019d1.westus2.azure.privatelinkservice"), + // PrivateLinkApprovalMessage: to.Ptr("Please approve the connection request for this Private Link"), + // Weight: to.Ptr[int32](1), + // }}, + // HealthProbeSettings: &armfrontdoor.SubResource{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/healthProbeSettings/healthProbeSettings1"), + // }, + // LoadBalancingSettings: &armfrontdoor.SubResource{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/loadBalancingSettings/loadBalancingSettings1"), + // }, + // }, + // }}, + // BackendPoolsSettings: &armfrontdoor.BackendPoolsSettings{ + // EnforceCertificateNameCheck: to.Ptr(armfrontdoor.EnforceCertificateNameCheckEnabledStateEnabled), + // SendRecvTimeoutSeconds: to.Ptr[int32](60), + // }, + // EnabledState: to.Ptr(armfrontdoor.FrontDoorEnabledStateEnabled), + // FrontendEndpoints: []*armfrontdoor.FrontendEndpoint{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/frontendEndpoint1"), + // Name: to.Ptr("frontendEndpoint1"), + // Properties: &armfrontdoor.FrontendEndpointProperties{ + // HostName: to.Ptr("www.contoso.com"), + // SessionAffinityEnabledState: to.Ptr(armfrontdoor.SessionAffinityEnabledStateEnabled), + // SessionAffinityTTLSeconds: to.Ptr[int32](60), + // WebApplicationFirewallPolicyLink: &armfrontdoor.FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), + // }, + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/default"), + // Name: to.Ptr("default"), + // Properties: &armfrontdoor.FrontendEndpointProperties{ + // HostName: to.Ptr("frontDoor1.azurefd.net"), + // }, + // }}, + // HealthProbeSettings: []*armfrontdoor.HealthProbeSettingsModel{ + // { + // Name: to.Ptr("healthProbeSettings1"), + // Properties: &armfrontdoor.HealthProbeSettingsProperties{ + // Path: to.Ptr("/"), + // EnabledState: to.Ptr(armfrontdoor.HealthProbeEnabledEnabled), + // HealthProbeMethod: to.Ptr(armfrontdoor.FrontDoorHealthProbeMethodHEAD), + // IntervalInSeconds: to.Ptr[int32](120), + // Protocol: to.Ptr(armfrontdoor.FrontDoorProtocolHTTP), + // }, + // }}, + // LoadBalancingSettings: []*armfrontdoor.LoadBalancingSettingsModel{ + // { + // Name: to.Ptr("loadBalancingSettings1"), + // Properties: &armfrontdoor.LoadBalancingSettingsProperties{ + // SampleSize: to.Ptr[int32](4), + // SuccessfulSamplesRequired: to.Ptr[int32](2), + // }, + // }}, + // RoutingRules: []*armfrontdoor.RoutingRule{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/routingRules/routingRule1"), + // Name: to.Ptr("routingRule1"), + // Properties: &armfrontdoor.RoutingRuleProperties{ + // AcceptedProtocols: []*armfrontdoor.FrontDoorProtocol{ + // to.Ptr(armfrontdoor.FrontDoorProtocolHTTP)}, + // EnabledState: to.Ptr(armfrontdoor.RoutingRuleEnabledStateEnabled), + // FrontendEndpoints: []*armfrontdoor.SubResource{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/frontendEndpoint1"), + // }, + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/default"), + // }}, + // PatternsToMatch: []*string{ + // to.Ptr("/*")}, + // RouteConfiguration: &armfrontdoor.ForwardingConfiguration{ + // ODataType: to.Ptr("#Microsoft.Azure.FrontDoor.Models.FrontdoorForwardingConfiguration"), + // BackendPool: &armfrontdoor.SubResource{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1"), + // }, + // CustomForwardingPath: to.Ptr(""), + // ForwardingProtocol: to.Ptr(armfrontdoor.FrontDoorForwardingProtocolMatchRequest), + // }, + // RulesEngine: &armfrontdoor.SubResource{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/rulesEngines/rulesEngine1"), + // }, + // WebApplicationFirewallPolicyLink: &armfrontdoor.RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), + // }, + // }, + // }}, + // Cname: to.Ptr("frontDoor1.azurefd.net"), + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armfrontdoor.FrontDoorResourceStateEnabled), + // RulesEngines: []*armfrontdoor.RulesEngine{ + // { + // Name: to.Ptr("rulesEngine1"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/rulesEngines/rulesEngine1"), + // Properties: &armfrontdoor.RulesEngineProperties{ + // Rules: []*armfrontdoor.RulesEngineRule{ + // { + // Name: to.Ptr("Rule1"), + // Action: &armfrontdoor.RulesEngineAction{ + // RouteConfigurationOverride: &armfrontdoor.RedirectConfiguration{ + // ODataType: to.Ptr("#Microsoft.Azure.FrontDoor.Models.FrontdoorRedirectConfiguration"), + // CustomFragment: to.Ptr("fragment"), + // CustomHost: to.Ptr("www.bing.com"), + // CustomPath: to.Ptr("/api"), + // CustomQueryString: to.Ptr("a=b"), + // RedirectProtocol: to.Ptr(armfrontdoor.FrontDoorRedirectProtocolHTTPSOnly), + // RedirectType: to.Ptr(armfrontdoor.FrontDoorRedirectTypeMoved), + // }, + // }, + // MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ + // { + // RulesEngineMatchValue: []*string{ + // to.Ptr("CH")}, + // RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariableRemoteAddr), + // RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorGeoMatch), + // }}, + // MatchProcessingBehavior: to.Ptr(armfrontdoor.MatchProcessingBehaviorStop), + // Priority: to.Ptr[int32](1), + // }, + // { + // Name: to.Ptr("Rule2"), + // Action: &armfrontdoor.RulesEngineAction{ + // ResponseHeaderActions: []*armfrontdoor.HeaderAction{ + // { + // HeaderActionType: to.Ptr(armfrontdoor.HeaderActionTypeOverwrite), + // HeaderName: to.Ptr("Cache-Control"), + // Value: to.Ptr("public, max-age=31536000"), + // }}, + // }, + // MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ + // { + // RulesEngineMatchValue: []*string{ + // to.Ptr("jpg")}, + // RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariable("FilenameExtension")), + // RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorEqual), + // Transforms: []*armfrontdoor.Transform{ + // to.Ptr(armfrontdoor.TransformLowercase)}, + // }}, + // Priority: to.Ptr[int32](2), + // }}, + // }, + // }}, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorCreate.json +func ExampleFrontDoorsClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewFrontDoorsClient().BeginCreateOrUpdate(ctx, "rg1", "frontDoor1", armfrontdoor.FrontDoor{ + Location: to.Ptr("westus"), + Tags: map[string]*string{ + "tag1": to.Ptr("value1"), + "tag2": to.Ptr("value2"), + }, + Properties: &armfrontdoor.Properties{ + BackendPools: []*armfrontdoor.BackendPool{ + { + Name: to.Ptr("backendPool1"), + Properties: &armfrontdoor.BackendPoolProperties{ + Backends: []*armfrontdoor.Backend{ + { + Address: to.Ptr("w3.contoso.com"), + HTTPPort: to.Ptr[int32](80), + HTTPSPort: to.Ptr[int32](443), + Priority: to.Ptr[int32](2), + Weight: to.Ptr[int32](1), + }, + { + Address: to.Ptr("contoso.com.website-us-west-2.othercloud.net"), + HTTPPort: to.Ptr[int32](80), + HTTPSPort: to.Ptr[int32](443), + Priority: to.Ptr[int32](1), + PrivateLinkApprovalMessage: to.Ptr("Please approve the connection request for this Private Link"), + PrivateLinkLocation: to.Ptr("eastus"), + PrivateLinkResourceID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.Network/privateLinkServices/pls1"), + Weight: to.Ptr[int32](2), + }, + { + Address: to.Ptr("10.0.1.5"), + HTTPPort: to.Ptr[int32](80), + HTTPSPort: to.Ptr[int32](443), + Priority: to.Ptr[int32](1), + PrivateLinkAlias: to.Ptr("APPSERVER.d84e61f0-0870-4d24-9746-7438fa0019d1.westus2.azure.privatelinkservice"), + PrivateLinkApprovalMessage: to.Ptr("Please approve this request to connect to the Private Link"), + Weight: to.Ptr[int32](1), + }}, + HealthProbeSettings: &armfrontdoor.SubResource{ + ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/healthProbeSettings/healthProbeSettings1"), + }, + LoadBalancingSettings: &armfrontdoor.SubResource{ + ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/loadBalancingSettings/loadBalancingSettings1"), + }, + }, + }}, + BackendPoolsSettings: &armfrontdoor.BackendPoolsSettings{ + EnforceCertificateNameCheck: to.Ptr(armfrontdoor.EnforceCertificateNameCheckEnabledStateEnabled), + SendRecvTimeoutSeconds: to.Ptr[int32](60), + }, + EnabledState: to.Ptr(armfrontdoor.FrontDoorEnabledStateEnabled), + FrontendEndpoints: []*armfrontdoor.FrontendEndpoint{ + { + Name: to.Ptr("frontendEndpoint1"), + Properties: &armfrontdoor.FrontendEndpointProperties{ + HostName: to.Ptr("www.contoso.com"), + SessionAffinityEnabledState: to.Ptr(armfrontdoor.SessionAffinityEnabledStateEnabled), + SessionAffinityTTLSeconds: to.Ptr[int32](60), + WebApplicationFirewallPolicyLink: &armfrontdoor.FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink{ + ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), + }, + }, + }, + { + Name: to.Ptr("default"), + Properties: &armfrontdoor.FrontendEndpointProperties{ + HostName: to.Ptr("frontDoor1.azurefd.net"), + }, + }}, + HealthProbeSettings: []*armfrontdoor.HealthProbeSettingsModel{ + { + Name: to.Ptr("healthProbeSettings1"), + Properties: &armfrontdoor.HealthProbeSettingsProperties{ + Path: to.Ptr("/"), + EnabledState: to.Ptr(armfrontdoor.HealthProbeEnabledEnabled), + HealthProbeMethod: to.Ptr(armfrontdoor.FrontDoorHealthProbeMethodHEAD), + IntervalInSeconds: to.Ptr[int32](120), + Protocol: to.Ptr(armfrontdoor.FrontDoorProtocolHTTP), + }, + }}, + LoadBalancingSettings: []*armfrontdoor.LoadBalancingSettingsModel{ + { + Name: to.Ptr("loadBalancingSettings1"), + Properties: &armfrontdoor.LoadBalancingSettingsProperties{ + SampleSize: to.Ptr[int32](4), + SuccessfulSamplesRequired: to.Ptr[int32](2), + }, + }}, + RoutingRules: []*armfrontdoor.RoutingRule{ + { + Name: to.Ptr("routingRule1"), + Properties: &armfrontdoor.RoutingRuleProperties{ + AcceptedProtocols: []*armfrontdoor.FrontDoorProtocol{ + to.Ptr(armfrontdoor.FrontDoorProtocolHTTP)}, + EnabledState: to.Ptr(armfrontdoor.RoutingRuleEnabledStateEnabled), + FrontendEndpoints: []*armfrontdoor.SubResource{ + { + ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/frontendEndpoint1"), + }, + { + ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/default"), + }}, + PatternsToMatch: []*string{ + to.Ptr("/*")}, + RouteConfiguration: &armfrontdoor.ForwardingConfiguration{ + ODataType: to.Ptr("#Microsoft.Azure.FrontDoor.Models.FrontdoorForwardingConfiguration"), + BackendPool: &armfrontdoor.SubResource{ + ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1"), + }, + }, + RulesEngine: &armfrontdoor.SubResource{ + ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/rulesEngines/rulesEngine1"), + }, + WebApplicationFirewallPolicyLink: &armfrontdoor.RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink{ + ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), + }, + }, + }}, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.FrontDoor = armfrontdoor.FrontDoor{ + // Name: to.Ptr("frontDoor1"), + // Type: to.Ptr("Microsoft.Network/frontDoor"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "tag1": to.Ptr("value1"), + // "tag2": to.Ptr("value2"), + // }, + // Properties: &armfrontdoor.Properties{ + // BackendPools: []*armfrontdoor.BackendPool{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1"), + // Name: to.Ptr("backendPool1"), + // Properties: &armfrontdoor.BackendPoolProperties{ + // Backends: []*armfrontdoor.Backend{ + // { + // Address: to.Ptr("w3.contoso.com"), + // EnabledState: to.Ptr(armfrontdoor.BackendEnabledStateEnabled), + // HTTPPort: to.Ptr[int32](80), + // HTTPSPort: to.Ptr[int32](443), + // Priority: to.Ptr[int32](2), + // Weight: to.Ptr[int32](1), + // }, + // { + // Address: to.Ptr("contoso.com.website-us-west-2.othercloud.net"), + // EnabledState: to.Ptr(armfrontdoor.BackendEnabledStateEnabled), + // HTTPPort: to.Ptr[int32](80), + // HTTPSPort: to.Ptr[int32](443), + // Priority: to.Ptr[int32](1), + // PrivateEndpointStatus: to.Ptr(armfrontdoor.PrivateEndpointStatusApproved), + // PrivateLinkApprovalMessage: to.Ptr("Please approve the connection request for this Private Link"), + // PrivateLinkLocation: to.Ptr("eastus"), + // PrivateLinkResourceID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.Network/privateLinkServices/pls1"), + // Weight: to.Ptr[int32](2), + // }, + // { + // Address: to.Ptr("10.0.1.5"), + // EnabledState: to.Ptr(armfrontdoor.BackendEnabledStateEnabled), + // HTTPPort: to.Ptr[int32](80), + // HTTPSPort: to.Ptr[int32](443), + // Priority: to.Ptr[int32](1), + // PrivateEndpointStatus: to.Ptr(armfrontdoor.PrivateEndpointStatusApproved), + // PrivateLinkAlias: to.Ptr("APPSERVER.d84e61f0-0870-4d24-9746-7438fa0019d1.westus2.azure.privatelinkservice"), + // PrivateLinkApprovalMessage: to.Ptr("Please approve the connection request for this Private Link"), + // Weight: to.Ptr[int32](1), + // }}, + // HealthProbeSettings: &armfrontdoor.SubResource{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/healthProbeSettings/healthProbeSettings1"), + // }, + // LoadBalancingSettings: &armfrontdoor.SubResource{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/loadBalancingSettings/loadBalancingSettings1"), + // }, + // }, + // }}, + // BackendPoolsSettings: &armfrontdoor.BackendPoolsSettings{ + // EnforceCertificateNameCheck: to.Ptr(armfrontdoor.EnforceCertificateNameCheckEnabledStateEnabled), + // SendRecvTimeoutSeconds: to.Ptr[int32](60), + // }, + // EnabledState: to.Ptr(armfrontdoor.FrontDoorEnabledStateEnabled), + // FrontendEndpoints: []*armfrontdoor.FrontendEndpoint{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/frontendEndpoint1"), + // Name: to.Ptr("frontendEndpoint1"), + // Properties: &armfrontdoor.FrontendEndpointProperties{ + // HostName: to.Ptr("www.contoso.com"), + // SessionAffinityEnabledState: to.Ptr(armfrontdoor.SessionAffinityEnabledStateEnabled), + // SessionAffinityTTLSeconds: to.Ptr[int32](60), + // WebApplicationFirewallPolicyLink: &armfrontdoor.FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), + // }, + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/default"), + // Name: to.Ptr("default"), + // Properties: &armfrontdoor.FrontendEndpointProperties{ + // HostName: to.Ptr("frontDoor1.azurefd.net"), + // }, + // }}, + // HealthProbeSettings: []*armfrontdoor.HealthProbeSettingsModel{ + // { + // Name: to.Ptr("healthProbeSettings1"), + // Properties: &armfrontdoor.HealthProbeSettingsProperties{ + // Path: to.Ptr("/"), + // EnabledState: to.Ptr(armfrontdoor.HealthProbeEnabledEnabled), + // HealthProbeMethod: to.Ptr(armfrontdoor.FrontDoorHealthProbeMethodHEAD), + // IntervalInSeconds: to.Ptr[int32](120), + // Protocol: to.Ptr(armfrontdoor.FrontDoorProtocolHTTP), + // }, + // }}, + // LoadBalancingSettings: []*armfrontdoor.LoadBalancingSettingsModel{ + // { + // Name: to.Ptr("loadBalancingSettings1"), + // Properties: &armfrontdoor.LoadBalancingSettingsProperties{ + // SampleSize: to.Ptr[int32](4), + // SuccessfulSamplesRequired: to.Ptr[int32](2), + // }, + // }}, + // RoutingRules: []*armfrontdoor.RoutingRule{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/routingRules/routingRule1"), + // Name: to.Ptr("routingRule1"), + // Properties: &armfrontdoor.RoutingRuleProperties{ + // AcceptedProtocols: []*armfrontdoor.FrontDoorProtocol{ + // to.Ptr(armfrontdoor.FrontDoorProtocolHTTP)}, + // EnabledState: to.Ptr(armfrontdoor.RoutingRuleEnabledStateEnabled), + // FrontendEndpoints: []*armfrontdoor.SubResource{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/frontendEndpoint1"), + // }, + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/default"), + // }}, + // PatternsToMatch: []*string{ + // to.Ptr("/*")}, + // RouteConfiguration: &armfrontdoor.ForwardingConfiguration{ + // ODataType: to.Ptr("#Microsoft.Azure.FrontDoor.Models.FrontdoorForwardingConfiguration"), + // BackendPool: &armfrontdoor.SubResource{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1"), + // }, + // CustomForwardingPath: to.Ptr(""), + // ForwardingProtocol: to.Ptr(armfrontdoor.FrontDoorForwardingProtocolMatchRequest), + // }, + // RulesEngine: &armfrontdoor.SubResource{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/rulesEngines/rulesEngine1"), + // }, + // WebApplicationFirewallPolicyLink: &armfrontdoor.RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), + // }, + // }, + // }}, + // Cname: to.Ptr("frontDoor1.azurefd.net"), + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armfrontdoor.FrontDoorResourceStateCreating), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorDelete.json +func ExampleFrontDoorsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewFrontDoorsClient().BeginDelete(ctx, "rg1", "frontDoor1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorValidateCustomDomain.json +func ExampleFrontDoorsClient_ValidateCustomDomain() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFrontDoorsClient().ValidateCustomDomain(ctx, "rg1", "frontDoor1", armfrontdoor.ValidateCustomDomainInput{ + HostName: to.Ptr("www.someDomain.com"), + }, 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.ValidateCustomDomainOutput = armfrontdoor.ValidateCustomDomainOutput{ + // CustomDomainValidated: to.Ptr(true), + // } +} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_frontendendpoints_client.go b/sdk/resourcemanager/frontdoor/armfrontdoor/frontendendpoints_client.go similarity index 81% rename from sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_frontendendpoints_client.go rename to sdk/resourcemanager/frontdoor/armfrontdoor/frontendendpoints_client.go index c53e0c27d1bd..e3a3f08e255d 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_frontendendpoints_client.go +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/frontendendpoints_client.go @@ -5,6 +5,7 @@ // 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 armfrontdoor @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,67 +24,60 @@ import ( // FrontendEndpointsClient contains the methods for the FrontendEndpoints group. // Don't use this type directly, use NewFrontendEndpointsClient() instead. type FrontendEndpointsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewFrontendEndpointsClient creates a new instance of FrontendEndpointsClient with the specified values. -// subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription -// ID forms part of the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription +// ID forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewFrontendEndpointsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FrontendEndpointsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".FrontendEndpointsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &FrontendEndpointsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginDisableHTTPS - Disables a frontendEndpoint for HTTPS traffic // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// frontDoorName - Name of the Front Door which is globally unique. -// frontendEndpointName - Name of the Frontend endpoint which is unique within the Front Door. -// options - FrontendEndpointsClientBeginDisableHTTPSOptions contains the optional parameters for the FrontendEndpointsClient.BeginDisableHTTPS -// method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - frontDoorName - Name of the Front Door which is globally unique. +// - frontendEndpointName - Name of the Frontend endpoint which is unique within the Front Door. +// - options - FrontendEndpointsClientBeginDisableHTTPSOptions contains the optional parameters for the FrontendEndpointsClient.BeginDisableHTTPS +// method. func (client *FrontendEndpointsClient) BeginDisableHTTPS(ctx context.Context, resourceGroupName string, frontDoorName string, frontendEndpointName string, options *FrontendEndpointsClientBeginDisableHTTPSOptions) (*runtime.Poller[FrontendEndpointsClientDisableHTTPSResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.disableHTTPS(ctx, resourceGroupName, frontDoorName, frontendEndpointName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[FrontendEndpointsClientDisableHTTPSResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FrontendEndpointsClientDisableHTTPSResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[FrontendEndpointsClientDisableHTTPSResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[FrontendEndpointsClientDisableHTTPSResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // DisableHTTPS - Disables a frontendEndpoint for HTTPS traffic // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 func (client *FrontendEndpointsClient) disableHTTPS(ctx context.Context, resourceGroupName string, frontDoorName string, frontendEndpointName string, options *FrontendEndpointsClientBeginDisableHTTPSOptions) (*http.Response, error) { req, err := client.disableHTTPSCreateRequest(ctx, resourceGroupName, frontDoorName, frontendEndpointName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -114,7 +106,7 @@ func (client *FrontendEndpointsClient) disableHTTPSCreateRequest(ctx context.Con return nil, errors.New("parameter frontendEndpointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{frontendEndpointName}", url.PathEscape(frontendEndpointName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -127,36 +119,38 @@ func (client *FrontendEndpointsClient) disableHTTPSCreateRequest(ctx context.Con // BeginEnableHTTPS - Enables a frontendEndpoint for HTTPS traffic // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// frontDoorName - Name of the Front Door which is globally unique. -// frontendEndpointName - Name of the Frontend endpoint which is unique within the Front Door. -// customHTTPSConfiguration - The configuration specifying how to enable HTTPS -// options - FrontendEndpointsClientBeginEnableHTTPSOptions contains the optional parameters for the FrontendEndpointsClient.BeginEnableHTTPS -// method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - frontDoorName - Name of the Front Door which is globally unique. +// - frontendEndpointName - Name of the Frontend endpoint which is unique within the Front Door. +// - customHTTPSConfiguration - The configuration specifying how to enable HTTPS +// - options - FrontendEndpointsClientBeginEnableHTTPSOptions contains the optional parameters for the FrontendEndpointsClient.BeginEnableHTTPS +// method. func (client *FrontendEndpointsClient) BeginEnableHTTPS(ctx context.Context, resourceGroupName string, frontDoorName string, frontendEndpointName string, customHTTPSConfiguration CustomHTTPSConfiguration, options *FrontendEndpointsClientBeginEnableHTTPSOptions) (*runtime.Poller[FrontendEndpointsClientEnableHTTPSResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.enableHTTPS(ctx, resourceGroupName, frontDoorName, frontendEndpointName, customHTTPSConfiguration, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[FrontendEndpointsClientEnableHTTPSResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FrontendEndpointsClientEnableHTTPSResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[FrontendEndpointsClientEnableHTTPSResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[FrontendEndpointsClientEnableHTTPSResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // EnableHTTPS - Enables a frontendEndpoint for HTTPS traffic // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 func (client *FrontendEndpointsClient) enableHTTPS(ctx context.Context, resourceGroupName string, frontDoorName string, frontendEndpointName string, customHTTPSConfiguration CustomHTTPSConfiguration, options *FrontendEndpointsClientBeginEnableHTTPSOptions) (*http.Response, error) { req, err := client.enableHTTPSCreateRequest(ctx, resourceGroupName, frontDoorName, frontendEndpointName, customHTTPSConfiguration, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -185,7 +179,7 @@ func (client *FrontendEndpointsClient) enableHTTPSCreateRequest(ctx context.Cont return nil, errors.New("parameter frontendEndpointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{frontendEndpointName}", url.PathEscape(frontendEndpointName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -198,17 +192,18 @@ func (client *FrontendEndpointsClient) enableHTTPSCreateRequest(ctx context.Cont // Get - Gets a Frontend endpoint with the specified name within the specified Front Door. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// frontDoorName - Name of the Front Door which is globally unique. -// frontendEndpointName - Name of the Frontend endpoint which is unique within the Front Door. -// options - FrontendEndpointsClientGetOptions contains the optional parameters for the FrontendEndpointsClient.Get method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - frontDoorName - Name of the Front Door which is globally unique. +// - frontendEndpointName - Name of the Frontend endpoint which is unique within the Front Door. +// - options - FrontendEndpointsClientGetOptions contains the optional parameters for the FrontendEndpointsClient.Get method. func (client *FrontendEndpointsClient) Get(ctx context.Context, resourceGroupName string, frontDoorName string, frontendEndpointName string, options *FrontendEndpointsClientGetOptions) (FrontendEndpointsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, frontDoorName, frontendEndpointName, options) if err != nil { return FrontendEndpointsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FrontendEndpointsClientGetResponse{}, err } @@ -237,7 +232,7 @@ func (client *FrontendEndpointsClient) getCreateRequest(ctx context.Context, res return nil, errors.New("parameter frontendEndpointName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{frontendEndpointName}", url.PathEscape(frontendEndpointName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -258,12 +253,12 @@ func (client *FrontendEndpointsClient) getHandleResponse(resp *http.Response) (F } // NewListByFrontDoorPager - Lists all of the frontend endpoints within a Front Door. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// frontDoorName - Name of the Front Door which is globally unique. -// options - FrontendEndpointsClientListByFrontDoorOptions contains the optional parameters for the FrontendEndpointsClient.ListByFrontDoor -// method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - frontDoorName - Name of the Front Door which is globally unique. +// - options - FrontendEndpointsClientListByFrontDoorOptions contains the optional parameters for the FrontendEndpointsClient.NewListByFrontDoorPager +// method. func (client *FrontendEndpointsClient) NewListByFrontDoorPager(resourceGroupName string, frontDoorName string, options *FrontendEndpointsClientListByFrontDoorOptions) *runtime.Pager[FrontendEndpointsClientListByFrontDoorResponse] { return runtime.NewPager(runtime.PagingHandler[FrontendEndpointsClientListByFrontDoorResponse]{ More: func(page FrontendEndpointsClientListByFrontDoorResponse) bool { @@ -280,7 +275,7 @@ func (client *FrontendEndpointsClient) NewListByFrontDoorPager(resourceGroupName if err != nil { return FrontendEndpointsClientListByFrontDoorResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return FrontendEndpointsClientListByFrontDoorResponse{}, err } @@ -307,7 +302,7 @@ func (client *FrontendEndpointsClient) listByFrontDoorCreateRequest(ctx context. return nil, errors.New("parameter frontDoorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{frontDoorName}", url.PathEscape(frontDoorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/frontendendpoints_client_example_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/frontendendpoints_client_example_test.go new file mode 100644 index 000000000000..ca4e5e544ef1 --- /dev/null +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/frontendendpoints_client_example_test.go @@ -0,0 +1,144 @@ +//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 armfrontdoor_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/frontdoor/armfrontdoor" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorFrontendEndpointList.json +func ExampleFrontendEndpointsClient_NewListByFrontDoorPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewFrontendEndpointsClient().NewListByFrontDoorPager("rg1", "frontDoor1", 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.FrontendEndpointsListResult = armfrontdoor.FrontendEndpointsListResult{ + // Value: []*armfrontdoor.FrontendEndpoint{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/frontendEndpoint1"), + // Name: to.Ptr("frontendEndpoint1"), + // Properties: &armfrontdoor.FrontendEndpointProperties{ + // HostName: to.Ptr("www.contoso.com"), + // SessionAffinityEnabledState: to.Ptr(armfrontdoor.SessionAffinityEnabledStateEnabled), + // SessionAffinityTTLSeconds: to.Ptr[int32](60), + // WebApplicationFirewallPolicyLink: &armfrontdoor.FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorFrontendEndpointGet.json +func ExampleFrontendEndpointsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewFrontendEndpointsClient().Get(ctx, "rg1", "frontDoor1", "frontendEndpoint1", 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.FrontendEndpoint = armfrontdoor.FrontendEndpoint{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/frontendEndpoint1"), + // Name: to.Ptr("frontendEndpoint1"), + // Properties: &armfrontdoor.FrontendEndpointProperties{ + // HostName: to.Ptr("www.contoso.com"), + // SessionAffinityEnabledState: to.Ptr(armfrontdoor.SessionAffinityEnabledStateEnabled), + // SessionAffinityTTLSeconds: to.Ptr[int32](60), + // WebApplicationFirewallPolicyLink: &armfrontdoor.FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorEnableHttps.json +func ExampleFrontendEndpointsClient_BeginEnableHTTPS() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewFrontendEndpointsClient().BeginEnableHTTPS(ctx, "rg1", "frontDoor1", "frontendEndpoint1", armfrontdoor.CustomHTTPSConfiguration{ + CertificateSource: to.Ptr(armfrontdoor.FrontDoorCertificateSourceAzureKeyVault), + KeyVaultCertificateSourceParameters: &armfrontdoor.KeyVaultCertificateSourceParameters{ + SecretName: to.Ptr("secret1"), + SecretVersion: to.Ptr("00000000-0000-0000-0000-000000000000"), + Vault: &armfrontdoor.KeyVaultCertificateSourceParametersVault{ + ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.KeyVault/vaults/vault1"), + }, + }, + MinimumTLSVersion: to.Ptr(armfrontdoor.MinimumTLSVersionOne0), + ProtocolType: to.Ptr(armfrontdoor.FrontDoorTLSProtocolTypeServerNameIndication), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorDisableHttps.json +func ExampleFrontendEndpointsClient_BeginDisableHTTPS() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewFrontendEndpointsClient().BeginDisableHTTPS(ctx, "rg1", "frontDoor1", "frontendEndpoint1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/go.mod b/sdk/resourcemanager/frontdoor/armfrontdoor/go.mod index 747848d3efa1..99aa71817d08 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/go.mod +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/frontdoor/armfrontd go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/go.sum b/sdk/resourcemanager/frontdoor/armfrontdoor/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/go.sum +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_managedrulesets_client.go b/sdk/resourcemanager/frontdoor/armfrontdoor/managedrulesets_client.go similarity index 76% rename from sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_managedrulesets_client.go rename to sdk/resourcemanager/frontdoor/armfrontdoor/managedrulesets_client.go index 7b9b5027515d..d38a30bddcc8 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_managedrulesets_client.go +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/managedrulesets_client.go @@ -5,6 +5,7 @@ // 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 armfrontdoor @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,40 +24,32 @@ import ( // ManagedRuleSetsClient contains the methods for the ManagedRuleSets group. // Don't use this type directly, use NewManagedRuleSetsClient() instead. type ManagedRuleSetsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewManagedRuleSetsClient creates a new instance of ManagedRuleSetsClient with the specified values. -// subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription -// ID forms part of the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription +// ID forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewManagedRuleSetsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ManagedRuleSetsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ManagedRuleSetsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ManagedRuleSetsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Lists all available managed rule sets. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-11-01 -// options - ManagedRuleSetsClientListOptions contains the optional parameters for the ManagedRuleSetsClient.List method. +// - options - ManagedRuleSetsClientListOptions contains the optional parameters for the ManagedRuleSetsClient.NewListPager +// method. func (client *ManagedRuleSetsClient) NewListPager(options *ManagedRuleSetsClientListOptions) *runtime.Pager[ManagedRuleSetsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ManagedRuleSetsClientListResponse]{ More: func(page ManagedRuleSetsClientListResponse) bool { @@ -75,7 +66,7 @@ func (client *ManagedRuleSetsClient) NewListPager(options *ManagedRuleSetsClient if err != nil { return ManagedRuleSetsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagedRuleSetsClientListResponse{}, err } @@ -94,7 +85,7 @@ func (client *ManagedRuleSetsClient) listCreateRequest(ctx context.Context, opti return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/managedrulesets_client_example_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/managedrulesets_client_example_test.go new file mode 100644 index 000000000000..26bc2124b06a --- /dev/null +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/managedrulesets_client_example_test.go @@ -0,0 +1,98 @@ +//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 armfrontdoor_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/frontdoor/armfrontdoor" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-11-01/examples/WafListManagedRuleSets.json +func ExampleManagedRuleSetsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewManagedRuleSetsClient().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.ManagedRuleSetDefinitionList = armfrontdoor.ManagedRuleSetDefinitionList{ + // Value: []*armfrontdoor.ManagedRuleSetDefinition{ + // { + // Name: to.Ptr("DefaultRuleSet_1.0"), + // Type: to.Ptr("Microsoft.Network/frontdoorwebapplicationfirewallmanagedrulesets"), + // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Network/FrontDoorWebApplicationFirewallManagedRuleSets"), + // Properties: &armfrontdoor.ManagedRuleSetDefinitionProperties{ + // ProvisioningState: to.Ptr("Succeeded"), + // RuleGroups: []*armfrontdoor.ManagedRuleGroupDefinition{ + // { + // Description: to.Ptr("SQL injection"), + // RuleGroupName: to.Ptr("SQLI"), + // Rules: []*armfrontdoor.ManagedRuleDefinition{ + // { + // Description: to.Ptr("SQL Injection Attack Detected via libinjection"), + // DefaultAction: to.Ptr(armfrontdoor.ActionTypeBlock), + // DefaultState: to.Ptr(armfrontdoor.ManagedRuleEnabledStateEnabled), + // RuleID: to.Ptr("942100"), + // }, + // { + // Description: to.Ptr("SQL Injection Attack: Common Injection Testing Detected"), + // DefaultAction: to.Ptr(armfrontdoor.ActionTypeBlock), + // DefaultState: to.Ptr(armfrontdoor.ManagedRuleEnabledStateEnabled), + // RuleID: to.Ptr("942110"), + // }}, + // }, + // { + // Description: to.Ptr("Cross-site scripting"), + // RuleGroupName: to.Ptr("XSS"), + // Rules: []*armfrontdoor.ManagedRuleDefinition{ + // { + // Description: to.Ptr("XSS Attack Detected via libinjection"), + // DefaultAction: to.Ptr(armfrontdoor.ActionTypeBlock), + // DefaultState: to.Ptr(armfrontdoor.ManagedRuleEnabledStateEnabled), + // RuleID: to.Ptr("941100"), + // }, + // { + // Description: to.Ptr("XSS Attack Detected via libinjection"), + // DefaultAction: to.Ptr(armfrontdoor.ActionTypeBlock), + // DefaultState: to.Ptr(armfrontdoor.ManagedRuleEnabledStateEnabled), + // RuleID: to.Ptr("941101"), + // }, + // { + // Description: to.Ptr("XSS Filter - Category 1: Script Tag Vector"), + // DefaultAction: to.Ptr(armfrontdoor.ActionTypeBlock), + // DefaultState: to.Ptr(armfrontdoor.ManagedRuleEnabledStateEnabled), + // RuleID: to.Ptr("941110"), + // }}, + // }}, + // RuleSetID: to.Ptr("8125d145-ddc5-4d90-9bc3-24c5f2de69a2"), + // RuleSetType: to.Ptr("DefaultRuleSet"), + // RuleSetVersion: to.Ptr("1.0"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_models.go b/sdk/resourcemanager/frontdoor/armfrontdoor/models.go similarity index 99% rename from sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_models.go rename to sdk/resourcemanager/frontdoor/armfrontdoor/models.go index 381541c3a8da..6902b26e6188 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_models.go +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/models.go @@ -5,6 +5,7 @@ // 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 armfrontdoor @@ -355,7 +356,8 @@ type ExperimentsClientGetOptions struct { // placeholder for future optional parameters } -// ExperimentsClientListByProfileOptions contains the optional parameters for the ExperimentsClient.ListByProfile method. +// ExperimentsClientListByProfileOptions contains the optional parameters for the ExperimentsClient.NewListByProfilePager +// method. type ExperimentsClientListByProfileOptions struct { // placeholder for future optional parameters } @@ -425,13 +427,13 @@ type FrontDoorsClientGetOptions struct { // placeholder for future optional parameters } -// FrontDoorsClientListByResourceGroupOptions contains the optional parameters for the FrontDoorsClient.ListByResourceGroup +// FrontDoorsClientListByResourceGroupOptions contains the optional parameters for the FrontDoorsClient.NewListByResourceGroupPager // method. type FrontDoorsClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// FrontDoorsClientListOptions contains the optional parameters for the FrontDoorsClient.List method. +// FrontDoorsClientListOptions contains the optional parameters for the FrontDoorsClient.NewListPager method. type FrontDoorsClientListOptions struct { // placeholder for future optional parameters } @@ -531,7 +533,7 @@ type FrontendEndpointsClientGetOptions struct { // placeholder for future optional parameters } -// FrontendEndpointsClientListByFrontDoorOptions contains the optional parameters for the FrontendEndpointsClient.ListByFrontDoor +// FrontendEndpointsClientListByFrontDoorOptions contains the optional parameters for the FrontendEndpointsClient.NewListByFrontDoorPager // method. type FrontendEndpointsClientListByFrontDoorOptions struct { // placeholder for future optional parameters @@ -928,7 +930,7 @@ type ManagedRuleSetList struct { ManagedRuleSets []*ManagedRuleSet `json:"managedRuleSets,omitempty"` } -// ManagedRuleSetsClientListOptions contains the optional parameters for the ManagedRuleSetsClient.List method. +// ManagedRuleSetsClientListOptions contains the optional parameters for the ManagedRuleSetsClient.NewListPager method. type ManagedRuleSetsClientListOptions struct { // placeholder for future optional parameters } @@ -992,13 +994,13 @@ type NetworkExperimentProfilesClientGetOptions struct { // placeholder for future optional parameters } -// NetworkExperimentProfilesClientListByResourceGroupOptions contains the optional parameters for the NetworkExperimentProfilesClient.ListByResourceGroup +// NetworkExperimentProfilesClientListByResourceGroupOptions contains the optional parameters for the NetworkExperimentProfilesClient.NewListByResourceGroupPager // method. type NetworkExperimentProfilesClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// NetworkExperimentProfilesClientListOptions contains the optional parameters for the NetworkExperimentProfilesClient.List +// NetworkExperimentProfilesClientListOptions contains the optional parameters for the NetworkExperimentProfilesClient.NewListPager // method. type NetworkExperimentProfilesClientListOptions struct { // placeholder for future optional parameters @@ -1021,7 +1023,7 @@ type PoliciesClientGetOptions struct { // placeholder for future optional parameters } -// PoliciesClientListOptions contains the optional parameters for the PoliciesClient.List method. +// PoliciesClientListOptions contains the optional parameters for the PoliciesClient.NewListPager method. type PoliciesClientListOptions struct { // placeholder for future optional parameters } @@ -1092,7 +1094,8 @@ type PreconfiguredEndpointProperties struct { EndpointType *EndpointType `json:"endpointType,omitempty"` } -// PreconfiguredEndpointsClientListOptions contains the optional parameters for the PreconfiguredEndpointsClient.List method. +// PreconfiguredEndpointsClientListOptions contains the optional parameters for the PreconfiguredEndpointsClient.NewListPager +// method. type PreconfiguredEndpointsClientListOptions struct { // placeholder for future optional parameters } @@ -1494,7 +1497,8 @@ type RulesEnginesClientGetOptions struct { // placeholder for future optional parameters } -// RulesEnginesClientListByFrontDoorOptions contains the optional parameters for the RulesEnginesClient.ListByFrontDoor method. +// RulesEnginesClientListByFrontDoorOptions contains the optional parameters for the RulesEnginesClient.NewListByFrontDoorPager +// method. type RulesEnginesClientListByFrontDoorOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/models_serde.go b/sdk/resourcemanager/frontdoor/armfrontdoor/models_serde.go new file mode 100644 index 000000000000..af4fc19b5f32 --- /dev/null +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/models_serde.go @@ -0,0 +1,3768 @@ +//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 armfrontdoor + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AzureAsyncOperationResult. +func (a AzureAsyncOperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", a.Error) + populate(objectMap, "status", a.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureAsyncOperationResult. +func (a *AzureAsyncOperationResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &a.Error) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &a.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Backend. +func (b Backend) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "address", b.Address) + populate(objectMap, "backendHostHeader", b.BackendHostHeader) + populate(objectMap, "enabledState", b.EnabledState) + populate(objectMap, "httpPort", b.HTTPPort) + populate(objectMap, "httpsPort", b.HTTPSPort) + populate(objectMap, "priority", b.Priority) + populate(objectMap, "privateEndpointStatus", b.PrivateEndpointStatus) + populate(objectMap, "privateLinkAlias", b.PrivateLinkAlias) + populate(objectMap, "privateLinkApprovalMessage", b.PrivateLinkApprovalMessage) + populate(objectMap, "privateLinkLocation", b.PrivateLinkLocation) + populate(objectMap, "privateLinkResourceId", b.PrivateLinkResourceID) + populate(objectMap, "weight", b.Weight) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Backend. +func (b *Backend) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "address": + err = unpopulate(val, "Address", &b.Address) + delete(rawMsg, key) + case "backendHostHeader": + err = unpopulate(val, "BackendHostHeader", &b.BackendHostHeader) + delete(rawMsg, key) + case "enabledState": + err = unpopulate(val, "EnabledState", &b.EnabledState) + delete(rawMsg, key) + case "httpPort": + err = unpopulate(val, "HTTPPort", &b.HTTPPort) + delete(rawMsg, key) + case "httpsPort": + err = unpopulate(val, "HTTPSPort", &b.HTTPSPort) + delete(rawMsg, key) + case "priority": + err = unpopulate(val, "Priority", &b.Priority) + delete(rawMsg, key) + case "privateEndpointStatus": + err = unpopulate(val, "PrivateEndpointStatus", &b.PrivateEndpointStatus) + delete(rawMsg, key) + case "privateLinkAlias": + err = unpopulate(val, "PrivateLinkAlias", &b.PrivateLinkAlias) + delete(rawMsg, key) + case "privateLinkApprovalMessage": + err = unpopulate(val, "PrivateLinkApprovalMessage", &b.PrivateLinkApprovalMessage) + delete(rawMsg, key) + case "privateLinkLocation": + err = unpopulate(val, "PrivateLinkLocation", &b.PrivateLinkLocation) + delete(rawMsg, key) + case "privateLinkResourceId": + err = unpopulate(val, "PrivateLinkResourceID", &b.PrivateLinkResourceID) + delete(rawMsg, key) + case "weight": + err = unpopulate(val, "Weight", &b.Weight) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BackendPool. +func (b BackendPool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", b.ID) + populate(objectMap, "name", b.Name) + populate(objectMap, "properties", b.Properties) + populate(objectMap, "type", b.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BackendPool. +func (b *BackendPool) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &b.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &b.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &b.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &b.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BackendPoolListResult. +func (b BackendPoolListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", b.NextLink) + populate(objectMap, "value", b.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BackendPoolListResult. +func (b *BackendPoolListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &b.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &b.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BackendPoolProperties. +func (b BackendPoolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "backends", b.Backends) + populate(objectMap, "healthProbeSettings", b.HealthProbeSettings) + populate(objectMap, "loadBalancingSettings", b.LoadBalancingSettings) + populate(objectMap, "resourceState", b.ResourceState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BackendPoolProperties. +func (b *BackendPoolProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "backends": + err = unpopulate(val, "Backends", &b.Backends) + delete(rawMsg, key) + case "healthProbeSettings": + err = unpopulate(val, "HealthProbeSettings", &b.HealthProbeSettings) + delete(rawMsg, key) + case "loadBalancingSettings": + err = unpopulate(val, "LoadBalancingSettings", &b.LoadBalancingSettings) + delete(rawMsg, key) + case "resourceState": + err = unpopulate(val, "ResourceState", &b.ResourceState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BackendPoolUpdateParameters. +func (b BackendPoolUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "backends", b.Backends) + populate(objectMap, "healthProbeSettings", b.HealthProbeSettings) + populate(objectMap, "loadBalancingSettings", b.LoadBalancingSettings) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BackendPoolUpdateParameters. +func (b *BackendPoolUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "backends": + err = unpopulate(val, "Backends", &b.Backends) + delete(rawMsg, key) + case "healthProbeSettings": + err = unpopulate(val, "HealthProbeSettings", &b.HealthProbeSettings) + delete(rawMsg, key) + case "loadBalancingSettings": + err = unpopulate(val, "LoadBalancingSettings", &b.LoadBalancingSettings) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BackendPoolsSettings. +func (b BackendPoolsSettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "enforceCertificateNameCheck", b.EnforceCertificateNameCheck) + populate(objectMap, "sendRecvTimeoutSeconds", b.SendRecvTimeoutSeconds) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BackendPoolsSettings. +func (b *BackendPoolsSettings) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "enforceCertificateNameCheck": + err = unpopulate(val, "EnforceCertificateNameCheck", &b.EnforceCertificateNameCheck) + delete(rawMsg, key) + case "sendRecvTimeoutSeconds": + err = unpopulate(val, "SendRecvTimeoutSeconds", &b.SendRecvTimeoutSeconds) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CacheConfiguration. +func (c CacheConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "cacheDuration", c.CacheDuration) + populate(objectMap, "dynamicCompression", c.DynamicCompression) + populate(objectMap, "queryParameterStripDirective", c.QueryParameterStripDirective) + populate(objectMap, "queryParameters", c.QueryParameters) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CacheConfiguration. +func (c *CacheConfiguration) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "cacheDuration": + err = unpopulate(val, "CacheDuration", &c.CacheDuration) + delete(rawMsg, key) + case "dynamicCompression": + err = unpopulate(val, "DynamicCompression", &c.DynamicCompression) + delete(rawMsg, key) + case "queryParameterStripDirective": + err = unpopulate(val, "QueryParameterStripDirective", &c.QueryParameterStripDirective) + delete(rawMsg, key) + case "queryParameters": + err = unpopulate(val, "QueryParameters", &c.QueryParameters) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CertificateSourceParameters. +func (c CertificateSourceParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "certificateType", c.CertificateType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CertificateSourceParameters. +func (c *CertificateSourceParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "certificateType": + err = unpopulate(val, "CertificateType", &c.CertificateType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityInput. +func (c CheckNameAvailabilityInput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityInput. +func (c *CheckNameAvailabilityInput) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityOutput. +func (c CheckNameAvailabilityOutput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", c.Message) + populate(objectMap, "nameAvailability", c.NameAvailability) + populate(objectMap, "reason", c.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityOutput. +func (c *CheckNameAvailabilityOutput) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &c.Message) + delete(rawMsg, key) + case "nameAvailability": + err = unpopulate(val, "NameAvailability", &c.NameAvailability) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &c.Reason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CustomHTTPSConfiguration. +func (c CustomHTTPSConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "certificateSource", c.CertificateSource) + populate(objectMap, "frontDoorCertificateSourceParameters", c.FrontDoorCertificateSourceParameters) + populate(objectMap, "keyVaultCertificateSourceParameters", c.KeyVaultCertificateSourceParameters) + populate(objectMap, "minimumTlsVersion", c.MinimumTLSVersion) + populate(objectMap, "protocolType", c.ProtocolType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomHTTPSConfiguration. +func (c *CustomHTTPSConfiguration) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "certificateSource": + err = unpopulate(val, "CertificateSource", &c.CertificateSource) + delete(rawMsg, key) + case "frontDoorCertificateSourceParameters": + err = unpopulate(val, "FrontDoorCertificateSourceParameters", &c.FrontDoorCertificateSourceParameters) + delete(rawMsg, key) + case "keyVaultCertificateSourceParameters": + err = unpopulate(val, "KeyVaultCertificateSourceParameters", &c.KeyVaultCertificateSourceParameters) + delete(rawMsg, key) + case "minimumTlsVersion": + err = unpopulate(val, "MinimumTLSVersion", &c.MinimumTLSVersion) + delete(rawMsg, key) + case "protocolType": + err = unpopulate(val, "ProtocolType", &c.ProtocolType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CustomRule. +func (c CustomRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "action", c.Action) + populate(objectMap, "enabledState", c.EnabledState) + populate(objectMap, "matchConditions", c.MatchConditions) + populate(objectMap, "name", c.Name) + populate(objectMap, "priority", c.Priority) + populate(objectMap, "rateLimitDurationInMinutes", c.RateLimitDurationInMinutes) + populate(objectMap, "rateLimitThreshold", c.RateLimitThreshold) + populate(objectMap, "ruleType", c.RuleType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomRule. +func (c *CustomRule) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + err = unpopulate(val, "Action", &c.Action) + delete(rawMsg, key) + case "enabledState": + err = unpopulate(val, "EnabledState", &c.EnabledState) + delete(rawMsg, key) + case "matchConditions": + err = unpopulate(val, "MatchConditions", &c.MatchConditions) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "priority": + err = unpopulate(val, "Priority", &c.Priority) + delete(rawMsg, key) + case "rateLimitDurationInMinutes": + err = unpopulate(val, "RateLimitDurationInMinutes", &c.RateLimitDurationInMinutes) + delete(rawMsg, key) + case "rateLimitThreshold": + err = unpopulate(val, "RateLimitThreshold", &c.RateLimitThreshold) + delete(rawMsg, key) + case "ruleType": + err = unpopulate(val, "RuleType", &c.RuleType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CustomRuleList. +func (c CustomRuleList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "rules", c.Rules) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomRuleList. +func (c *CustomRuleList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "rules": + err = unpopulate(val, "Rules", &c.Rules) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Endpoint. +func (e Endpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "endpoint", e.Endpoint) + populate(objectMap, "name", e.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Endpoint. +func (e *Endpoint) 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 "endpoint": + err = unpopulate(val, "Endpoint", &e.Endpoint) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + 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 Error. +func (e Error) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "innerError", e.InnerError) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Error. +func (e *Error) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "innerError": + err = unpopulate(val, "InnerError", &e.InnerError) + 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) + populate(objectMap, "code", e.Code) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetails. +func (e *ErrorDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "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 ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", e.Code) + populate(objectMap, "message", e.Message) + 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 "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Experiment. +func (e Experiment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", e.ID) + populate(objectMap, "location", e.Location) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "tags", e.Tags) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Experiment. +func (e *Experiment) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &e.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + 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 ExperimentList. +func (e ExperimentList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentList. +func (e *ExperimentList) 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 "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + 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 ExperimentProperties. +func (e ExperimentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", e.Description) + populate(objectMap, "enabledState", e.EnabledState) + populate(objectMap, "endpointA", e.EndpointA) + populate(objectMap, "endpointB", e.EndpointB) + populate(objectMap, "resourceState", e.ResourceState) + populate(objectMap, "scriptFileUri", e.ScriptFileURI) + populate(objectMap, "status", e.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentProperties. +func (e *ExperimentProperties) 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 "description": + err = unpopulate(val, "Description", &e.Description) + delete(rawMsg, key) + case "enabledState": + err = unpopulate(val, "EnabledState", &e.EnabledState) + delete(rawMsg, key) + case "endpointA": + err = unpopulate(val, "EndpointA", &e.EndpointA) + delete(rawMsg, key) + case "endpointB": + err = unpopulate(val, "EndpointB", &e.EndpointB) + delete(rawMsg, key) + case "resourceState": + err = unpopulate(val, "ResourceState", &e.ResourceState) + delete(rawMsg, key) + case "scriptFileUri": + err = unpopulate(val, "ScriptFileURI", &e.ScriptFileURI) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &e.Status) + 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 ExperimentUpdateModel. +func (e ExperimentUpdateModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "tags", e.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentUpdateModel. +func (e *ExperimentUpdateModel) 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 "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + 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 ExperimentUpdateProperties. +func (e ExperimentUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", e.Description) + populate(objectMap, "enabledState", e.EnabledState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExperimentUpdateProperties. +func (e *ExperimentUpdateProperties) 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 "description": + err = unpopulate(val, "Description", &e.Description) + delete(rawMsg, key) + case "enabledState": + err = unpopulate(val, "EnabledState", &e.EnabledState) + 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 ForwardingConfiguration. +func (f ForwardingConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "backendPool", f.BackendPool) + populate(objectMap, "cacheConfiguration", f.CacheConfiguration) + populate(objectMap, "customForwardingPath", f.CustomForwardingPath) + populate(objectMap, "forwardingProtocol", f.ForwardingProtocol) + objectMap["@odata.type"] = "#Microsoft.Azure.FrontDoor.Models.FrontdoorForwardingConfiguration" + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ForwardingConfiguration. +func (f *ForwardingConfiguration) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "backendPool": + err = unpopulate(val, "BackendPool", &f.BackendPool) + delete(rawMsg, key) + case "cacheConfiguration": + err = unpopulate(val, "CacheConfiguration", &f.CacheConfiguration) + delete(rawMsg, key) + case "customForwardingPath": + err = unpopulate(val, "CustomForwardingPath", &f.CustomForwardingPath) + delete(rawMsg, key) + case "forwardingProtocol": + err = unpopulate(val, "ForwardingProtocol", &f.ForwardingProtocol) + delete(rawMsg, key) + case "@odata.type": + err = unpopulate(val, "ODataType", &f.ODataType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FrontDoor. +func (f FrontDoor) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", f.ID) + populate(objectMap, "location", f.Location) + populate(objectMap, "name", f.Name) + populate(objectMap, "properties", f.Properties) + populate(objectMap, "tags", f.Tags) + populate(objectMap, "type", f.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FrontDoor. +func (f *FrontDoor) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &f.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &f.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &f.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &f.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &f.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FrontendEndpoint. +func (f FrontendEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", f.ID) + populate(objectMap, "name", f.Name) + populate(objectMap, "properties", f.Properties) + populate(objectMap, "type", f.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FrontendEndpoint. +func (f *FrontendEndpoint) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &f.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &f.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &f.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FrontendEndpointLink. +func (f FrontendEndpointLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", f.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FrontendEndpointLink. +func (f *FrontendEndpointLink) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &f.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FrontendEndpointProperties. +func (f FrontendEndpointProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "customHttpsConfiguration", f.CustomHTTPSConfiguration) + populate(objectMap, "customHttpsProvisioningState", f.CustomHTTPSProvisioningState) + populate(objectMap, "customHttpsProvisioningSubstate", f.CustomHTTPSProvisioningSubstate) + populate(objectMap, "hostName", f.HostName) + populate(objectMap, "resourceState", f.ResourceState) + populate(objectMap, "sessionAffinityEnabledState", f.SessionAffinityEnabledState) + populate(objectMap, "sessionAffinityTtlSeconds", f.SessionAffinityTTLSeconds) + populate(objectMap, "webApplicationFirewallPolicyLink", f.WebApplicationFirewallPolicyLink) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FrontendEndpointProperties. +func (f *FrontendEndpointProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "customHttpsConfiguration": + err = unpopulate(val, "CustomHTTPSConfiguration", &f.CustomHTTPSConfiguration) + delete(rawMsg, key) + case "customHttpsProvisioningState": + err = unpopulate(val, "CustomHTTPSProvisioningState", &f.CustomHTTPSProvisioningState) + delete(rawMsg, key) + case "customHttpsProvisioningSubstate": + err = unpopulate(val, "CustomHTTPSProvisioningSubstate", &f.CustomHTTPSProvisioningSubstate) + delete(rawMsg, key) + case "hostName": + err = unpopulate(val, "HostName", &f.HostName) + delete(rawMsg, key) + case "resourceState": + err = unpopulate(val, "ResourceState", &f.ResourceState) + delete(rawMsg, key) + case "sessionAffinityEnabledState": + err = unpopulate(val, "SessionAffinityEnabledState", &f.SessionAffinityEnabledState) + delete(rawMsg, key) + case "sessionAffinityTtlSeconds": + err = unpopulate(val, "SessionAffinityTTLSeconds", &f.SessionAffinityTTLSeconds) + delete(rawMsg, key) + case "webApplicationFirewallPolicyLink": + err = unpopulate(val, "WebApplicationFirewallPolicyLink", &f.WebApplicationFirewallPolicyLink) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FrontendEndpointUpdateParameters. +func (f FrontendEndpointUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "hostName", f.HostName) + populate(objectMap, "sessionAffinityEnabledState", f.SessionAffinityEnabledState) + populate(objectMap, "sessionAffinityTtlSeconds", f.SessionAffinityTTLSeconds) + populate(objectMap, "webApplicationFirewallPolicyLink", f.WebApplicationFirewallPolicyLink) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FrontendEndpointUpdateParameters. +func (f *FrontendEndpointUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "hostName": + err = unpopulate(val, "HostName", &f.HostName) + delete(rawMsg, key) + case "sessionAffinityEnabledState": + err = unpopulate(val, "SessionAffinityEnabledState", &f.SessionAffinityEnabledState) + delete(rawMsg, key) + case "sessionAffinityTtlSeconds": + err = unpopulate(val, "SessionAffinityTTLSeconds", &f.SessionAffinityTTLSeconds) + delete(rawMsg, key) + case "webApplicationFirewallPolicyLink": + err = unpopulate(val, "WebApplicationFirewallPolicyLink", &f.WebApplicationFirewallPolicyLink) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink. +func (f FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", f.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink. +func (f *FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &f.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FrontendEndpointsListResult. +func (f FrontendEndpointsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", f.NextLink) + populate(objectMap, "value", f.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FrontendEndpointsListResult. +func (f *FrontendEndpointsListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &f.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &f.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HeaderAction. +func (h HeaderAction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "headerActionType", h.HeaderActionType) + populate(objectMap, "headerName", h.HeaderName) + populate(objectMap, "value", h.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HeaderAction. +func (h *HeaderAction) 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", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "headerActionType": + err = unpopulate(val, "HeaderActionType", &h.HeaderActionType) + delete(rawMsg, key) + case "headerName": + err = unpopulate(val, "HeaderName", &h.HeaderName) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &h.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HealthProbeSettingsListResult. +func (h HealthProbeSettingsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", h.NextLink) + populate(objectMap, "value", h.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthProbeSettingsListResult. +func (h *HealthProbeSettingsListResult) 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", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &h.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &h.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HealthProbeSettingsModel. +func (h HealthProbeSettingsModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", h.ID) + populate(objectMap, "name", h.Name) + populate(objectMap, "properties", h.Properties) + populate(objectMap, "type", h.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthProbeSettingsModel. +func (h *HealthProbeSettingsModel) 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", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &h.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &h.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &h.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &h.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HealthProbeSettingsProperties. +func (h HealthProbeSettingsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "enabledState", h.EnabledState) + populate(objectMap, "healthProbeMethod", h.HealthProbeMethod) + populate(objectMap, "intervalInSeconds", h.IntervalInSeconds) + populate(objectMap, "path", h.Path) + populate(objectMap, "protocol", h.Protocol) + populate(objectMap, "resourceState", h.ResourceState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthProbeSettingsProperties. +func (h *HealthProbeSettingsProperties) 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", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "enabledState": + err = unpopulate(val, "EnabledState", &h.EnabledState) + delete(rawMsg, key) + case "healthProbeMethod": + err = unpopulate(val, "HealthProbeMethod", &h.HealthProbeMethod) + delete(rawMsg, key) + case "intervalInSeconds": + err = unpopulate(val, "IntervalInSeconds", &h.IntervalInSeconds) + delete(rawMsg, key) + case "path": + err = unpopulate(val, "Path", &h.Path) + delete(rawMsg, key) + case "protocol": + err = unpopulate(val, "Protocol", &h.Protocol) + delete(rawMsg, key) + case "resourceState": + err = unpopulate(val, "ResourceState", &h.ResourceState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HealthProbeSettingsUpdateParameters. +func (h HealthProbeSettingsUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "enabledState", h.EnabledState) + populate(objectMap, "healthProbeMethod", h.HealthProbeMethod) + populate(objectMap, "intervalInSeconds", h.IntervalInSeconds) + populate(objectMap, "path", h.Path) + populate(objectMap, "protocol", h.Protocol) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthProbeSettingsUpdateParameters. +func (h *HealthProbeSettingsUpdateParameters) 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", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "enabledState": + err = unpopulate(val, "EnabledState", &h.EnabledState) + delete(rawMsg, key) + case "healthProbeMethod": + err = unpopulate(val, "HealthProbeMethod", &h.HealthProbeMethod) + delete(rawMsg, key) + case "intervalInSeconds": + err = unpopulate(val, "IntervalInSeconds", &h.IntervalInSeconds) + delete(rawMsg, key) + case "path": + err = unpopulate(val, "Path", &h.Path) + delete(rawMsg, key) + case "protocol": + err = unpopulate(val, "Protocol", &h.Protocol) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultCertificateSourceParameters. +func (k KeyVaultCertificateSourceParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "secretName", k.SecretName) + populate(objectMap, "secretVersion", k.SecretVersion) + populate(objectMap, "vault", k.Vault) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultCertificateSourceParameters. +func (k *KeyVaultCertificateSourceParameters) 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", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "secretName": + err = unpopulate(val, "SecretName", &k.SecretName) + delete(rawMsg, key) + case "secretVersion": + err = unpopulate(val, "SecretVersion", &k.SecretVersion) + delete(rawMsg, key) + case "vault": + err = unpopulate(val, "Vault", &k.Vault) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultCertificateSourceParametersVault. +func (k KeyVaultCertificateSourceParametersVault) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", k.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultCertificateSourceParametersVault. +func (k *KeyVaultCertificateSourceParametersVault) 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", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &k.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LatencyMetric. +func (l LatencyMetric) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "aCLower95CI", l.ACLower95CI) + populate(objectMap, "aHUpper95CI", l.AHUpper95CI) + populate(objectMap, "aValue", l.AValue) + populate(objectMap, "bCLower95CI", l.BCLower95CI) + populate(objectMap, "bUpper95CI", l.BUpper95CI) + populate(objectMap, "bValue", l.BValue) + populate(objectMap, "delta", l.Delta) + populate(objectMap, "deltaPercent", l.DeltaPercent) + populate(objectMap, "endDateTimeUTC", l.EndDateTimeUTC) + populate(objectMap, "name", l.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LatencyMetric. +func (l *LatencyMetric) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "aCLower95CI": + err = unpopulate(val, "ACLower95CI", &l.ACLower95CI) + delete(rawMsg, key) + case "aHUpper95CI": + err = unpopulate(val, "AHUpper95CI", &l.AHUpper95CI) + delete(rawMsg, key) + case "aValue": + err = unpopulate(val, "AValue", &l.AValue) + delete(rawMsg, key) + case "bCLower95CI": + err = unpopulate(val, "BCLower95CI", &l.BCLower95CI) + delete(rawMsg, key) + case "bUpper95CI": + err = unpopulate(val, "BUpper95CI", &l.BUpper95CI) + delete(rawMsg, key) + case "bValue": + err = unpopulate(val, "BValue", &l.BValue) + delete(rawMsg, key) + case "delta": + err = unpopulate(val, "Delta", &l.Delta) + delete(rawMsg, key) + case "deltaPercent": + err = unpopulate(val, "DeltaPercent", &l.DeltaPercent) + delete(rawMsg, key) + case "endDateTimeUTC": + err = unpopulate(val, "EndDateTimeUTC", &l.EndDateTimeUTC) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &l.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LatencyScorecard. +func (l LatencyScorecard) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", l.ID) + populate(objectMap, "location", l.Location) + populate(objectMap, "name", l.Name) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "tags", l.Tags) + populate(objectMap, "type", l.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LatencyScorecard. +func (l *LatencyScorecard) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &l.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &l.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &l.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &l.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &l.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &l.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LatencyScorecardProperties. +func (l LatencyScorecardProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "country", l.Country) + populate(objectMap, "description", l.Description) + populateTimeRFC3339(objectMap, "endDateTimeUTC", l.EndDateTimeUTC) + populate(objectMap, "endpointA", l.EndpointA) + populate(objectMap, "endpointB", l.EndpointB) + populate(objectMap, "id", l.ID) + populate(objectMap, "latencyMetrics", l.LatencyMetrics) + populate(objectMap, "name", l.Name) + populateTimeRFC3339(objectMap, "startDateTimeUTC", l.StartDateTimeUTC) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LatencyScorecardProperties. +func (l *LatencyScorecardProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "country": + err = unpopulate(val, "Country", &l.Country) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &l.Description) + delete(rawMsg, key) + case "endDateTimeUTC": + err = unpopulateTimeRFC3339(val, "EndDateTimeUTC", &l.EndDateTimeUTC) + delete(rawMsg, key) + case "endpointA": + err = unpopulate(val, "EndpointA", &l.EndpointA) + delete(rawMsg, key) + case "endpointB": + err = unpopulate(val, "EndpointB", &l.EndpointB) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &l.ID) + delete(rawMsg, key) + case "latencyMetrics": + err = unpopulate(val, "LatencyMetrics", &l.LatencyMetrics) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &l.Name) + delete(rawMsg, key) + case "startDateTimeUTC": + err = unpopulateTimeRFC3339(val, "StartDateTimeUTC", &l.StartDateTimeUTC) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ListResult. +func (l ListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ListResult. +func (l *ListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &l.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &l.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LoadBalancingSettingsListResult. +func (l LoadBalancingSettingsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LoadBalancingSettingsListResult. +func (l *LoadBalancingSettingsListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &l.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &l.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LoadBalancingSettingsModel. +func (l LoadBalancingSettingsModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", l.ID) + populate(objectMap, "name", l.Name) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "type", l.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LoadBalancingSettingsModel. +func (l *LoadBalancingSettingsModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &l.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &l.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &l.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &l.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LoadBalancingSettingsProperties. +func (l LoadBalancingSettingsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalLatencyMilliseconds", l.AdditionalLatencyMilliseconds) + populate(objectMap, "resourceState", l.ResourceState) + populate(objectMap, "sampleSize", l.SampleSize) + populate(objectMap, "successfulSamplesRequired", l.SuccessfulSamplesRequired) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LoadBalancingSettingsProperties. +func (l *LoadBalancingSettingsProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalLatencyMilliseconds": + err = unpopulate(val, "AdditionalLatencyMilliseconds", &l.AdditionalLatencyMilliseconds) + delete(rawMsg, key) + case "resourceState": + err = unpopulate(val, "ResourceState", &l.ResourceState) + delete(rawMsg, key) + case "sampleSize": + err = unpopulate(val, "SampleSize", &l.SampleSize) + delete(rawMsg, key) + case "successfulSamplesRequired": + err = unpopulate(val, "SuccessfulSamplesRequired", &l.SuccessfulSamplesRequired) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LoadBalancingSettingsUpdateParameters. +func (l LoadBalancingSettingsUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalLatencyMilliseconds", l.AdditionalLatencyMilliseconds) + populate(objectMap, "sampleSize", l.SampleSize) + populate(objectMap, "successfulSamplesRequired", l.SuccessfulSamplesRequired) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LoadBalancingSettingsUpdateParameters. +func (l *LoadBalancingSettingsUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalLatencyMilliseconds": + err = unpopulate(val, "AdditionalLatencyMilliseconds", &l.AdditionalLatencyMilliseconds) + delete(rawMsg, key) + case "sampleSize": + err = unpopulate(val, "SampleSize", &l.SampleSize) + delete(rawMsg, key) + case "successfulSamplesRequired": + err = unpopulate(val, "SuccessfulSamplesRequired", &l.SuccessfulSamplesRequired) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedRuleDefinition. +func (m ManagedRuleDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "defaultAction", m.DefaultAction) + populate(objectMap, "defaultState", m.DefaultState) + populate(objectMap, "description", m.Description) + populate(objectMap, "ruleId", m.RuleID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedRuleDefinition. +func (m *ManagedRuleDefinition) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "defaultAction": + err = unpopulate(val, "DefaultAction", &m.DefaultAction) + delete(rawMsg, key) + case "defaultState": + err = unpopulate(val, "DefaultState", &m.DefaultState) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &m.Description) + delete(rawMsg, key) + case "ruleId": + err = unpopulate(val, "RuleID", &m.RuleID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedRuleExclusion. +func (m ManagedRuleExclusion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "matchVariable", m.MatchVariable) + populate(objectMap, "selector", m.Selector) + populate(objectMap, "selectorMatchOperator", m.SelectorMatchOperator) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedRuleExclusion. +func (m *ManagedRuleExclusion) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "matchVariable": + err = unpopulate(val, "MatchVariable", &m.MatchVariable) + delete(rawMsg, key) + case "selector": + err = unpopulate(val, "Selector", &m.Selector) + delete(rawMsg, key) + case "selectorMatchOperator": + err = unpopulate(val, "SelectorMatchOperator", &m.SelectorMatchOperator) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedRuleGroupDefinition. +func (m ManagedRuleGroupDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", m.Description) + populate(objectMap, "ruleGroupName", m.RuleGroupName) + populate(objectMap, "rules", m.Rules) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedRuleGroupDefinition. +func (m *ManagedRuleGroupDefinition) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &m.Description) + delete(rawMsg, key) + case "ruleGroupName": + err = unpopulate(val, "RuleGroupName", &m.RuleGroupName) + delete(rawMsg, key) + case "rules": + err = unpopulate(val, "Rules", &m.Rules) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedRuleGroupOverride. +func (m ManagedRuleGroupOverride) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "exclusions", m.Exclusions) + populate(objectMap, "ruleGroupName", m.RuleGroupName) + populate(objectMap, "rules", m.Rules) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedRuleGroupOverride. +func (m *ManagedRuleGroupOverride) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "exclusions": + err = unpopulate(val, "Exclusions", &m.Exclusions) + delete(rawMsg, key) + case "ruleGroupName": + err = unpopulate(val, "RuleGroupName", &m.RuleGroupName) + delete(rawMsg, key) + case "rules": + err = unpopulate(val, "Rules", &m.Rules) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedRuleOverride. +func (m ManagedRuleOverride) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "action", m.Action) + populate(objectMap, "enabledState", m.EnabledState) + populate(objectMap, "exclusions", m.Exclusions) + populate(objectMap, "ruleId", m.RuleID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedRuleOverride. +func (m *ManagedRuleOverride) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + err = unpopulate(val, "Action", &m.Action) + delete(rawMsg, key) + case "enabledState": + err = unpopulate(val, "EnabledState", &m.EnabledState) + delete(rawMsg, key) + case "exclusions": + err = unpopulate(val, "Exclusions", &m.Exclusions) + delete(rawMsg, key) + case "ruleId": + err = unpopulate(val, "RuleID", &m.RuleID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedRuleSet. +func (m ManagedRuleSet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "exclusions", m.Exclusions) + populate(objectMap, "ruleGroupOverrides", m.RuleGroupOverrides) + populate(objectMap, "ruleSetAction", m.RuleSetAction) + populate(objectMap, "ruleSetType", m.RuleSetType) + populate(objectMap, "ruleSetVersion", m.RuleSetVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedRuleSet. +func (m *ManagedRuleSet) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "exclusions": + err = unpopulate(val, "Exclusions", &m.Exclusions) + delete(rawMsg, key) + case "ruleGroupOverrides": + err = unpopulate(val, "RuleGroupOverrides", &m.RuleGroupOverrides) + delete(rawMsg, key) + case "ruleSetAction": + err = unpopulate(val, "RuleSetAction", &m.RuleSetAction) + delete(rawMsg, key) + case "ruleSetType": + err = unpopulate(val, "RuleSetType", &m.RuleSetType) + delete(rawMsg, key) + case "ruleSetVersion": + err = unpopulate(val, "RuleSetVersion", &m.RuleSetVersion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedRuleSetDefinition. +func (m ManagedRuleSetDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", m.ID) + populate(objectMap, "location", m.Location) + populate(objectMap, "name", m.Name) + populate(objectMap, "properties", m.Properties) + populate(objectMap, "tags", m.Tags) + populate(objectMap, "type", m.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedRuleSetDefinition. +func (m *ManagedRuleSetDefinition) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &m.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &m.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &m.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &m.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &m.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedRuleSetDefinitionList. +func (m ManagedRuleSetDefinitionList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", m.NextLink) + populate(objectMap, "value", m.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedRuleSetDefinitionList. +func (m *ManagedRuleSetDefinitionList) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &m.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &m.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedRuleSetDefinitionProperties. +func (m ManagedRuleSetDefinitionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisioningState", m.ProvisioningState) + populate(objectMap, "ruleGroups", m.RuleGroups) + populate(objectMap, "ruleSetId", m.RuleSetID) + populate(objectMap, "ruleSetType", m.RuleSetType) + populate(objectMap, "ruleSetVersion", m.RuleSetVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedRuleSetDefinitionProperties. +func (m *ManagedRuleSetDefinitionProperties) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &m.ProvisioningState) + delete(rawMsg, key) + case "ruleGroups": + err = unpopulate(val, "RuleGroups", &m.RuleGroups) + delete(rawMsg, key) + case "ruleSetId": + err = unpopulate(val, "RuleSetID", &m.RuleSetID) + delete(rawMsg, key) + case "ruleSetType": + err = unpopulate(val, "RuleSetType", &m.RuleSetType) + delete(rawMsg, key) + case "ruleSetVersion": + err = unpopulate(val, "RuleSetVersion", &m.RuleSetVersion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedRuleSetList. +func (m ManagedRuleSetList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "managedRuleSets", m.ManagedRuleSets) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedRuleSetList. +func (m *ManagedRuleSetList) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "managedRuleSets": + err = unpopulate(val, "ManagedRuleSets", &m.ManagedRuleSets) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MatchCondition. +func (m MatchCondition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "matchValue", m.MatchValue) + populate(objectMap, "matchVariable", m.MatchVariable) + populate(objectMap, "negateCondition", m.NegateCondition) + populate(objectMap, "operator", m.Operator) + populate(objectMap, "selector", m.Selector) + populate(objectMap, "transforms", m.Transforms) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MatchCondition. +func (m *MatchCondition) 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", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "matchValue": + err = unpopulate(val, "MatchValue", &m.MatchValue) + delete(rawMsg, key) + case "matchVariable": + err = unpopulate(val, "MatchVariable", &m.MatchVariable) + delete(rawMsg, key) + case "negateCondition": + err = unpopulate(val, "NegateCondition", &m.NegateCondition) + delete(rawMsg, key) + case "operator": + err = unpopulate(val, "Operator", &m.Operator) + delete(rawMsg, key) + case "selector": + err = unpopulate(val, "Selector", &m.Selector) + delete(rawMsg, key) + case "transforms": + err = unpopulate(val, "Transforms", &m.Transforms) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PolicySettings. +func (p PolicySettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "customBlockResponseBody", p.CustomBlockResponseBody) + populate(objectMap, "customBlockResponseStatusCode", p.CustomBlockResponseStatusCode) + populate(objectMap, "enabledState", p.EnabledState) + populate(objectMap, "mode", p.Mode) + populate(objectMap, "redirectUrl", p.RedirectURL) + populate(objectMap, "requestBodyCheck", p.RequestBodyCheck) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicySettings. +func (p *PolicySettings) 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 "customBlockResponseBody": + err = unpopulate(val, "CustomBlockResponseBody", &p.CustomBlockResponseBody) + delete(rawMsg, key) + case "customBlockResponseStatusCode": + err = unpopulate(val, "CustomBlockResponseStatusCode", &p.CustomBlockResponseStatusCode) + delete(rawMsg, key) + case "enabledState": + err = unpopulate(val, "EnabledState", &p.EnabledState) + delete(rawMsg, key) + case "mode": + err = unpopulate(val, "Mode", &p.Mode) + delete(rawMsg, key) + case "redirectUrl": + err = unpopulate(val, "RedirectURL", &p.RedirectURL) + delete(rawMsg, key) + case "requestBodyCheck": + err = unpopulate(val, "RequestBodyCheck", &p.RequestBodyCheck) + 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 PreconfiguredEndpoint. +func (p PreconfiguredEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "location", p.Location) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PreconfiguredEndpoint. +func (p *PreconfiguredEndpoint) 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 "location": + err = unpopulate(val, "Location", &p.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + 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 PreconfiguredEndpointList. +func (p PreconfiguredEndpointList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PreconfiguredEndpointList. +func (p *PreconfiguredEndpointList) 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 "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + 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 PreconfiguredEndpointProperties. +func (p PreconfiguredEndpointProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "backend", p.Backend) + populate(objectMap, "description", p.Description) + populate(objectMap, "endpoint", p.Endpoint) + populate(objectMap, "endpointType", p.EndpointType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PreconfiguredEndpointProperties. +func (p *PreconfiguredEndpointProperties) 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 "backend": + err = unpopulate(val, "Backend", &p.Backend) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "endpoint": + err = unpopulate(val, "Endpoint", &p.Endpoint) + delete(rawMsg, key) + case "endpointType": + err = unpopulate(val, "EndpointType", &p.EndpointType) + 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 Profile. +func (p Profile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", p.Etag) + populate(objectMap, "id", p.ID) + populate(objectMap, "location", p.Location) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Profile. +func (p *Profile) 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 "etag": + err = unpopulate(val, "Etag", &p.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &p.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + 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 ProfileList. +func (p ProfileList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProfileList. +func (p *ProfileList) 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 "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + 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 ProfileProperties. +func (p ProfileProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "enabledState", p.EnabledState) + populate(objectMap, "resourceState", p.ResourceState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProfileProperties. +func (p *ProfileProperties) 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 "enabledState": + err = unpopulate(val, "EnabledState", &p.EnabledState) + delete(rawMsg, key) + case "resourceState": + err = unpopulate(val, "ResourceState", &p.ResourceState) + 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 ProfileUpdateModel. +func (p ProfileUpdateModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProfileUpdateModel. +func (p *ProfileUpdateModel) 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 "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + 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 ProfileUpdateProperties. +func (p ProfileUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "enabledState", p.EnabledState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProfileUpdateProperties. +func (p *ProfileUpdateProperties) 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 "enabledState": + err = unpopulate(val, "EnabledState", &p.EnabledState) + 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 Properties. +func (p Properties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "backendPools", p.BackendPools) + populate(objectMap, "backendPoolsSettings", p.BackendPoolsSettings) + populate(objectMap, "cname", p.Cname) + populate(objectMap, "enabledState", p.EnabledState) + populate(objectMap, "friendlyName", p.FriendlyName) + populate(objectMap, "frontdoorId", p.FrontdoorID) + populate(objectMap, "frontendEndpoints", p.FrontendEndpoints) + populate(objectMap, "healthProbeSettings", p.HealthProbeSettings) + populate(objectMap, "loadBalancingSettings", p.LoadBalancingSettings) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "resourceState", p.ResourceState) + populate(objectMap, "routingRules", p.RoutingRules) + populate(objectMap, "rulesEngines", p.RulesEngines) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Properties. +func (p *Properties) 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 "backendPools": + err = unpopulate(val, "BackendPools", &p.BackendPools) + delete(rawMsg, key) + case "backendPoolsSettings": + err = unpopulate(val, "BackendPoolsSettings", &p.BackendPoolsSettings) + delete(rawMsg, key) + case "cname": + err = unpopulate(val, "Cname", &p.Cname) + delete(rawMsg, key) + case "enabledState": + err = unpopulate(val, "EnabledState", &p.EnabledState) + delete(rawMsg, key) + case "friendlyName": + err = unpopulate(val, "FriendlyName", &p.FriendlyName) + delete(rawMsg, key) + case "frontdoorId": + err = unpopulate(val, "FrontdoorID", &p.FrontdoorID) + delete(rawMsg, key) + case "frontendEndpoints": + err = unpopulate(val, "FrontendEndpoints", &p.FrontendEndpoints) + delete(rawMsg, key) + case "healthProbeSettings": + err = unpopulate(val, "HealthProbeSettings", &p.HealthProbeSettings) + delete(rawMsg, key) + case "loadBalancingSettings": + err = unpopulate(val, "LoadBalancingSettings", &p.LoadBalancingSettings) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + case "resourceState": + err = unpopulate(val, "ResourceState", &p.ResourceState) + delete(rawMsg, key) + case "routingRules": + err = unpopulate(val, "RoutingRules", &p.RoutingRules) + delete(rawMsg, key) + case "rulesEngines": + err = unpopulate(val, "RulesEngines", &p.RulesEngines) + 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 PurgeParameters. +func (p PurgeParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contentPaths", p.ContentPaths) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PurgeParameters. +func (p *PurgeParameters) 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 "contentPaths": + err = unpopulate(val, "ContentPaths", &p.ContentPaths) + 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 RedirectConfiguration. +func (r RedirectConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "customFragment", r.CustomFragment) + populate(objectMap, "customHost", r.CustomHost) + populate(objectMap, "customPath", r.CustomPath) + populate(objectMap, "customQueryString", r.CustomQueryString) + objectMap["@odata.type"] = "#Microsoft.Azure.FrontDoor.Models.FrontdoorRedirectConfiguration" + populate(objectMap, "redirectProtocol", r.RedirectProtocol) + populate(objectMap, "redirectType", r.RedirectType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RedirectConfiguration. +func (r *RedirectConfiguration) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "customFragment": + err = unpopulate(val, "CustomFragment", &r.CustomFragment) + delete(rawMsg, key) + case "customHost": + err = unpopulate(val, "CustomHost", &r.CustomHost) + delete(rawMsg, key) + case "customPath": + err = unpopulate(val, "CustomPath", &r.CustomPath) + delete(rawMsg, key) + case "customQueryString": + err = unpopulate(val, "CustomQueryString", &r.CustomQueryString) + delete(rawMsg, key) + case "@odata.type": + err = unpopulate(val, "ODataType", &r.ODataType) + delete(rawMsg, key) + case "redirectProtocol": + err = unpopulate(val, "RedirectProtocol", &r.RedirectProtocol) + delete(rawMsg, key) + case "redirectType": + err = unpopulate(val, "RedirectType", &r.RedirectType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "location", r.Location) + populate(objectMap, "name", r.Name) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &r.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RouteConfiguration. +func (r RouteConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["@odata.type"] = r.ODataType + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RouteConfiguration. +func (r *RouteConfiguration) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "@odata.type": + err = unpopulate(val, "ODataType", &r.ODataType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RoutingRule. +func (r RoutingRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RoutingRule. +func (r *RoutingRule) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RoutingRuleLink. +func (r RoutingRuleLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RoutingRuleLink. +func (r *RoutingRuleLink) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RoutingRuleListResult. +func (r RoutingRuleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RoutingRuleListResult. +func (r *RoutingRuleListResult) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RoutingRuleProperties. +func (r RoutingRuleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "acceptedProtocols", r.AcceptedProtocols) + populate(objectMap, "enabledState", r.EnabledState) + populate(objectMap, "frontendEndpoints", r.FrontendEndpoints) + populate(objectMap, "patternsToMatch", r.PatternsToMatch) + populate(objectMap, "resourceState", r.ResourceState) + populate(objectMap, "routeConfiguration", r.RouteConfiguration) + populate(objectMap, "rulesEngine", r.RulesEngine) + populate(objectMap, "webApplicationFirewallPolicyLink", r.WebApplicationFirewallPolicyLink) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RoutingRuleProperties. +func (r *RoutingRuleProperties) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "acceptedProtocols": + err = unpopulate(val, "AcceptedProtocols", &r.AcceptedProtocols) + delete(rawMsg, key) + case "enabledState": + err = unpopulate(val, "EnabledState", &r.EnabledState) + delete(rawMsg, key) + case "frontendEndpoints": + err = unpopulate(val, "FrontendEndpoints", &r.FrontendEndpoints) + delete(rawMsg, key) + case "patternsToMatch": + err = unpopulate(val, "PatternsToMatch", &r.PatternsToMatch) + delete(rawMsg, key) + case "resourceState": + err = unpopulate(val, "ResourceState", &r.ResourceState) + delete(rawMsg, key) + case "routeConfiguration": + r.RouteConfiguration, err = unmarshalRouteConfigurationClassification(val) + delete(rawMsg, key) + case "rulesEngine": + err = unpopulate(val, "RulesEngine", &r.RulesEngine) + delete(rawMsg, key) + case "webApplicationFirewallPolicyLink": + err = unpopulate(val, "WebApplicationFirewallPolicyLink", &r.WebApplicationFirewallPolicyLink) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RoutingRuleUpdateParameters. +func (r RoutingRuleUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "acceptedProtocols", r.AcceptedProtocols) + populate(objectMap, "enabledState", r.EnabledState) + populate(objectMap, "frontendEndpoints", r.FrontendEndpoints) + populate(objectMap, "patternsToMatch", r.PatternsToMatch) + populate(objectMap, "routeConfiguration", r.RouteConfiguration) + populate(objectMap, "rulesEngine", r.RulesEngine) + populate(objectMap, "webApplicationFirewallPolicyLink", r.WebApplicationFirewallPolicyLink) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RoutingRuleUpdateParameters. +func (r *RoutingRuleUpdateParameters) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "acceptedProtocols": + err = unpopulate(val, "AcceptedProtocols", &r.AcceptedProtocols) + delete(rawMsg, key) + case "enabledState": + err = unpopulate(val, "EnabledState", &r.EnabledState) + delete(rawMsg, key) + case "frontendEndpoints": + err = unpopulate(val, "FrontendEndpoints", &r.FrontendEndpoints) + delete(rawMsg, key) + case "patternsToMatch": + err = unpopulate(val, "PatternsToMatch", &r.PatternsToMatch) + delete(rawMsg, key) + case "routeConfiguration": + r.RouteConfiguration, err = unmarshalRouteConfigurationClassification(val) + delete(rawMsg, key) + case "rulesEngine": + err = unpopulate(val, "RulesEngine", &r.RulesEngine) + delete(rawMsg, key) + case "webApplicationFirewallPolicyLink": + err = unpopulate(val, "WebApplicationFirewallPolicyLink", &r.WebApplicationFirewallPolicyLink) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink. +func (r RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink. +func (r *RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RulesEngine. +func (r RulesEngine) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RulesEngine. +func (r *RulesEngine) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RulesEngineAction. +func (r RulesEngineAction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "requestHeaderActions", r.RequestHeaderActions) + populate(objectMap, "responseHeaderActions", r.ResponseHeaderActions) + populate(objectMap, "routeConfigurationOverride", r.RouteConfigurationOverride) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RulesEngineAction. +func (r *RulesEngineAction) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "requestHeaderActions": + err = unpopulate(val, "RequestHeaderActions", &r.RequestHeaderActions) + delete(rawMsg, key) + case "responseHeaderActions": + err = unpopulate(val, "ResponseHeaderActions", &r.ResponseHeaderActions) + delete(rawMsg, key) + case "routeConfigurationOverride": + r.RouteConfigurationOverride, err = unmarshalRouteConfigurationClassification(val) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RulesEngineListResult. +func (r RulesEngineListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RulesEngineListResult. +func (r *RulesEngineListResult) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RulesEngineMatchCondition. +func (r RulesEngineMatchCondition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "negateCondition", r.NegateCondition) + populate(objectMap, "rulesEngineMatchValue", r.RulesEngineMatchValue) + populate(objectMap, "rulesEngineMatchVariable", r.RulesEngineMatchVariable) + populate(objectMap, "rulesEngineOperator", r.RulesEngineOperator) + populate(objectMap, "selector", r.Selector) + populate(objectMap, "transforms", r.Transforms) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RulesEngineMatchCondition. +func (r *RulesEngineMatchCondition) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "negateCondition": + err = unpopulate(val, "NegateCondition", &r.NegateCondition) + delete(rawMsg, key) + case "rulesEngineMatchValue": + err = unpopulate(val, "RulesEngineMatchValue", &r.RulesEngineMatchValue) + delete(rawMsg, key) + case "rulesEngineMatchVariable": + err = unpopulate(val, "RulesEngineMatchVariable", &r.RulesEngineMatchVariable) + delete(rawMsg, key) + case "rulesEngineOperator": + err = unpopulate(val, "RulesEngineOperator", &r.RulesEngineOperator) + delete(rawMsg, key) + case "selector": + err = unpopulate(val, "Selector", &r.Selector) + delete(rawMsg, key) + case "transforms": + err = unpopulate(val, "Transforms", &r.Transforms) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RulesEngineProperties. +func (r RulesEngineProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceState", r.ResourceState) + populate(objectMap, "rules", r.Rules) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RulesEngineProperties. +func (r *RulesEngineProperties) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceState": + err = unpopulate(val, "ResourceState", &r.ResourceState) + delete(rawMsg, key) + case "rules": + err = unpopulate(val, "Rules", &r.Rules) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RulesEngineRule. +func (r RulesEngineRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "action", r.Action) + populate(objectMap, "matchConditions", r.MatchConditions) + populate(objectMap, "matchProcessingBehavior", r.MatchProcessingBehavior) + populate(objectMap, "name", r.Name) + populate(objectMap, "priority", r.Priority) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RulesEngineRule. +func (r *RulesEngineRule) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + err = unpopulate(val, "Action", &r.Action) + delete(rawMsg, key) + case "matchConditions": + err = unpopulate(val, "MatchConditions", &r.MatchConditions) + delete(rawMsg, key) + case "matchProcessingBehavior": + err = unpopulate(val, "MatchProcessingBehavior", &r.MatchProcessingBehavior) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "priority": + err = unpopulate(val, "Priority", &r.Priority) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RulesEngineUpdateParameters. +func (r RulesEngineUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "rules", r.Rules) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RulesEngineUpdateParameters. +func (r *RulesEngineUpdateParameters) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "rules": + err = unpopulate(val, "Rules", &r.Rules) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SKU. +func (s SKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", s.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKU. +func (s *SKU) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SecurityPolicyLink. +func (s SecurityPolicyLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SecurityPolicyLink. +func (s *SecurityPolicyLink) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SubResource. +func (s SubResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubResource. +func (s *SubResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TagsObject. +func (t TagsObject) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", t.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagsObject. +func (t *TagsObject) 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 "tags": + err = unpopulate(val, "Tags", &t.Tags) + 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 Timeseries. +func (t Timeseries) 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, "properties", t.Properties) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Timeseries. +func (t *Timeseries) 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 "properties": + err = unpopulate(val, "Properties", &t.Properties) + 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 TimeseriesDataPoint. +func (t TimeseriesDataPoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dateTimeUTC", t.DateTimeUTC) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TimeseriesDataPoint. +func (t *TimeseriesDataPoint) 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 "dateTimeUTC": + err = unpopulate(val, "DateTimeUTC", &t.DateTimeUTC) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + 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 TimeseriesProperties. +func (t TimeseriesProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "aggregationInterval", t.AggregationInterval) + populate(objectMap, "country", t.Country) + populate(objectMap, "endDateTimeUTC", t.EndDateTimeUTC) + populate(objectMap, "endpoint", t.Endpoint) + populate(objectMap, "startDateTimeUTC", t.StartDateTimeUTC) + populate(objectMap, "timeseriesData", t.TimeseriesData) + populate(objectMap, "timeseriesType", t.TimeseriesType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TimeseriesProperties. +func (t *TimeseriesProperties) 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 "aggregationInterval": + err = unpopulate(val, "AggregationInterval", &t.AggregationInterval) + delete(rawMsg, key) + case "country": + err = unpopulate(val, "Country", &t.Country) + delete(rawMsg, key) + case "endDateTimeUTC": + err = unpopulate(val, "EndDateTimeUTC", &t.EndDateTimeUTC) + delete(rawMsg, key) + case "endpoint": + err = unpopulate(val, "Endpoint", &t.Endpoint) + delete(rawMsg, key) + case "startDateTimeUTC": + err = unpopulate(val, "StartDateTimeUTC", &t.StartDateTimeUTC) + delete(rawMsg, key) + case "timeseriesData": + err = unpopulate(val, "TimeseriesData", &t.TimeseriesData) + delete(rawMsg, key) + case "timeseriesType": + err = unpopulate(val, "TimeseriesType", &t.TimeseriesType) + 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 UpdateParameters. +func (u UpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "backendPools", u.BackendPools) + populate(objectMap, "backendPoolsSettings", u.BackendPoolsSettings) + populate(objectMap, "enabledState", u.EnabledState) + populate(objectMap, "friendlyName", u.FriendlyName) + populate(objectMap, "frontendEndpoints", u.FrontendEndpoints) + populate(objectMap, "healthProbeSettings", u.HealthProbeSettings) + populate(objectMap, "loadBalancingSettings", u.LoadBalancingSettings) + populate(objectMap, "routingRules", u.RoutingRules) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateParameters. +func (u *UpdateParameters) 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", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "backendPools": + err = unpopulate(val, "BackendPools", &u.BackendPools) + delete(rawMsg, key) + case "backendPoolsSettings": + err = unpopulate(val, "BackendPoolsSettings", &u.BackendPoolsSettings) + delete(rawMsg, key) + case "enabledState": + err = unpopulate(val, "EnabledState", &u.EnabledState) + delete(rawMsg, key) + case "friendlyName": + err = unpopulate(val, "FriendlyName", &u.FriendlyName) + delete(rawMsg, key) + case "frontendEndpoints": + err = unpopulate(val, "FrontendEndpoints", &u.FrontendEndpoints) + delete(rawMsg, key) + case "healthProbeSettings": + err = unpopulate(val, "HealthProbeSettings", &u.HealthProbeSettings) + delete(rawMsg, key) + case "loadBalancingSettings": + err = unpopulate(val, "LoadBalancingSettings", &u.LoadBalancingSettings) + delete(rawMsg, key) + case "routingRules": + err = unpopulate(val, "RoutingRules", &u.RoutingRules) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ValidateCustomDomainInput. +func (v ValidateCustomDomainInput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "hostName", v.HostName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ValidateCustomDomainInput. +func (v *ValidateCustomDomainInput) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "hostName": + err = unpopulate(val, "HostName", &v.HostName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ValidateCustomDomainOutput. +func (v ValidateCustomDomainOutput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "customDomainValidated", v.CustomDomainValidated) + populate(objectMap, "message", v.Message) + populate(objectMap, "reason", v.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ValidateCustomDomainOutput. +func (v *ValidateCustomDomainOutput) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "customDomainValidated": + err = unpopulate(val, "CustomDomainValidated", &v.CustomDomainValidated) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &v.Message) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &v.Reason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WebApplicationFirewallPolicy. +func (w WebApplicationFirewallPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", w.Etag) + populate(objectMap, "id", w.ID) + populate(objectMap, "location", w.Location) + populate(objectMap, "name", w.Name) + populate(objectMap, "properties", w.Properties) + populate(objectMap, "sku", w.SKU) + populate(objectMap, "tags", w.Tags) + populate(objectMap, "type", w.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WebApplicationFirewallPolicy. +func (w *WebApplicationFirewallPolicy) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "etag": + err = unpopulate(val, "Etag", &w.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &w.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &w.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &w.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &w.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &w.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &w.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WebApplicationFirewallPolicyList. +func (w WebApplicationFirewallPolicyList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WebApplicationFirewallPolicyList. +func (w *WebApplicationFirewallPolicyList) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &w.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &w.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WebApplicationFirewallPolicyProperties. +func (w WebApplicationFirewallPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "customRules", w.CustomRules) + populate(objectMap, "frontendEndpointLinks", w.FrontendEndpointLinks) + populate(objectMap, "managedRules", w.ManagedRules) + populate(objectMap, "policySettings", w.PolicySettings) + populate(objectMap, "provisioningState", w.ProvisioningState) + populate(objectMap, "resourceState", w.ResourceState) + populate(objectMap, "routingRuleLinks", w.RoutingRuleLinks) + populate(objectMap, "securityPolicyLinks", w.SecurityPolicyLinks) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WebApplicationFirewallPolicyProperties. +func (w *WebApplicationFirewallPolicyProperties) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "customRules": + err = unpopulate(val, "CustomRules", &w.CustomRules) + delete(rawMsg, key) + case "frontendEndpointLinks": + err = unpopulate(val, "FrontendEndpointLinks", &w.FrontendEndpointLinks) + delete(rawMsg, key) + case "managedRules": + err = unpopulate(val, "ManagedRules", &w.ManagedRules) + delete(rawMsg, key) + case "policySettings": + err = unpopulate(val, "PolicySettings", &w.PolicySettings) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &w.ProvisioningState) + delete(rawMsg, key) + case "resourceState": + err = unpopulate(val, "ResourceState", &w.ResourceState) + delete(rawMsg, key) + case "routingRuleLinks": + err = unpopulate(val, "RoutingRuleLinks", &w.RoutingRuleLinks) + delete(rawMsg, key) + case "securityPolicyLinks": + err = unpopulate(val, "SecurityPolicyLinks", &w.SecurityPolicyLinks) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_nameavailability_client.go b/sdk/resourcemanager/frontdoor/armfrontdoor/nameavailability_client.go similarity index 77% rename from sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_nameavailability_client.go rename to sdk/resourcemanager/frontdoor/armfrontdoor/nameavailability_client.go index accbfc78fbc2..ed0b143c7d22 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_nameavailability_client.go +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/nameavailability_client.go @@ -5,6 +5,7 @@ // 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 armfrontdoor @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,43 +21,35 @@ import ( // NameAvailabilityClient contains the methods for the FrontDoorNameAvailability group. // Don't use this type directly, use NewNameAvailabilityClient() instead. type NameAvailabilityClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewNameAvailabilityClient creates a new instance of NameAvailabilityClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewNameAvailabilityClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*NameAvailabilityClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".NameAvailabilityClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &NameAvailabilityClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // Check - Check the availability of a Front Door resource name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// checkFrontDoorNameAvailabilityInput - Input to check. -// options - NameAvailabilityClientCheckOptions contains the optional parameters for the NameAvailabilityClient.Check method. +// - checkFrontDoorNameAvailabilityInput - Input to check. +// - options - NameAvailabilityClientCheckOptions contains the optional parameters for the NameAvailabilityClient.Check method. func (client *NameAvailabilityClient) Check(ctx context.Context, checkFrontDoorNameAvailabilityInput CheckNameAvailabilityInput, options *NameAvailabilityClientCheckOptions) (NameAvailabilityClientCheckResponse, error) { req, err := client.checkCreateRequest(ctx, checkFrontDoorNameAvailabilityInput, options) if err != nil { return NameAvailabilityClientCheckResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NameAvailabilityClientCheckResponse{}, err } @@ -71,7 +62,7 @@ func (client *NameAvailabilityClient) Check(ctx context.Context, checkFrontDoorN // checkCreateRequest creates the Check request. func (client *NameAvailabilityClient) checkCreateRequest(ctx context.Context, checkFrontDoorNameAvailabilityInput CheckNameAvailabilityInput, options *NameAvailabilityClientCheckOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Network/checkFrontDoorNameAvailability" - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/nameavailability_client_example_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/nameavailability_client_example_test.go new file mode 100644 index 000000000000..05d4fbf944e8 --- /dev/null +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/nameavailability_client_example_test.go @@ -0,0 +1,47 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armfrontdoor_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/frontdoor/armfrontdoor" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/CheckFrontdoorNameAvailability.json +func ExampleNameAvailabilityClient_Check() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewNameAvailabilityClient().Check(ctx, armfrontdoor.CheckNameAvailabilityInput{ + Name: to.Ptr("sampleName"), + Type: to.Ptr(armfrontdoor.ResourceTypeMicrosoftNetworkFrontDoors), + }, 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.CheckNameAvailabilityOutput = armfrontdoor.CheckNameAvailabilityOutput{ + // Message: to.Ptr("Name not available"), + // NameAvailability: to.Ptr(armfrontdoor.AvailabilityUnavailable), + // Reason: to.Ptr("Name is already in use"), + // } +} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_nameavailabilitywithsubscription_client.go b/sdk/resourcemanager/frontdoor/armfrontdoor/nameavailabilitywithsubscription_client.go similarity index 76% rename from sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_nameavailabilitywithsubscription_client.go rename to sdk/resourcemanager/frontdoor/armfrontdoor/nameavailabilitywithsubscription_client.go index 6b19fdbd6826..b258b8ea2675 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_nameavailabilitywithsubscription_client.go +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/nameavailabilitywithsubscription_client.go @@ -5,6 +5,7 @@ // 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 armfrontdoor @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,48 +24,40 @@ import ( // NameAvailabilityWithSubscriptionClient contains the methods for the FrontDoorNameAvailabilityWithSubscription group. // Don't use this type directly, use NewNameAvailabilityWithSubscriptionClient() instead. type NameAvailabilityWithSubscriptionClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewNameAvailabilityWithSubscriptionClient creates a new instance of NameAvailabilityWithSubscriptionClient with the specified values. -// subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription -// ID forms part of the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription +// ID forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewNameAvailabilityWithSubscriptionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*NameAvailabilityWithSubscriptionClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".NameAvailabilityWithSubscriptionClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &NameAvailabilityWithSubscriptionClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Check - Check the availability of a Front Door subdomain. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// checkFrontDoorNameAvailabilityInput - Input to check. -// options - NameAvailabilityWithSubscriptionClientCheckOptions contains the optional parameters for the NameAvailabilityWithSubscriptionClient.Check -// method. +// - checkFrontDoorNameAvailabilityInput - Input to check. +// - options - NameAvailabilityWithSubscriptionClientCheckOptions contains the optional parameters for the NameAvailabilityWithSubscriptionClient.Check +// method. func (client *NameAvailabilityWithSubscriptionClient) Check(ctx context.Context, checkFrontDoorNameAvailabilityInput CheckNameAvailabilityInput, options *NameAvailabilityWithSubscriptionClientCheckOptions) (NameAvailabilityWithSubscriptionClientCheckResponse, error) { req, err := client.checkCreateRequest(ctx, checkFrontDoorNameAvailabilityInput, options) if err != nil { return NameAvailabilityWithSubscriptionClientCheckResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NameAvailabilityWithSubscriptionClientCheckResponse{}, err } @@ -83,7 +74,7 @@ func (client *NameAvailabilityWithSubscriptionClient) checkCreateRequest(ctx con return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/nameavailabilitywithsubscription_client_example_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/nameavailabilitywithsubscription_client_example_test.go new file mode 100644 index 000000000000..c967df2cf933 --- /dev/null +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/nameavailabilitywithsubscription_client_example_test.go @@ -0,0 +1,47 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armfrontdoor_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/frontdoor/armfrontdoor" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/CheckFrontdoorNameAvailabilityWithSubscription.json +func ExampleNameAvailabilityWithSubscriptionClient_Check() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewNameAvailabilityWithSubscriptionClient().Check(ctx, armfrontdoor.CheckNameAvailabilityInput{ + Name: to.Ptr("sampleName"), + Type: to.Ptr(armfrontdoor.ResourceTypeMicrosoftNetworkFrontDoorsFrontendEndpoints), + }, 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.CheckNameAvailabilityOutput = armfrontdoor.CheckNameAvailabilityOutput{ + // Message: to.Ptr("Name not available"), + // NameAvailability: to.Ptr(armfrontdoor.AvailabilityUnavailable), + // Reason: to.Ptr("Name is already in use"), + // } +} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_networkexperimentprofiles_client.go b/sdk/resourcemanager/frontdoor/armfrontdoor/networkexperimentprofiles_client.go similarity index 84% rename from sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_networkexperimentprofiles_client.go rename to sdk/resourcemanager/frontdoor/armfrontdoor/networkexperimentprofiles_client.go index 2a781b1cb1c5..c9390ce6f507 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_networkexperimentprofiles_client.go +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/networkexperimentprofiles_client.go @@ -5,6 +5,7 @@ // 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 armfrontdoor @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,65 +24,58 @@ import ( // NetworkExperimentProfilesClient contains the methods for the NetworkExperimentProfiles group. // Don't use this type directly, use NewNetworkExperimentProfilesClient() instead. type NetworkExperimentProfilesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewNetworkExperimentProfilesClient creates a new instance of NetworkExperimentProfilesClient with the specified values. -// subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription -// ID forms part of the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription +// ID forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewNetworkExperimentProfilesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*NetworkExperimentProfilesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".NetworkExperimentProfilesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &NetworkExperimentProfilesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates an NetworkExperiment Profile // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 -// profileName - The Profile identifier associated with the Tenant and Partner -// resourceGroupName - Name of the Resource group within the Azure subscription. -// parameters - An Network Experiment Profile -// options - NetworkExperimentProfilesClientBeginCreateOrUpdateOptions contains the optional parameters for the NetworkExperimentProfilesClient.BeginCreateOrUpdate -// method. +// - profileName - The Profile identifier associated with the Tenant and Partner +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - parameters - An Network Experiment Profile +// - options - NetworkExperimentProfilesClientBeginCreateOrUpdateOptions contains the optional parameters for the NetworkExperimentProfilesClient.BeginCreateOrUpdate +// method. func (client *NetworkExperimentProfilesClient) BeginCreateOrUpdate(ctx context.Context, profileName string, resourceGroupName string, parameters Profile, options *NetworkExperimentProfilesClientBeginCreateOrUpdateOptions) (*runtime.Poller[NetworkExperimentProfilesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, profileName, resourceGroupName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[NetworkExperimentProfilesClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[NetworkExperimentProfilesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[NetworkExperimentProfilesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[NetworkExperimentProfilesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates an NetworkExperiment Profile // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 func (client *NetworkExperimentProfilesClient) createOrUpdate(ctx context.Context, profileName string, resourceGroupName string, parameters Profile, options *NetworkExperimentProfilesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, profileName, resourceGroupName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -108,7 +100,7 @@ func (client *NetworkExperimentProfilesClient) createOrUpdateCreateRequest(ctx c return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -121,32 +113,34 @@ func (client *NetworkExperimentProfilesClient) createOrUpdateCreateRequest(ctx c // BeginDelete - Deletes an NetworkExperiment Profile by ProfileName // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// profileName - The Profile identifier associated with the Tenant and Partner -// options - NetworkExperimentProfilesClientBeginDeleteOptions contains the optional parameters for the NetworkExperimentProfilesClient.BeginDelete -// method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - profileName - The Profile identifier associated with the Tenant and Partner +// - options - NetworkExperimentProfilesClientBeginDeleteOptions contains the optional parameters for the NetworkExperimentProfilesClient.BeginDelete +// method. func (client *NetworkExperimentProfilesClient) BeginDelete(ctx context.Context, resourceGroupName string, profileName string, options *NetworkExperimentProfilesClientBeginDeleteOptions) (*runtime.Poller[NetworkExperimentProfilesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, profileName, options) if err != nil { return nil, err } - return runtime.NewPoller[NetworkExperimentProfilesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[NetworkExperimentProfilesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[NetworkExperimentProfilesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[NetworkExperimentProfilesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes an NetworkExperiment Profile by ProfileName // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 func (client *NetworkExperimentProfilesClient) deleteOperation(ctx context.Context, resourceGroupName string, profileName string, options *NetworkExperimentProfilesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, profileName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -171,7 +165,7 @@ func (client *NetworkExperimentProfilesClient) deleteCreateRequest(ctx context.C return nil, errors.New("parameter profileName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{profileName}", url.PathEscape(profileName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -184,17 +178,18 @@ func (client *NetworkExperimentProfilesClient) deleteCreateRequest(ctx context.C // Get - Gets an NetworkExperiment Profile by ProfileName // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// profileName - The Profile identifier associated with the Tenant and Partner -// options - NetworkExperimentProfilesClientGetOptions contains the optional parameters for the NetworkExperimentProfilesClient.Get -// method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - profileName - The Profile identifier associated with the Tenant and Partner +// - options - NetworkExperimentProfilesClientGetOptions contains the optional parameters for the NetworkExperimentProfilesClient.Get +// method. func (client *NetworkExperimentProfilesClient) Get(ctx context.Context, resourceGroupName string, profileName string, options *NetworkExperimentProfilesClientGetOptions) (NetworkExperimentProfilesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, profileName, options) if err != nil { return NetworkExperimentProfilesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NetworkExperimentProfilesClientGetResponse{}, err } @@ -219,7 +214,7 @@ func (client *NetworkExperimentProfilesClient) getCreateRequest(ctx context.Cont return nil, errors.New("parameter profileName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{profileName}", url.PathEscape(profileName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -240,10 +235,10 @@ func (client *NetworkExperimentProfilesClient) getHandleResponse(resp *http.Resp } // NewListPager - Gets a list of Network Experiment Profiles under a subscription -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 -// options - NetworkExperimentProfilesClientListOptions contains the optional parameters for the NetworkExperimentProfilesClient.List -// method. +// - options - NetworkExperimentProfilesClientListOptions contains the optional parameters for the NetworkExperimentProfilesClient.NewListPager +// method. func (client *NetworkExperimentProfilesClient) NewListPager(options *NetworkExperimentProfilesClientListOptions) *runtime.Pager[NetworkExperimentProfilesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[NetworkExperimentProfilesClientListResponse]{ More: func(page NetworkExperimentProfilesClientListResponse) bool { @@ -260,7 +255,7 @@ func (client *NetworkExperimentProfilesClient) NewListPager(options *NetworkExpe if err != nil { return NetworkExperimentProfilesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NetworkExperimentProfilesClientListResponse{}, err } @@ -279,7 +274,7 @@ func (client *NetworkExperimentProfilesClient) listCreateRequest(ctx context.Con return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -300,11 +295,11 @@ func (client *NetworkExperimentProfilesClient) listHandleResponse(resp *http.Res } // NewListByResourceGroupPager - Gets a list of Network Experiment Profiles within a resource group under a subscription -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// options - NetworkExperimentProfilesClientListByResourceGroupOptions contains the optional parameters for the NetworkExperimentProfilesClient.ListByResourceGroup -// method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - options - NetworkExperimentProfilesClientListByResourceGroupOptions contains the optional parameters for the NetworkExperimentProfilesClient.NewListByResourceGroupPager +// method. func (client *NetworkExperimentProfilesClient) NewListByResourceGroupPager(resourceGroupName string, options *NetworkExperimentProfilesClientListByResourceGroupOptions) *runtime.Pager[NetworkExperimentProfilesClientListByResourceGroupResponse] { return runtime.NewPager(runtime.PagingHandler[NetworkExperimentProfilesClientListByResourceGroupResponse]{ More: func(page NetworkExperimentProfilesClientListByResourceGroupResponse) bool { @@ -321,7 +316,7 @@ func (client *NetworkExperimentProfilesClient) NewListByResourceGroupPager(resou if err != nil { return NetworkExperimentProfilesClientListByResourceGroupResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return NetworkExperimentProfilesClientListByResourceGroupResponse{}, err } @@ -344,7 +339,7 @@ func (client *NetworkExperimentProfilesClient) listByResourceGroupCreateRequest( return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -366,33 +361,35 @@ func (client *NetworkExperimentProfilesClient) listByResourceGroupHandleResponse // BeginUpdate - Updates an NetworkExperimentProfiles // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// profileName - The Profile identifier associated with the Tenant and Partner -// parameters - The Profile Update Model -// options - NetworkExperimentProfilesClientBeginUpdateOptions contains the optional parameters for the NetworkExperimentProfilesClient.BeginUpdate -// method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - profileName - The Profile identifier associated with the Tenant and Partner +// - parameters - The Profile Update Model +// - options - NetworkExperimentProfilesClientBeginUpdateOptions contains the optional parameters for the NetworkExperimentProfilesClient.BeginUpdate +// method. func (client *NetworkExperimentProfilesClient) BeginUpdate(ctx context.Context, resourceGroupName string, profileName string, parameters ProfileUpdateModel, options *NetworkExperimentProfilesClientBeginUpdateOptions) (*runtime.Poller[NetworkExperimentProfilesClientUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.update(ctx, resourceGroupName, profileName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[NetworkExperimentProfilesClientUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[NetworkExperimentProfilesClientUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[NetworkExperimentProfilesClientUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[NetworkExperimentProfilesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Update - Updates an NetworkExperimentProfiles // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 func (client *NetworkExperimentProfilesClient) update(ctx context.Context, resourceGroupName string, profileName string, parameters ProfileUpdateModel, options *NetworkExperimentProfilesClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, profileName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -417,7 +414,7 @@ func (client *NetworkExperimentProfilesClient) updateCreateRequest(ctx context.C return nil, errors.New("parameter profileName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{profileName}", url.PathEscape(profileName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/networkexperimentprofiles_client_example_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/networkexperimentprofiles_client_example_test.go new file mode 100644 index 000000000000..ada7e47a74f6 --- /dev/null +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/networkexperimentprofiles_client_example_test.go @@ -0,0 +1,204 @@ +//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 armfrontdoor_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/frontdoor/armfrontdoor" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentListProfiles.json +func ExampleNetworkExperimentProfilesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewNetworkExperimentProfilesClient().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.ProfileList = armfrontdoor.ProfileList{ + // Value: []*armfrontdoor.Profile{ + // { + // Name: to.Ptr("MyProfile"), + // Type: to.Ptr("Microsoft.Network/NetworkExperimentprofiles"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/MyResourceGroup/providers/Microsoft.Network/NetworkExperimentProfiles/"), + // Location: to.Ptr("WestUs"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armfrontdoor.ProfileProperties{ + // EnabledState: to.Ptr(armfrontdoor.StateEnabled), + // ResourceState: to.Ptr(armfrontdoor.NetworkExperimentResourceStateCreating), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentGetProfile.json +func ExampleNetworkExperimentProfilesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewNetworkExperimentProfilesClient().Get(ctx, "MyResourceGroup", "MyProfile", 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.Profile = armfrontdoor.Profile{ + // Name: to.Ptr("MyProfile"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/MyResourceGroup/providers/Microsoft.Network/NetworkExperimentProfiles/MyProfile"), + // Location: to.Ptr("WestUs"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armfrontdoor.ProfileProperties{ + // EnabledState: to.Ptr(armfrontdoor.StateEnabled), + // ResourceState: to.Ptr(armfrontdoor.NetworkExperimentResourceStateCreating), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentCreateProfile.json +func ExampleNetworkExperimentProfilesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewNetworkExperimentProfilesClient().BeginCreateOrUpdate(ctx, "MyProfile", "MyResourceGroup", armfrontdoor.Profile{ + Location: to.Ptr("WestUs"), + Properties: &armfrontdoor.ProfileProperties{ + EnabledState: to.Ptr(armfrontdoor.StateEnabled), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Profile = armfrontdoor.Profile{ + // Name: to.Ptr("MyProfile"), + // Type: to.Ptr("Microsoft.Network/NetworkExperimentprofiles"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/MyResourceGroup/providers/Microsoft.Network/NetworkExperimentProfiles/MyProfile"), + // Location: to.Ptr("WestUs"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armfrontdoor.ProfileProperties{ + // EnabledState: to.Ptr(armfrontdoor.StateEnabled), + // ResourceState: to.Ptr(armfrontdoor.NetworkExperimentResourceStateCreating), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentUpdateProfile.json +func ExampleNetworkExperimentProfilesClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewNetworkExperimentProfilesClient().BeginUpdate(ctx, "MyResourceGroup", "MyProfile", armfrontdoor.ProfileUpdateModel{ + Properties: &armfrontdoor.ProfileUpdateProperties{ + EnabledState: to.Ptr(armfrontdoor.StateEnabled), + }, + Tags: map[string]*string{ + "key1": to.Ptr("value1"), + "key2": to.Ptr("value2"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Profile = armfrontdoor.Profile{ + // Name: to.Ptr("MyProfile"), + // Type: to.Ptr("Microsoft.Network/NetworkExperimentprofiles"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/MyResourceGroup/providers/Microsoft.Network/NetworkExperimentProfiles/MyProfile"), + // Location: to.Ptr("WestUs"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armfrontdoor.ProfileProperties{ + // EnabledState: to.Ptr(armfrontdoor.StateEnabled), + // ResourceState: to.Ptr(armfrontdoor.NetworkExperimentResourceStateCreating), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentDeleteProfile.json +func ExampleNetworkExperimentProfilesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewNetworkExperimentProfilesClient().BeginDelete(ctx, "MyResourceGroup", "MyProfile", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_policies_client.go b/sdk/resourcemanager/frontdoor/armfrontdoor/policies_client.go similarity index 83% rename from sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_policies_client.go rename to sdk/resourcemanager/frontdoor/armfrontdoor/policies_client.go index 72b97c7c9b92..0ae9550d7143 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_policies_client.go +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/policies_client.go @@ -5,6 +5,7 @@ // 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 armfrontdoor @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,65 +24,58 @@ import ( // PoliciesClient contains the methods for the Policies group. // Don't use this type directly, use NewPoliciesClient() instead. type PoliciesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPoliciesClient creates a new instance of PoliciesClient with the specified values. -// subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription -// ID forms part of the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription +// ID forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PoliciesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".PoliciesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PoliciesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Create or update policy with specified rule set name within a resource group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-11-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// policyName - The name of the Web Application Firewall Policy. -// parameters - Policy to be created. -// options - PoliciesClientBeginCreateOrUpdateOptions contains the optional parameters for the PoliciesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - policyName - The name of the Web Application Firewall Policy. +// - parameters - Policy to be created. +// - options - PoliciesClientBeginCreateOrUpdateOptions contains the optional parameters for the PoliciesClient.BeginCreateOrUpdate +// method. func (client *PoliciesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, policyName string, parameters WebApplicationFirewallPolicy, options *PoliciesClientBeginCreateOrUpdateOptions) (*runtime.Poller[PoliciesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, policyName, parameters, options) if err != nil { return nil, err } - return runtime.NewPoller[PoliciesClientCreateOrUpdateResponse](resp, client.pl, nil) + return runtime.NewPoller[PoliciesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[PoliciesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PoliciesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Create or update policy with specified rule set name within a resource group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-11-01 func (client *PoliciesClient) createOrUpdate(ctx context.Context, resourceGroupName string, policyName string, parameters WebApplicationFirewallPolicy, options *PoliciesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, policyName, parameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -108,7 +100,7 @@ func (client *PoliciesClient) createOrUpdateCreateRequest(ctx context.Context, r return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -121,31 +113,33 @@ func (client *PoliciesClient) createOrUpdateCreateRequest(ctx context.Context, r // BeginDelete - Deletes Policy // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-11-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// policyName - The name of the Web Application Firewall Policy. -// options - PoliciesClientBeginDeleteOptions contains the optional parameters for the PoliciesClient.BeginDelete method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - policyName - The name of the Web Application Firewall Policy. +// - options - PoliciesClientBeginDeleteOptions contains the optional parameters for the PoliciesClient.BeginDelete method. func (client *PoliciesClient) BeginDelete(ctx context.Context, resourceGroupName string, policyName string, options *PoliciesClientBeginDeleteOptions) (*runtime.Poller[PoliciesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, policyName, options) if err != nil { return nil, err } - return runtime.NewPoller[PoliciesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[PoliciesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[PoliciesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[PoliciesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes Policy // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-11-01 func (client *PoliciesClient) deleteOperation(ctx context.Context, resourceGroupName string, policyName string, options *PoliciesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, policyName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -170,7 +164,7 @@ func (client *PoliciesClient) deleteCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -182,16 +176,17 @@ func (client *PoliciesClient) deleteCreateRequest(ctx context.Context, resourceG // Get - Retrieve protection policy with specified name within a resource group. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-11-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// policyName - The name of the Web Application Firewall Policy. -// options - PoliciesClientGetOptions contains the optional parameters for the PoliciesClient.Get method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - policyName - The name of the Web Application Firewall Policy. +// - options - PoliciesClientGetOptions contains the optional parameters for the PoliciesClient.Get method. func (client *PoliciesClient) Get(ctx context.Context, resourceGroupName string, policyName string, options *PoliciesClientGetOptions) (PoliciesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, policyName, options) if err != nil { return PoliciesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PoliciesClientGetResponse{}, err } @@ -216,7 +211,7 @@ func (client *PoliciesClient) getCreateRequest(ctx context.Context, resourceGrou return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -237,10 +232,10 @@ func (client *PoliciesClient) getHandleResponse(resp *http.Response) (PoliciesCl } // NewListPager - Lists all of the protection policies within a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-11-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// options - PoliciesClientListOptions contains the optional parameters for the PoliciesClient.List method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - options - PoliciesClientListOptions contains the optional parameters for the PoliciesClient.NewListPager method. func (client *PoliciesClient) NewListPager(resourceGroupName string, options *PoliciesClientListOptions) *runtime.Pager[PoliciesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[PoliciesClientListResponse]{ More: func(page PoliciesClientListResponse) bool { @@ -257,7 +252,7 @@ func (client *PoliciesClient) NewListPager(resourceGroupName string, options *Po if err != nil { return PoliciesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PoliciesClientListResponse{}, err } @@ -280,7 +275,7 @@ func (client *PoliciesClient) listCreateRequest(ctx context.Context, resourceGro return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/policies_client_example_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/policies_client_example_test.go new file mode 100644 index 000000000000..9f04ad5adca7 --- /dev/null +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/policies_client_example_test.go @@ -0,0 +1,545 @@ +//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 armfrontdoor_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/frontdoor/armfrontdoor" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-11-01/examples/WafListPolicies.json +func ExamplePoliciesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPoliciesClient().NewListPager("rg1", 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.WebApplicationFirewallPolicyList = armfrontdoor.WebApplicationFirewallPolicyList{ + // Value: []*armfrontdoor.WebApplicationFirewallPolicy{ + // { + // Name: to.Ptr("Policy1"), + // Type: to.Ptr("Microsoft.Network/frontdoorwebapplicationfirewallpolicies"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/FrontDoorWebApplicationFirewallPolicies/Policy1"), + // Location: to.Ptr("WestUs"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armfrontdoor.WebApplicationFirewallPolicyProperties{ + // CustomRules: &armfrontdoor.CustomRuleList{ + // Rules: []*armfrontdoor.CustomRule{ + // { + // Name: to.Ptr("Rule1"), + // Action: to.Ptr(armfrontdoor.ActionTypeBlock), + // EnabledState: to.Ptr(armfrontdoor.CustomRuleEnabledStateEnabled), + // MatchConditions: []*armfrontdoor.MatchCondition{ + // { + // MatchValue: []*string{ + // to.Ptr("192.168.1.0/24"), + // to.Ptr("10.0.0.0/24")}, + // MatchVariable: to.Ptr(armfrontdoor.MatchVariableRemoteAddr), + // NegateCondition: to.Ptr(false), + // Operator: to.Ptr(armfrontdoor.OperatorIPMatch), + // Transforms: []*armfrontdoor.TransformType{ + // }, + // }}, + // Priority: to.Ptr[int32](1), + // RateLimitDurationInMinutes: to.Ptr[int32](0), + // RateLimitThreshold: to.Ptr[int32](1000), + // RuleType: to.Ptr(armfrontdoor.RuleTypeRateLimitRule), + // }, + // { + // Name: to.Ptr("Rule2"), + // Action: to.Ptr(armfrontdoor.ActionTypeBlock), + // EnabledState: to.Ptr(armfrontdoor.CustomRuleEnabledStateEnabled), + // MatchConditions: []*armfrontdoor.MatchCondition{ + // { + // MatchValue: []*string{ + // to.Ptr("CH")}, + // MatchVariable: to.Ptr(armfrontdoor.MatchVariableRemoteAddr), + // NegateCondition: to.Ptr(false), + // Operator: to.Ptr(armfrontdoor.OperatorGeoMatch), + // }, + // { + // MatchValue: []*string{ + // to.Ptr("windows")}, + // MatchVariable: to.Ptr(armfrontdoor.MatchVariableRequestHeader), + // NegateCondition: to.Ptr(false), + // Operator: to.Ptr(armfrontdoor.OperatorContains), + // Selector: to.Ptr("UserAgent"), + // Transforms: []*armfrontdoor.TransformType{ + // to.Ptr(armfrontdoor.TransformTypeLowercase)}, + // }}, + // Priority: to.Ptr[int32](2), + // RateLimitDurationInMinutes: to.Ptr[int32](0), + // RateLimitThreshold: to.Ptr[int32](0), + // RuleType: to.Ptr(armfrontdoor.RuleTypeMatchRule), + // }}, + // }, + // FrontendEndpointLinks: []*armfrontdoor.FrontendEndpointLink{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontdoors/fd1/frontendendpoints/fd1-azurefd-net"), + // }}, + // ManagedRules: &armfrontdoor.ManagedRuleSetList{ + // ManagedRuleSets: []*armfrontdoor.ManagedRuleSet{ + // { + // Exclusions: []*armfrontdoor.ManagedRuleExclusion{ + // { + // MatchVariable: to.Ptr(armfrontdoor.ManagedRuleExclusionMatchVariableRequestHeaderNames), + // Selector: to.Ptr("User-Agent"), + // SelectorMatchOperator: to.Ptr(armfrontdoor.ManagedRuleExclusionSelectorMatchOperatorEquals), + // }}, + // RuleGroupOverrides: []*armfrontdoor.ManagedRuleGroupOverride{ + // { + // RuleGroupName: to.Ptr("SQLI"), + // Rules: []*armfrontdoor.ManagedRuleOverride{ + // { + // Action: to.Ptr(armfrontdoor.ActionTypeRedirect), + // EnabledState: to.Ptr(armfrontdoor.ManagedRuleEnabledStateEnabled), + // RuleID: to.Ptr("942100"), + // }, + // { + // EnabledState: to.Ptr(armfrontdoor.ManagedRuleEnabledStateDisabled), + // RuleID: to.Ptr("942110"), + // }}, + // }}, + // RuleSetType: to.Ptr("DefaultRuleSet"), + // RuleSetVersion: to.Ptr("1.0"), + // }}, + // }, + // PolicySettings: &armfrontdoor.PolicySettings{ + // CustomBlockResponseBody: to.Ptr("PGh0bWw+CjxoZWFkZXI+PHRpdGxlPkhlbGxvPC90aXRsZT48L2hlYWRlcj4KPGJvZHk+CkhlbGxvIHdvcmxkCjwvYm9keT4KPC9odG1sPg=="), + // CustomBlockResponseStatusCode: to.Ptr[int32](499), + // EnabledState: to.Ptr(armfrontdoor.PolicyEnabledStateEnabled), + // Mode: to.Ptr(armfrontdoor.PolicyModePrevention), + // RedirectURL: to.Ptr("http://www.bing.com"), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armfrontdoor.PolicyResourceStateEnabled), + // SecurityPolicyLinks: []*armfrontdoor.SecurityPolicyLink{ + // }, + // }, + // SKU: &armfrontdoor.SKU{ + // Name: to.Ptr(armfrontdoor.SKUNameClassicAzureFrontDoor), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-11-01/examples/WafPolicyGet.json +func ExamplePoliciesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewPoliciesClient().Get(ctx, "rg1", "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.WebApplicationFirewallPolicy = armfrontdoor.WebApplicationFirewallPolicy{ + // Name: to.Ptr("Policy1"), + // Type: to.Ptr("Microsoft.Network/frontdoorwebapplicationfirewallpolicies"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/FrontDoorWebApplicationFirewallPolicies/Policy1"), + // Location: to.Ptr("WestUs"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armfrontdoor.WebApplicationFirewallPolicyProperties{ + // CustomRules: &armfrontdoor.CustomRuleList{ + // Rules: []*armfrontdoor.CustomRule{ + // { + // Name: to.Ptr("Rule1"), + // Action: to.Ptr(armfrontdoor.ActionTypeBlock), + // EnabledState: to.Ptr(armfrontdoor.CustomRuleEnabledStateEnabled), + // MatchConditions: []*armfrontdoor.MatchCondition{ + // { + // MatchValue: []*string{ + // to.Ptr("192.168.1.0/24"), + // to.Ptr("10.0.0.0/24")}, + // MatchVariable: to.Ptr(armfrontdoor.MatchVariableRemoteAddr), + // NegateCondition: to.Ptr(false), + // Operator: to.Ptr(armfrontdoor.OperatorIPMatch), + // Transforms: []*armfrontdoor.TransformType{ + // }, + // }}, + // Priority: to.Ptr[int32](1), + // RateLimitDurationInMinutes: to.Ptr[int32](0), + // RateLimitThreshold: to.Ptr[int32](1000), + // RuleType: to.Ptr(armfrontdoor.RuleTypeRateLimitRule), + // }, + // { + // Name: to.Ptr("Rule2"), + // Action: to.Ptr(armfrontdoor.ActionTypeBlock), + // EnabledState: to.Ptr(armfrontdoor.CustomRuleEnabledStateEnabled), + // MatchConditions: []*armfrontdoor.MatchCondition{ + // { + // MatchValue: []*string{ + // to.Ptr("CH")}, + // MatchVariable: to.Ptr(armfrontdoor.MatchVariableRemoteAddr), + // NegateCondition: to.Ptr(false), + // Operator: to.Ptr(armfrontdoor.OperatorGeoMatch), + // }, + // { + // MatchValue: []*string{ + // to.Ptr("windows")}, + // MatchVariable: to.Ptr(armfrontdoor.MatchVariableRequestHeader), + // NegateCondition: to.Ptr(false), + // Operator: to.Ptr(armfrontdoor.OperatorContains), + // Selector: to.Ptr("UserAgent"), + // Transforms: []*armfrontdoor.TransformType{ + // to.Ptr(armfrontdoor.TransformTypeLowercase)}, + // }}, + // Priority: to.Ptr[int32](2), + // RateLimitDurationInMinutes: to.Ptr[int32](0), + // RateLimitThreshold: to.Ptr[int32](0), + // RuleType: to.Ptr(armfrontdoor.RuleTypeMatchRule), + // }}, + // }, + // FrontendEndpointLinks: []*armfrontdoor.FrontendEndpointLink{ + // { + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontdoors/fd1/frontendendpoints/fd1-azurefd-net"), + // }}, + // ManagedRules: &armfrontdoor.ManagedRuleSetList{ + // ManagedRuleSets: []*armfrontdoor.ManagedRuleSet{ + // { + // Exclusions: []*armfrontdoor.ManagedRuleExclusion{ + // { + // MatchVariable: to.Ptr(armfrontdoor.ManagedRuleExclusionMatchVariableRequestHeaderNames), + // Selector: to.Ptr("User-Agent"), + // SelectorMatchOperator: to.Ptr(armfrontdoor.ManagedRuleExclusionSelectorMatchOperatorEquals), + // }}, + // RuleGroupOverrides: []*armfrontdoor.ManagedRuleGroupOverride{ + // { + // Exclusions: []*armfrontdoor.ManagedRuleExclusion{ + // }, + // RuleGroupName: to.Ptr("SQLI"), + // Rules: []*armfrontdoor.ManagedRuleOverride{ + // { + // Action: to.Ptr(armfrontdoor.ActionTypeRedirect), + // EnabledState: to.Ptr(armfrontdoor.ManagedRuleEnabledStateEnabled), + // Exclusions: []*armfrontdoor.ManagedRuleExclusion{ + // }, + // RuleID: to.Ptr("942100"), + // }, + // { + // EnabledState: to.Ptr(armfrontdoor.ManagedRuleEnabledStateDisabled), + // RuleID: to.Ptr("942110"), + // }}, + // }}, + // RuleSetAction: to.Ptr(armfrontdoor.ManagedRuleSetActionTypeBlock), + // RuleSetType: to.Ptr("DefaultRuleSet"), + // RuleSetVersion: to.Ptr("1.0"), + // }}, + // }, + // PolicySettings: &armfrontdoor.PolicySettings{ + // CustomBlockResponseBody: to.Ptr("PGh0bWw+CjxoZWFkZXI+PHRpdGxlPkhlbGxvPC90aXRsZT48L2hlYWRlcj4KPGJvZHk+CkhlbGxvIHdvcmxkCjwvYm9keT4KPC9odG1sPg=="), + // CustomBlockResponseStatusCode: to.Ptr[int32](499), + // EnabledState: to.Ptr(armfrontdoor.PolicyEnabledStateEnabled), + // Mode: to.Ptr(armfrontdoor.PolicyModePrevention), + // RedirectURL: to.Ptr("http://www.bing.com"), + // RequestBodyCheck: to.Ptr(armfrontdoor.PolicyRequestBodyCheckDisabled), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armfrontdoor.PolicyResourceStateEnabled), + // SecurityPolicyLinks: []*armfrontdoor.SecurityPolicyLink{ + // }, + // }, + // SKU: &armfrontdoor.SKU{ + // Name: to.Ptr(armfrontdoor.SKUNameClassicAzureFrontDoor), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-11-01/examples/WafPolicyCreateOrUpdate.json +func ExamplePoliciesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewPoliciesClient().BeginCreateOrUpdate(ctx, "rg1", "Policy1", armfrontdoor.WebApplicationFirewallPolicy{ + Properties: &armfrontdoor.WebApplicationFirewallPolicyProperties{ + CustomRules: &armfrontdoor.CustomRuleList{ + Rules: []*armfrontdoor.CustomRule{ + { + Name: to.Ptr("Rule1"), + Action: to.Ptr(armfrontdoor.ActionTypeBlock), + MatchConditions: []*armfrontdoor.MatchCondition{ + { + MatchValue: []*string{ + to.Ptr("192.168.1.0/24"), + to.Ptr("10.0.0.0/24")}, + MatchVariable: to.Ptr(armfrontdoor.MatchVariableRemoteAddr), + Operator: to.Ptr(armfrontdoor.OperatorIPMatch), + }}, + Priority: to.Ptr[int32](1), + RateLimitThreshold: to.Ptr[int32](1000), + RuleType: to.Ptr(armfrontdoor.RuleTypeRateLimitRule), + }, + { + Name: to.Ptr("Rule2"), + Action: to.Ptr(armfrontdoor.ActionTypeBlock), + MatchConditions: []*armfrontdoor.MatchCondition{ + { + MatchValue: []*string{ + to.Ptr("CH")}, + MatchVariable: to.Ptr(armfrontdoor.MatchVariableRemoteAddr), + Operator: to.Ptr(armfrontdoor.OperatorGeoMatch), + }, + { + MatchValue: []*string{ + to.Ptr("windows")}, + MatchVariable: to.Ptr(armfrontdoor.MatchVariableRequestHeader), + Operator: to.Ptr(armfrontdoor.OperatorContains), + Selector: to.Ptr("UserAgent"), + Transforms: []*armfrontdoor.TransformType{ + to.Ptr(armfrontdoor.TransformTypeLowercase)}, + }}, + Priority: to.Ptr[int32](2), + RuleType: to.Ptr(armfrontdoor.RuleTypeMatchRule), + }}, + }, + ManagedRules: &armfrontdoor.ManagedRuleSetList{ + ManagedRuleSets: []*armfrontdoor.ManagedRuleSet{ + { + Exclusions: []*armfrontdoor.ManagedRuleExclusion{ + { + MatchVariable: to.Ptr(armfrontdoor.ManagedRuleExclusionMatchVariableRequestHeaderNames), + Selector: to.Ptr("User-Agent"), + SelectorMatchOperator: to.Ptr(armfrontdoor.ManagedRuleExclusionSelectorMatchOperatorEquals), + }}, + RuleGroupOverrides: []*armfrontdoor.ManagedRuleGroupOverride{ + { + Exclusions: []*armfrontdoor.ManagedRuleExclusion{ + { + MatchVariable: to.Ptr(armfrontdoor.ManagedRuleExclusionMatchVariableRequestCookieNames), + Selector: to.Ptr("token"), + SelectorMatchOperator: to.Ptr(armfrontdoor.ManagedRuleExclusionSelectorMatchOperatorStartsWith), + }}, + RuleGroupName: to.Ptr("SQLI"), + Rules: []*armfrontdoor.ManagedRuleOverride{ + { + Action: to.Ptr(armfrontdoor.ActionTypeRedirect), + EnabledState: to.Ptr(armfrontdoor.ManagedRuleEnabledStateEnabled), + Exclusions: []*armfrontdoor.ManagedRuleExclusion{ + { + MatchVariable: to.Ptr(armfrontdoor.ManagedRuleExclusionMatchVariableQueryStringArgNames), + Selector: to.Ptr("query"), + SelectorMatchOperator: to.Ptr(armfrontdoor.ManagedRuleExclusionSelectorMatchOperatorEquals), + }}, + RuleID: to.Ptr("942100"), + }, + { + EnabledState: to.Ptr(armfrontdoor.ManagedRuleEnabledStateDisabled), + RuleID: to.Ptr("942110"), + }}, + }}, + RuleSetAction: to.Ptr(armfrontdoor.ManagedRuleSetActionTypeBlock), + RuleSetType: to.Ptr("DefaultRuleSet"), + RuleSetVersion: to.Ptr("1.0"), + }}, + }, + PolicySettings: &armfrontdoor.PolicySettings{ + CustomBlockResponseBody: to.Ptr("PGh0bWw+CjxoZWFkZXI+PHRpdGxlPkhlbGxvPC90aXRsZT48L2hlYWRlcj4KPGJvZHk+CkhlbGxvIHdvcmxkCjwvYm9keT4KPC9odG1sPg=="), + CustomBlockResponseStatusCode: to.Ptr[int32](499), + EnabledState: to.Ptr(armfrontdoor.PolicyEnabledStateEnabled), + Mode: to.Ptr(armfrontdoor.PolicyModePrevention), + RedirectURL: to.Ptr("http://www.bing.com"), + RequestBodyCheck: to.Ptr(armfrontdoor.PolicyRequestBodyCheckDisabled), + }, + }, + SKU: &armfrontdoor.SKU{ + Name: to.Ptr(armfrontdoor.SKUNameClassicAzureFrontDoor), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.WebApplicationFirewallPolicy = armfrontdoor.WebApplicationFirewallPolicy{ + // Name: to.Ptr("Policy1"), + // Type: to.Ptr("Microsoft.Network/frontdoorwebapplicationfirewallpolicies"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/FrontDoorWebApplicationFirewallPolicies/Policy1"), + // Location: to.Ptr("WestUs"), + // Tags: map[string]*string{ + // "key1": to.Ptr("value1"), + // "key2": to.Ptr("value2"), + // }, + // Properties: &armfrontdoor.WebApplicationFirewallPolicyProperties{ + // CustomRules: &armfrontdoor.CustomRuleList{ + // Rules: []*armfrontdoor.CustomRule{ + // { + // Name: to.Ptr("Rule1"), + // Action: to.Ptr(armfrontdoor.ActionTypeBlock), + // EnabledState: to.Ptr(armfrontdoor.CustomRuleEnabledStateEnabled), + // MatchConditions: []*armfrontdoor.MatchCondition{ + // { + // MatchValue: []*string{ + // to.Ptr("192.168.1.0/24"), + // to.Ptr("10.0.0.0/24")}, + // MatchVariable: to.Ptr(armfrontdoor.MatchVariableRemoteAddr), + // NegateCondition: to.Ptr(false), + // Operator: to.Ptr(armfrontdoor.OperatorIPMatch), + // Transforms: []*armfrontdoor.TransformType{ + // }, + // }}, + // Priority: to.Ptr[int32](1), + // RateLimitDurationInMinutes: to.Ptr[int32](0), + // RateLimitThreshold: to.Ptr[int32](1000), + // RuleType: to.Ptr(armfrontdoor.RuleTypeRateLimitRule), + // }, + // { + // Name: to.Ptr("Rule2"), + // Action: to.Ptr(armfrontdoor.ActionTypeBlock), + // EnabledState: to.Ptr(armfrontdoor.CustomRuleEnabledStateEnabled), + // MatchConditions: []*armfrontdoor.MatchCondition{ + // { + // MatchValue: []*string{ + // to.Ptr("CH")}, + // MatchVariable: to.Ptr(armfrontdoor.MatchVariableRemoteAddr), + // NegateCondition: to.Ptr(false), + // Operator: to.Ptr(armfrontdoor.OperatorGeoMatch), + // }, + // { + // MatchValue: []*string{ + // to.Ptr("windows")}, + // MatchVariable: to.Ptr(armfrontdoor.MatchVariableRequestHeader), + // NegateCondition: to.Ptr(false), + // Operator: to.Ptr(armfrontdoor.OperatorContains), + // Selector: to.Ptr("UserAgent"), + // Transforms: []*armfrontdoor.TransformType{ + // to.Ptr(armfrontdoor.TransformTypeLowercase)}, + // }}, + // Priority: to.Ptr[int32](2), + // RateLimitDurationInMinutes: to.Ptr[int32](0), + // RateLimitThreshold: to.Ptr[int32](0), + // RuleType: to.Ptr(armfrontdoor.RuleTypeMatchRule), + // }}, + // }, + // FrontendEndpointLinks: []*armfrontdoor.FrontendEndpointLink{ + // }, + // ManagedRules: &armfrontdoor.ManagedRuleSetList{ + // ManagedRuleSets: []*armfrontdoor.ManagedRuleSet{ + // { + // Exclusions: []*armfrontdoor.ManagedRuleExclusion{ + // { + // MatchVariable: to.Ptr(armfrontdoor.ManagedRuleExclusionMatchVariableRequestHeaderNames), + // Selector: to.Ptr("User-Agent"), + // SelectorMatchOperator: to.Ptr(armfrontdoor.ManagedRuleExclusionSelectorMatchOperatorEquals), + // }}, + // RuleGroupOverrides: []*armfrontdoor.ManagedRuleGroupOverride{ + // { + // Exclusions: []*armfrontdoor.ManagedRuleExclusion{ + // { + // MatchVariable: to.Ptr(armfrontdoor.ManagedRuleExclusionMatchVariableRequestCookieNames), + // Selector: to.Ptr("token"), + // SelectorMatchOperator: to.Ptr(armfrontdoor.ManagedRuleExclusionSelectorMatchOperatorStartsWith), + // }}, + // RuleGroupName: to.Ptr("SQLI"), + // Rules: []*armfrontdoor.ManagedRuleOverride{ + // { + // Action: to.Ptr(armfrontdoor.ActionTypeRedirect), + // EnabledState: to.Ptr(armfrontdoor.ManagedRuleEnabledStateEnabled), + // Exclusions: []*armfrontdoor.ManagedRuleExclusion{ + // { + // MatchVariable: to.Ptr(armfrontdoor.ManagedRuleExclusionMatchVariableQueryStringArgNames), + // Selector: to.Ptr("query"), + // SelectorMatchOperator: to.Ptr(armfrontdoor.ManagedRuleExclusionSelectorMatchOperatorEquals), + // }}, + // RuleID: to.Ptr("942100"), + // }, + // { + // EnabledState: to.Ptr(armfrontdoor.ManagedRuleEnabledStateDisabled), + // RuleID: to.Ptr("942110"), + // }}, + // }}, + // RuleSetAction: to.Ptr(armfrontdoor.ManagedRuleSetActionTypeBlock), + // RuleSetType: to.Ptr("DefaultRuleSet"), + // RuleSetVersion: to.Ptr("1.0"), + // }}, + // }, + // PolicySettings: &armfrontdoor.PolicySettings{ + // CustomBlockResponseBody: to.Ptr("PGh0bWw+CjxoZWFkZXI+PHRpdGxlPkhlbGxvPC90aXRsZT48L2hlYWRlcj4KPGJvZHk+CkhlbGxvIHdvcmxkCjwvYm9keT4KPC9odG1sPg=="), + // CustomBlockResponseStatusCode: to.Ptr[int32](499), + // EnabledState: to.Ptr(armfrontdoor.PolicyEnabledStateEnabled), + // Mode: to.Ptr(armfrontdoor.PolicyModePrevention), + // RedirectURL: to.Ptr("http://www.bing.com"), + // RequestBodyCheck: to.Ptr(armfrontdoor.PolicyRequestBodyCheckDisabled), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ResourceState: to.Ptr(armfrontdoor.PolicyResourceStateEnabled), + // SecurityPolicyLinks: []*armfrontdoor.SecurityPolicyLink{ + // }, + // }, + // SKU: &armfrontdoor.SKU{ + // Name: to.Ptr(armfrontdoor.SKUNameClassicAzureFrontDoor), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-11-01/examples/WafPolicyDelete.json +func ExamplePoliciesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewPoliciesClient().BeginDelete(ctx, "rg1", "Policy1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_polymorphic_helpers.go b/sdk/resourcemanager/frontdoor/armfrontdoor/polymorphic_helpers.go similarity index 96% rename from sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_polymorphic_helpers.go rename to sdk/resourcemanager/frontdoor/armfrontdoor/polymorphic_helpers.go index 9f0ca53b7682..4f79c84d3068 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_polymorphic_helpers.go +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/polymorphic_helpers.go @@ -5,6 +5,7 @@ // 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 armfrontdoor @@ -14,7 +15,7 @@ func unmarshalRouteConfigurationClassification(rawMsg json.RawMessage) (RouteCon if rawMsg == nil { return nil, nil } - var m map[string]interface{} + var m map[string]any if err := json.Unmarshal(rawMsg, &m); err != nil { return nil, err } diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_preconfiguredendpoints_client.go b/sdk/resourcemanager/frontdoor/armfrontdoor/preconfiguredendpoints_client.go similarity index 76% rename from sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_preconfiguredendpoints_client.go rename to sdk/resourcemanager/frontdoor/armfrontdoor/preconfiguredendpoints_client.go index a0515a114559..9cb04cb74dfd 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_preconfiguredendpoints_client.go +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/preconfiguredendpoints_client.go @@ -5,6 +5,7 @@ // 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 armfrontdoor @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,43 +24,34 @@ import ( // PreconfiguredEndpointsClient contains the methods for the PreconfiguredEndpoints group. // Don't use this type directly, use NewPreconfiguredEndpointsClient() instead. type PreconfiguredEndpointsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewPreconfiguredEndpointsClient creates a new instance of PreconfiguredEndpointsClient with the specified values. -// subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription -// ID forms part of the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription +// ID forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewPreconfiguredEndpointsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PreconfiguredEndpointsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".PreconfiguredEndpointsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &PreconfiguredEndpointsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Gets a list of Preconfigured Endpoints -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// profileName - The Profile identifier associated with the Tenant and Partner -// options - PreconfiguredEndpointsClientListOptions contains the optional parameters for the PreconfiguredEndpointsClient.List -// method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - profileName - The Profile identifier associated with the Tenant and Partner +// - options - PreconfiguredEndpointsClientListOptions contains the optional parameters for the PreconfiguredEndpointsClient.NewListPager +// method. func (client *PreconfiguredEndpointsClient) NewListPager(resourceGroupName string, profileName string, options *PreconfiguredEndpointsClientListOptions) *runtime.Pager[PreconfiguredEndpointsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[PreconfiguredEndpointsClientListResponse]{ More: func(page PreconfiguredEndpointsClientListResponse) bool { @@ -78,7 +68,7 @@ func (client *PreconfiguredEndpointsClient) NewListPager(resourceGroupName strin if err != nil { return PreconfiguredEndpointsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return PreconfiguredEndpointsClientListResponse{}, err } @@ -105,7 +95,7 @@ func (client *PreconfiguredEndpointsClient) listCreateRequest(ctx context.Contex return nil, errors.New("parameter profileName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{profileName}", url.PathEscape(profileName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/preconfiguredendpoints_client_example_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/preconfiguredendpoints_client_example_test.go new file mode 100644 index 000000000000..4c2931e9d9ef --- /dev/null +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/preconfiguredendpoints_client_example_test.go @@ -0,0 +1,55 @@ +//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 armfrontdoor_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/frontdoor/armfrontdoor" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentGetPreconfiguredEndpoints.json +func ExamplePreconfiguredEndpointsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewPreconfiguredEndpointsClient().NewListPager("MyResourceGroup", "MyProfile", 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.PreconfiguredEndpointList = armfrontdoor.PreconfiguredEndpointList{ + // Value: []*armfrontdoor.PreconfiguredEndpoint{ + // { + // Name: to.Ptr("Endpoint 1"), + // Properties: &armfrontdoor.PreconfiguredEndpointProperties{ + // Description: to.Ptr("this is the endpoint 1 preconfigured endpoint."), + // Backend: to.Ptr("WESTUS"), + // Endpoint: to.Ptr("endpoint1.net"), + // EndpointType: to.Ptr(armfrontdoor.EndpointTypeAFD), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_reports_client.go b/sdk/resourcemanager/frontdoor/armfrontdoor/reports_client.go similarity index 79% rename from sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_reports_client.go rename to sdk/resourcemanager/frontdoor/armfrontdoor/reports_client.go index 2e73d5df63dc..8a6864ddc3d4 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_reports_client.go +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/reports_client.go @@ -5,6 +5,7 @@ // 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 armfrontdoor @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -26,51 +25,43 @@ import ( // ReportsClient contains the methods for the Reports group. // Don't use this type directly, use NewReportsClient() instead. type ReportsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewReportsClient creates a new instance of ReportsClient with the specified values. -// subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription -// ID forms part of the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription +// ID forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewReportsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ReportsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ReportsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ReportsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // GetLatencyScorecards - Gets a Latency Scorecard for a given Experiment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// profileName - The Profile identifier associated with the Tenant and Partner -// experimentName - The Experiment identifier associated with the Experiment -// aggregationInterval - The aggregation interval of the Latency Scorecard -// options - ReportsClientGetLatencyScorecardsOptions contains the optional parameters for the ReportsClient.GetLatencyScorecards -// method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - profileName - The Profile identifier associated with the Tenant and Partner +// - experimentName - The Experiment identifier associated with the Experiment +// - aggregationInterval - The aggregation interval of the Latency Scorecard +// - options - ReportsClientGetLatencyScorecardsOptions contains the optional parameters for the ReportsClient.GetLatencyScorecards +// method. func (client *ReportsClient) GetLatencyScorecards(ctx context.Context, resourceGroupName string, profileName string, experimentName string, aggregationInterval LatencyScorecardAggregationInterval, options *ReportsClientGetLatencyScorecardsOptions) (ReportsClientGetLatencyScorecardsResponse, error) { req, err := client.getLatencyScorecardsCreateRequest(ctx, resourceGroupName, profileName, experimentName, aggregationInterval, options) if err != nil { return ReportsClientGetLatencyScorecardsResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ReportsClientGetLatencyScorecardsResponse{}, err } @@ -99,7 +90,7 @@ func (client *ReportsClient) getLatencyScorecardsCreateRequest(ctx context.Conte return nil, errors.New("parameter experimentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -128,21 +119,22 @@ func (client *ReportsClient) getLatencyScorecardsHandleResponse(resp *http.Respo // GetTimeseries - Gets a Timeseries for a given Experiment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2019-11-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// profileName - The Profile identifier associated with the Tenant and Partner -// experimentName - The Experiment identifier associated with the Experiment -// startDateTimeUTC - The start DateTime of the Timeseries in UTC -// endDateTimeUTC - The end DateTime of the Timeseries in UTC -// aggregationInterval - The aggregation interval of the Timeseries -// timeseriesType - The type of Timeseries -// options - ReportsClientGetTimeseriesOptions contains the optional parameters for the ReportsClient.GetTimeseries method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - profileName - The Profile identifier associated with the Tenant and Partner +// - experimentName - The Experiment identifier associated with the Experiment +// - startDateTimeUTC - The start DateTime of the Timeseries in UTC +// - endDateTimeUTC - The end DateTime of the Timeseries in UTC +// - aggregationInterval - The aggregation interval of the Timeseries +// - timeseriesType - The type of Timeseries +// - options - ReportsClientGetTimeseriesOptions contains the optional parameters for the ReportsClient.GetTimeseries method. func (client *ReportsClient) GetTimeseries(ctx context.Context, resourceGroupName string, profileName string, experimentName string, startDateTimeUTC time.Time, endDateTimeUTC time.Time, aggregationInterval TimeseriesAggregationInterval, timeseriesType TimeseriesType, options *ReportsClientGetTimeseriesOptions) (ReportsClientGetTimeseriesResponse, error) { req, err := client.getTimeseriesCreateRequest(ctx, resourceGroupName, profileName, experimentName, startDateTimeUTC, endDateTimeUTC, aggregationInterval, timeseriesType, options) if err != nil { return ReportsClientGetTimeseriesResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ReportsClientGetTimeseriesResponse{}, err } @@ -171,7 +163,7 @@ func (client *ReportsClient) getTimeseriesCreateRequest(ctx context.Context, res return nil, errors.New("parameter experimentName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{experimentName}", url.PathEscape(experimentName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/reports_client_example_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/reports_client_example_test.go new file mode 100644 index 000000000000..b9f1d48a3def --- /dev/null +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/reports_client_example_test.go @@ -0,0 +1,92 @@ +//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 armfrontdoor_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/frontdoor/armfrontdoor" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentGetLatencyScorecard.json +func ExampleReportsClient_GetLatencyScorecards() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewReportsClient().GetLatencyScorecards(ctx, "MyResourceGroup", "MyProfile", "MyExperiment", armfrontdoor.LatencyScorecardAggregationIntervalDaily, &armfrontdoor.ReportsClientGetLatencyScorecardsOptions{EndDateTimeUTC: nil, + Country: 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.LatencyScorecard = armfrontdoor.LatencyScorecard{ + // Name: to.Ptr("DailyLatencyScorecard"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/MyResourceGroup/providers/Microsoft.Network/NetworkExperimentProfiles/MyProfile/Experiments/MyExperiment/LatencyScorecard"), + // Properties: &armfrontdoor.LatencyScorecardProperties{ + // Description: to.Ptr("This scorecard is the latency scorecard, aggregated over a day"), + // Country: to.Ptr("USA"), + // EndDateTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-21T17:32:28Z"); return t}()), + // EndpointA: to.Ptr("https://endpointA.com"), + // EndpointB: to.Ptr("https://endpoingB.com"), + // StartDateTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-21T17:32:28Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentGetTimeseries.json +func ExampleReportsClient_GetTimeseries() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewReportsClient().GetTimeseries(ctx, "MyResourceGroup", "MyProfile", "MyExperiment", func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-21T17:32:28Z"); return t }(), func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-21T17:32:28Z"); return t }(), armfrontdoor.TimeseriesAggregationIntervalHourly, armfrontdoor.TimeseriesTypeMeasurementCounts, &armfrontdoor.ReportsClientGetTimeseriesOptions{Endpoint: nil, + Country: 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.Timeseries = armfrontdoor.Timeseries{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/MyResourceGroup/providers/Microsoft.Network/NetworkExperimentProfiles/MyProfile/Experiments/MyExperiment/Timeseries"), + // Properties: &armfrontdoor.TimeseriesProperties{ + // AggregationInterval: to.Ptr(armfrontdoor.AggregationIntervalHourly), + // Country: to.Ptr("United States"), + // EndDateTimeUTC: to.Ptr("2019-08-02"), + // Endpoint: to.Ptr("https://endpointA.com"), + // StartDateTimeUTC: to.Ptr("2019-07-29"), + // TimeseriesData: []*armfrontdoor.TimeseriesDataPoint{ + // { + // DateTimeUTC: to.Ptr("2019-07-22T17:32:28Z"), + // Value: to.Ptr[float32](79), + // }}, + // TimeseriesType: to.Ptr(armfrontdoor.TimeseriesTypeMeasurementCounts), + // }, + // } +} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_response_types.go b/sdk/resourcemanager/frontdoor/armfrontdoor/response_types.go similarity index 82% rename from sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_response_types.go rename to sdk/resourcemanager/frontdoor/armfrontdoor/response_types.go index f30fac794500..fb5d33301551 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_response_types.go +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/response_types.go @@ -5,20 +5,21 @@ // 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 armfrontdoor -// EndpointsClientPurgeContentResponse contains the response from method EndpointsClient.PurgeContent. +// EndpointsClientPurgeContentResponse contains the response from method EndpointsClient.BeginPurgeContent. type EndpointsClientPurgeContentResponse struct { // placeholder for future response values } -// ExperimentsClientCreateOrUpdateResponse contains the response from method ExperimentsClient.CreateOrUpdate. +// ExperimentsClientCreateOrUpdateResponse contains the response from method ExperimentsClient.BeginCreateOrUpdate. type ExperimentsClientCreateOrUpdateResponse struct { Experiment } -// ExperimentsClientDeleteResponse contains the response from method ExperimentsClient.Delete. +// ExperimentsClientDeleteResponse contains the response from method ExperimentsClient.BeginDelete. type ExperimentsClientDeleteResponse struct { // placeholder for future response values } @@ -28,22 +29,22 @@ type ExperimentsClientGetResponse struct { Experiment } -// ExperimentsClientListByProfileResponse contains the response from method ExperimentsClient.ListByProfile. +// ExperimentsClientListByProfileResponse contains the response from method ExperimentsClient.NewListByProfilePager. type ExperimentsClientListByProfileResponse struct { ExperimentList } -// ExperimentsClientUpdateResponse contains the response from method ExperimentsClient.Update. +// ExperimentsClientUpdateResponse contains the response from method ExperimentsClient.BeginUpdate. type ExperimentsClientUpdateResponse struct { Experiment } -// FrontDoorsClientCreateOrUpdateResponse contains the response from method FrontDoorsClient.CreateOrUpdate. +// FrontDoorsClientCreateOrUpdateResponse contains the response from method FrontDoorsClient.BeginCreateOrUpdate. type FrontDoorsClientCreateOrUpdateResponse struct { FrontDoor } -// FrontDoorsClientDeleteResponse contains the response from method FrontDoorsClient.Delete. +// FrontDoorsClientDeleteResponse contains the response from method FrontDoorsClient.BeginDelete. type FrontDoorsClientDeleteResponse struct { // placeholder for future response values } @@ -53,12 +54,12 @@ type FrontDoorsClientGetResponse struct { FrontDoor } -// FrontDoorsClientListByResourceGroupResponse contains the response from method FrontDoorsClient.ListByResourceGroup. +// FrontDoorsClientListByResourceGroupResponse contains the response from method FrontDoorsClient.NewListByResourceGroupPager. type FrontDoorsClientListByResourceGroupResponse struct { ListResult } -// FrontDoorsClientListResponse contains the response from method FrontDoorsClient.List. +// FrontDoorsClientListResponse contains the response from method FrontDoorsClient.NewListPager. type FrontDoorsClientListResponse struct { ListResult } @@ -68,12 +69,12 @@ type FrontDoorsClientValidateCustomDomainResponse struct { ValidateCustomDomainOutput } -// FrontendEndpointsClientDisableHTTPSResponse contains the response from method FrontendEndpointsClient.DisableHTTPS. +// FrontendEndpointsClientDisableHTTPSResponse contains the response from method FrontendEndpointsClient.BeginDisableHTTPS. type FrontendEndpointsClientDisableHTTPSResponse struct { // placeholder for future response values } -// FrontendEndpointsClientEnableHTTPSResponse contains the response from method FrontendEndpointsClient.EnableHTTPS. +// FrontendEndpointsClientEnableHTTPSResponse contains the response from method FrontendEndpointsClient.BeginEnableHTTPS. type FrontendEndpointsClientEnableHTTPSResponse struct { // placeholder for future response values } @@ -83,12 +84,12 @@ type FrontendEndpointsClientGetResponse struct { FrontendEndpoint } -// FrontendEndpointsClientListByFrontDoorResponse contains the response from method FrontendEndpointsClient.ListByFrontDoor. +// FrontendEndpointsClientListByFrontDoorResponse contains the response from method FrontendEndpointsClient.NewListByFrontDoorPager. type FrontendEndpointsClientListByFrontDoorResponse struct { FrontendEndpointsListResult } -// ManagedRuleSetsClientListResponse contains the response from method ManagedRuleSetsClient.List. +// ManagedRuleSetsClientListResponse contains the response from method ManagedRuleSetsClient.NewListPager. type ManagedRuleSetsClientListResponse struct { ManagedRuleSetDefinitionList } @@ -103,12 +104,12 @@ type NameAvailabilityWithSubscriptionClientCheckResponse struct { CheckNameAvailabilityOutput } -// NetworkExperimentProfilesClientCreateOrUpdateResponse contains the response from method NetworkExperimentProfilesClient.CreateOrUpdate. +// NetworkExperimentProfilesClientCreateOrUpdateResponse contains the response from method NetworkExperimentProfilesClient.BeginCreateOrUpdate. type NetworkExperimentProfilesClientCreateOrUpdateResponse struct { Profile } -// NetworkExperimentProfilesClientDeleteResponse contains the response from method NetworkExperimentProfilesClient.Delete. +// NetworkExperimentProfilesClientDeleteResponse contains the response from method NetworkExperimentProfilesClient.BeginDelete. type NetworkExperimentProfilesClientDeleteResponse struct { // placeholder for future response values } @@ -118,27 +119,27 @@ type NetworkExperimentProfilesClientGetResponse struct { Profile } -// NetworkExperimentProfilesClientListByResourceGroupResponse contains the response from method NetworkExperimentProfilesClient.ListByResourceGroup. +// NetworkExperimentProfilesClientListByResourceGroupResponse contains the response from method NetworkExperimentProfilesClient.NewListByResourceGroupPager. type NetworkExperimentProfilesClientListByResourceGroupResponse struct { ProfileList } -// NetworkExperimentProfilesClientListResponse contains the response from method NetworkExperimentProfilesClient.List. +// NetworkExperimentProfilesClientListResponse contains the response from method NetworkExperimentProfilesClient.NewListPager. type NetworkExperimentProfilesClientListResponse struct { ProfileList } -// NetworkExperimentProfilesClientUpdateResponse contains the response from method NetworkExperimentProfilesClient.Update. +// NetworkExperimentProfilesClientUpdateResponse contains the response from method NetworkExperimentProfilesClient.BeginUpdate. type NetworkExperimentProfilesClientUpdateResponse struct { Profile } -// PoliciesClientCreateOrUpdateResponse contains the response from method PoliciesClient.CreateOrUpdate. +// PoliciesClientCreateOrUpdateResponse contains the response from method PoliciesClient.BeginCreateOrUpdate. type PoliciesClientCreateOrUpdateResponse struct { WebApplicationFirewallPolicy } -// PoliciesClientDeleteResponse contains the response from method PoliciesClient.Delete. +// PoliciesClientDeleteResponse contains the response from method PoliciesClient.BeginDelete. type PoliciesClientDeleteResponse struct { // placeholder for future response values } @@ -148,12 +149,12 @@ type PoliciesClientGetResponse struct { WebApplicationFirewallPolicy } -// PoliciesClientListResponse contains the response from method PoliciesClient.List. +// PoliciesClientListResponse contains the response from method PoliciesClient.NewListPager. type PoliciesClientListResponse struct { WebApplicationFirewallPolicyList } -// PreconfiguredEndpointsClientListResponse contains the response from method PreconfiguredEndpointsClient.List. +// PreconfiguredEndpointsClientListResponse contains the response from method PreconfiguredEndpointsClient.NewListPager. type PreconfiguredEndpointsClientListResponse struct { PreconfiguredEndpointList } @@ -168,12 +169,12 @@ type ReportsClientGetTimeseriesResponse struct { Timeseries } -// RulesEnginesClientCreateOrUpdateResponse contains the response from method RulesEnginesClient.CreateOrUpdate. +// RulesEnginesClientCreateOrUpdateResponse contains the response from method RulesEnginesClient.BeginCreateOrUpdate. type RulesEnginesClientCreateOrUpdateResponse struct { RulesEngine } -// RulesEnginesClientDeleteResponse contains the response from method RulesEnginesClient.Delete. +// RulesEnginesClientDeleteResponse contains the response from method RulesEnginesClient.BeginDelete. type RulesEnginesClientDeleteResponse struct { // placeholder for future response values } @@ -183,7 +184,7 @@ type RulesEnginesClientGetResponse struct { RulesEngine } -// RulesEnginesClientListByFrontDoorResponse contains the response from method RulesEnginesClient.ListByFrontDoor. +// RulesEnginesClientListByFrontDoorResponse contains the response from method RulesEnginesClient.NewListByFrontDoorPager. type RulesEnginesClientListByFrontDoorResponse struct { RulesEngineListResult } diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_rulesengines_client.go b/sdk/resourcemanager/frontdoor/armfrontdoor/rulesengines_client.go similarity index 81% rename from sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_rulesengines_client.go rename to sdk/resourcemanager/frontdoor/armfrontdoor/rulesengines_client.go index 98b366377355..f5091953b5ec 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_rulesengines_client.go +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/rulesengines_client.go @@ -5,6 +5,7 @@ // 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 armfrontdoor @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,68 +24,61 @@ import ( // RulesEnginesClient contains the methods for the RulesEngines group. // Don't use this type directly, use NewRulesEnginesClient() instead. type RulesEnginesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewRulesEnginesClient creates a new instance of RulesEnginesClient with the specified values. -// subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription -// ID forms part of the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription +// ID forms part of the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewRulesEnginesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RulesEnginesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".RulesEnginesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &RulesEnginesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreateOrUpdate - Creates a new Rules Engine Configuration with the specified name within the specified Front Door. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// frontDoorName - Name of the Front Door which is globally unique. -// rulesEngineName - Name of the Rules Engine which is unique within the Front Door. -// rulesEngineParameters - Rules Engine Configuration properties needed to create a new Rules Engine Configuration. -// options - RulesEnginesClientBeginCreateOrUpdateOptions contains the optional parameters for the RulesEnginesClient.BeginCreateOrUpdate -// method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - frontDoorName - Name of the Front Door which is globally unique. +// - rulesEngineName - Name of the Rules Engine which is unique within the Front Door. +// - rulesEngineParameters - Rules Engine Configuration properties needed to create a new Rules Engine Configuration. +// - options - RulesEnginesClientBeginCreateOrUpdateOptions contains the optional parameters for the RulesEnginesClient.BeginCreateOrUpdate +// method. func (client *RulesEnginesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, frontDoorName string, rulesEngineName string, rulesEngineParameters RulesEngine, options *RulesEnginesClientBeginCreateOrUpdateOptions) (*runtime.Poller[RulesEnginesClientCreateOrUpdateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.createOrUpdate(ctx, resourceGroupName, frontDoorName, rulesEngineName, rulesEngineParameters, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[RulesEnginesClientCreateOrUpdateResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RulesEnginesClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[RulesEnginesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[RulesEnginesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // CreateOrUpdate - Creates a new Rules Engine Configuration with the specified name within the specified Front Door. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 func (client *RulesEnginesClient) createOrUpdate(ctx context.Context, resourceGroupName string, frontDoorName string, rulesEngineName string, rulesEngineParameters RulesEngine, options *RulesEnginesClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, frontDoorName, rulesEngineName, rulesEngineParameters, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -115,7 +107,7 @@ func (client *RulesEnginesClient) createOrUpdateCreateRequest(ctx context.Contex return nil, errors.New("parameter rulesEngineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{rulesEngineName}", url.PathEscape(rulesEngineName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -128,35 +120,37 @@ func (client *RulesEnginesClient) createOrUpdateCreateRequest(ctx context.Contex // BeginDelete - Deletes an existing Rules Engine Configuration with the specified parameters. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// frontDoorName - Name of the Front Door which is globally unique. -// rulesEngineName - Name of the Rules Engine which is unique within the Front Door. -// options - RulesEnginesClientBeginDeleteOptions contains the optional parameters for the RulesEnginesClient.BeginDelete -// method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - frontDoorName - Name of the Front Door which is globally unique. +// - rulesEngineName - Name of the Rules Engine which is unique within the Front Door. +// - options - RulesEnginesClientBeginDeleteOptions contains the optional parameters for the RulesEnginesClient.BeginDelete +// method. func (client *RulesEnginesClient) BeginDelete(ctx context.Context, resourceGroupName string, frontDoorName string, rulesEngineName string, options *RulesEnginesClientBeginDeleteOptions) (*runtime.Poller[RulesEnginesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, frontDoorName, rulesEngineName, options) if err != nil { return nil, err } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[RulesEnginesClientDeleteResponse]{ + return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[RulesEnginesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) } else { - return runtime.NewPollerFromResumeToken[RulesEnginesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[RulesEnginesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes an existing Rules Engine Configuration with the specified parameters. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 func (client *RulesEnginesClient) deleteOperation(ctx context.Context, resourceGroupName string, frontDoorName string, rulesEngineName string, options *RulesEnginesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, frontDoorName, rulesEngineName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -185,7 +179,7 @@ func (client *RulesEnginesClient) deleteCreateRequest(ctx context.Context, resou return nil, errors.New("parameter rulesEngineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{rulesEngineName}", url.PathEscape(rulesEngineName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -198,17 +192,18 @@ func (client *RulesEnginesClient) deleteCreateRequest(ctx context.Context, resou // Get - Gets a Rules Engine Configuration with the specified name within the specified Front Door. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// frontDoorName - Name of the Front Door which is globally unique. -// rulesEngineName - Name of the Rules Engine which is unique within the Front Door. -// options - RulesEnginesClientGetOptions contains the optional parameters for the RulesEnginesClient.Get method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - frontDoorName - Name of the Front Door which is globally unique. +// - rulesEngineName - Name of the Rules Engine which is unique within the Front Door. +// - options - RulesEnginesClientGetOptions contains the optional parameters for the RulesEnginesClient.Get method. func (client *RulesEnginesClient) Get(ctx context.Context, resourceGroupName string, frontDoorName string, rulesEngineName string, options *RulesEnginesClientGetOptions) (RulesEnginesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, frontDoorName, rulesEngineName, options) if err != nil { return RulesEnginesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RulesEnginesClientGetResponse{}, err } @@ -237,7 +232,7 @@ func (client *RulesEnginesClient) getCreateRequest(ctx context.Context, resource return nil, errors.New("parameter rulesEngineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{rulesEngineName}", url.PathEscape(rulesEngineName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -258,12 +253,12 @@ func (client *RulesEnginesClient) getHandleResponse(resp *http.Response) (RulesE } // NewListByFrontDoorPager - Lists all of the Rules Engine Configurations within a Front Door. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-05-01 -// resourceGroupName - Name of the Resource group within the Azure subscription. -// frontDoorName - Name of the Front Door which is globally unique. -// options - RulesEnginesClientListByFrontDoorOptions contains the optional parameters for the RulesEnginesClient.ListByFrontDoor -// method. +// - resourceGroupName - Name of the Resource group within the Azure subscription. +// - frontDoorName - Name of the Front Door which is globally unique. +// - options - RulesEnginesClientListByFrontDoorOptions contains the optional parameters for the RulesEnginesClient.NewListByFrontDoorPager +// method. func (client *RulesEnginesClient) NewListByFrontDoorPager(resourceGroupName string, frontDoorName string, options *RulesEnginesClientListByFrontDoorOptions) *runtime.Pager[RulesEnginesClientListByFrontDoorResponse] { return runtime.NewPager(runtime.PagingHandler[RulesEnginesClientListByFrontDoorResponse]{ More: func(page RulesEnginesClientListByFrontDoorResponse) bool { @@ -280,7 +275,7 @@ func (client *RulesEnginesClient) NewListByFrontDoorPager(resourceGroupName stri if err != nil { return RulesEnginesClientListByFrontDoorResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return RulesEnginesClientListByFrontDoorResponse{}, err } @@ -307,7 +302,7 @@ func (client *RulesEnginesClient) listByFrontDoorCreateRequest(ctx context.Conte return nil, errors.New("parameter frontDoorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{frontDoorName}", url.PathEscape(frontDoorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/rulesengines_client_example_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/rulesengines_client_example_test.go new file mode 100644 index 000000000000..76500707be7e --- /dev/null +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/rulesengines_client_example_test.go @@ -0,0 +1,403 @@ +//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 armfrontdoor_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/frontdoor/armfrontdoor" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorRulesEngineList.json +func ExampleRulesEnginesClient_NewListByFrontDoorPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewRulesEnginesClient().NewListByFrontDoorPager("rg1", "frontDoor1", 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.RulesEngineListResult = armfrontdoor.RulesEngineListResult{ + // Value: []*armfrontdoor.RulesEngine{ + // { + // Name: to.Ptr("rulesEngine1"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/rulesEngines/rulesEngine1"), + // Properties: &armfrontdoor.RulesEngineProperties{ + // Rules: []*armfrontdoor.RulesEngineRule{ + // { + // Name: to.Ptr("Rule1"), + // Action: &armfrontdoor.RulesEngineAction{ + // RouteConfigurationOverride: &armfrontdoor.RedirectConfiguration{ + // ODataType: to.Ptr("#Microsoft.Azure.FrontDoor.Models.FrontdoorRedirectConfiguration"), + // CustomFragment: to.Ptr("fragment"), + // CustomHost: to.Ptr("www.bing.com"), + // CustomPath: to.Ptr("/api"), + // CustomQueryString: to.Ptr("a=b"), + // RedirectProtocol: to.Ptr(armfrontdoor.FrontDoorRedirectProtocolHTTPSOnly), + // RedirectType: to.Ptr(armfrontdoor.FrontDoorRedirectTypeMoved), + // }, + // }, + // MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ + // { + // RulesEngineMatchValue: []*string{ + // to.Ptr("CH")}, + // RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariableRemoteAddr), + // RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorGeoMatch), + // }}, + // MatchProcessingBehavior: to.Ptr(armfrontdoor.MatchProcessingBehaviorStop), + // Priority: to.Ptr[int32](1), + // }, + // { + // Name: to.Ptr("Rule2"), + // Action: &armfrontdoor.RulesEngineAction{ + // ResponseHeaderActions: []*armfrontdoor.HeaderAction{ + // { + // HeaderActionType: to.Ptr(armfrontdoor.HeaderActionTypeOverwrite), + // HeaderName: to.Ptr("Cache-Control"), + // Value: to.Ptr("public, max-age=31536000"), + // }}, + // }, + // MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ + // { + // RulesEngineMatchValue: []*string{ + // to.Ptr("jpg")}, + // RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariableRequestFilenameExtension), + // RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorEqual), + // Transforms: []*armfrontdoor.Transform{ + // to.Ptr(armfrontdoor.TransformLowercase)}, + // }}, + // Priority: to.Ptr[int32](2), + // }, + // { + // Name: to.Ptr("Rule3"), + // Action: &armfrontdoor.RulesEngineAction{ + // RouteConfigurationOverride: &armfrontdoor.ForwardingConfiguration{ + // ODataType: to.Ptr("#Microsoft.Azure.FrontDoor.Models.FrontdoorForwardingConfiguration"), + // BackendPool: &armfrontdoor.SubResource{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1"), + // }, + // CacheConfiguration: &armfrontdoor.CacheConfiguration{ + // CacheDuration: to.Ptr("P1DT12H20M30S"), + // DynamicCompression: to.Ptr(armfrontdoor.DynamicCompressionEnabledDisabled), + // QueryParameterStripDirective: to.Ptr(armfrontdoor.FrontDoorQueryStripOnly), + // QueryParameters: to.Ptr("a=b,p=q"), + // }, + // ForwardingProtocol: to.Ptr(armfrontdoor.FrontDoorForwardingProtocolHTTPSOnly), + // }, + // }, + // MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ + // { + // NegateCondition: to.Ptr(false), + // RulesEngineMatchValue: []*string{ + // to.Ptr("allowoverride")}, + // RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariableRequestHeader), + // RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorEqual), + // Selector: to.Ptr("Rules-Engine-Route-Forward"), + // Transforms: []*armfrontdoor.Transform{ + // to.Ptr(armfrontdoor.TransformLowercase)}, + // }}, + // Priority: to.Ptr[int32](3), + // }}, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorRulesEngineGet.json +func ExampleRulesEnginesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewRulesEnginesClient().Get(ctx, "rg1", "frontDoor1", "rulesEngine1", 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.RulesEngine = armfrontdoor.RulesEngine{ + // Name: to.Ptr("rulesEngine1"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/rulesEngines/rulesEngine1"), + // Properties: &armfrontdoor.RulesEngineProperties{ + // Rules: []*armfrontdoor.RulesEngineRule{ + // { + // Name: to.Ptr("Rule1"), + // Action: &armfrontdoor.RulesEngineAction{ + // RouteConfigurationOverride: &armfrontdoor.RedirectConfiguration{ + // ODataType: to.Ptr("#Microsoft.Azure.FrontDoor.Models.FrontdoorRedirectConfiguration"), + // CustomFragment: to.Ptr("fragment"), + // CustomHost: to.Ptr("www.bing.com"), + // CustomPath: to.Ptr("/api"), + // CustomQueryString: to.Ptr("a=b"), + // RedirectProtocol: to.Ptr(armfrontdoor.FrontDoorRedirectProtocolHTTPSOnly), + // RedirectType: to.Ptr(armfrontdoor.FrontDoorRedirectTypeMoved), + // }, + // }, + // MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ + // { + // RulesEngineMatchValue: []*string{ + // to.Ptr("CH")}, + // RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariableRemoteAddr), + // RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorGeoMatch), + // }}, + // MatchProcessingBehavior: to.Ptr(armfrontdoor.MatchProcessingBehaviorStop), + // Priority: to.Ptr[int32](1), + // }, + // { + // Name: to.Ptr("Rule2"), + // Action: &armfrontdoor.RulesEngineAction{ + // ResponseHeaderActions: []*armfrontdoor.HeaderAction{ + // { + // HeaderActionType: to.Ptr(armfrontdoor.HeaderActionTypeOverwrite), + // HeaderName: to.Ptr("Cache-Control"), + // Value: to.Ptr("public, max-age=31536000"), + // }}, + // }, + // MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ + // { + // RulesEngineMatchValue: []*string{ + // to.Ptr("jpg")}, + // RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariableRequestFilenameExtension), + // RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorEqual), + // Transforms: []*armfrontdoor.Transform{ + // to.Ptr(armfrontdoor.TransformLowercase)}, + // }}, + // Priority: to.Ptr[int32](2), + // }, + // { + // Name: to.Ptr("Rule3"), + // Action: &armfrontdoor.RulesEngineAction{ + // RouteConfigurationOverride: &armfrontdoor.ForwardingConfiguration{ + // ODataType: to.Ptr("#Microsoft.Azure.FrontDoor.Models.FrontdoorForwardingConfiguration"), + // BackendPool: &armfrontdoor.SubResource{ + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1"), + // }, + // CacheConfiguration: &armfrontdoor.CacheConfiguration{ + // CacheDuration: to.Ptr("P1DT12H20M30S"), + // DynamicCompression: to.Ptr(armfrontdoor.DynamicCompressionEnabledDisabled), + // QueryParameterStripDirective: to.Ptr(armfrontdoor.FrontDoorQueryStripOnly), + // QueryParameters: to.Ptr("a=b,p=q"), + // }, + // ForwardingProtocol: to.Ptr(armfrontdoor.FrontDoorForwardingProtocolHTTPSOnly), + // }, + // }, + // MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ + // { + // NegateCondition: to.Ptr(false), + // RulesEngineMatchValue: []*string{ + // to.Ptr("allowoverride")}, + // RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariableRequestHeader), + // RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorEqual), + // Selector: to.Ptr("Rules-Engine-Route-Forward"), + // Transforms: []*armfrontdoor.Transform{ + // to.Ptr(armfrontdoor.TransformLowercase)}, + // }}, + // Priority: to.Ptr[int32](3), + // }}, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorRulesEngineCreate.json +func ExampleRulesEnginesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewRulesEnginesClient().BeginCreateOrUpdate(ctx, "rg1", "frontDoor1", "rulesEngine1", armfrontdoor.RulesEngine{ + Properties: &armfrontdoor.RulesEngineProperties{ + Rules: []*armfrontdoor.RulesEngineRule{ + { + Name: to.Ptr("Rule1"), + Action: &armfrontdoor.RulesEngineAction{ + RouteConfigurationOverride: &armfrontdoor.RedirectConfiguration{ + ODataType: to.Ptr("#Microsoft.Azure.FrontDoor.Models.FrontdoorRedirectConfiguration"), + CustomFragment: to.Ptr("fragment"), + CustomHost: to.Ptr("www.bing.com"), + CustomPath: to.Ptr("/api"), + CustomQueryString: to.Ptr("a=b"), + RedirectProtocol: to.Ptr(armfrontdoor.FrontDoorRedirectProtocolHTTPSOnly), + RedirectType: to.Ptr(armfrontdoor.FrontDoorRedirectTypeMoved), + }, + }, + MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ + { + RulesEngineMatchValue: []*string{ + to.Ptr("CH")}, + RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariableRemoteAddr), + RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorGeoMatch), + }}, + MatchProcessingBehavior: to.Ptr(armfrontdoor.MatchProcessingBehaviorStop), + Priority: to.Ptr[int32](1), + }, + { + Name: to.Ptr("Rule2"), + Action: &armfrontdoor.RulesEngineAction{ + ResponseHeaderActions: []*armfrontdoor.HeaderAction{ + { + HeaderActionType: to.Ptr(armfrontdoor.HeaderActionTypeOverwrite), + HeaderName: to.Ptr("Cache-Control"), + Value: to.Ptr("public, max-age=31536000"), + }}, + }, + MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ + { + RulesEngineMatchValue: []*string{ + to.Ptr("jpg")}, + RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariableRequestFilenameExtension), + RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorEqual), + Transforms: []*armfrontdoor.Transform{ + to.Ptr(armfrontdoor.TransformLowercase)}, + }}, + Priority: to.Ptr[int32](2), + }, + { + Name: to.Ptr("Rule3"), + Action: &armfrontdoor.RulesEngineAction{ + RouteConfigurationOverride: &armfrontdoor.ForwardingConfiguration{ + ODataType: to.Ptr("#Microsoft.Azure.FrontDoor.Models.FrontdoorForwardingConfiguration"), + BackendPool: &armfrontdoor.SubResource{ + ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1"), + }, + CacheConfiguration: &armfrontdoor.CacheConfiguration{ + CacheDuration: to.Ptr("P1DT12H20M30S"), + DynamicCompression: to.Ptr(armfrontdoor.DynamicCompressionEnabledDisabled), + QueryParameterStripDirective: to.Ptr(armfrontdoor.FrontDoorQueryStripOnly), + QueryParameters: to.Ptr("a=b,p=q"), + }, + ForwardingProtocol: to.Ptr(armfrontdoor.FrontDoorForwardingProtocolHTTPSOnly), + }, + }, + MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ + { + NegateCondition: to.Ptr(false), + RulesEngineMatchValue: []*string{ + to.Ptr("allowoverride")}, + RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariableRequestHeader), + RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorEqual), + Selector: to.Ptr("Rules-Engine-Route-Forward"), + Transforms: []*armfrontdoor.Transform{ + to.Ptr(armfrontdoor.TransformLowercase)}, + }}, + Priority: to.Ptr[int32](3), + }}, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RulesEngine = armfrontdoor.RulesEngine{ + // Name: to.Ptr("rulesEngine1"), + // ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/rulesEngines/rulesEngine1"), + // Properties: &armfrontdoor.RulesEngineProperties{ + // Rules: []*armfrontdoor.RulesEngineRule{ + // { + // Name: to.Ptr("Rule1"), + // Action: &armfrontdoor.RulesEngineAction{ + // RouteConfigurationOverride: &armfrontdoor.RedirectConfiguration{ + // ODataType: to.Ptr("#Microsoft.Azure.FrontDoor.Models.FrontdoorRedirectConfiguration"), + // CustomFragment: to.Ptr("fragment"), + // CustomHost: to.Ptr("www.bing.com"), + // CustomPath: to.Ptr("/api"), + // CustomQueryString: to.Ptr("a=b"), + // RedirectProtocol: to.Ptr(armfrontdoor.FrontDoorRedirectProtocolHTTPSOnly), + // RedirectType: to.Ptr(armfrontdoor.FrontDoorRedirectTypeMoved), + // }, + // }, + // MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ + // { + // RulesEngineMatchValue: []*string{ + // to.Ptr("CH")}, + // RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariableRemoteAddr), + // RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorGeoMatch), + // }}, + // MatchProcessingBehavior: to.Ptr(armfrontdoor.MatchProcessingBehaviorStop), + // Priority: to.Ptr[int32](1), + // }, + // { + // Name: to.Ptr("Rule2"), + // Action: &armfrontdoor.RulesEngineAction{ + // ResponseHeaderActions: []*armfrontdoor.HeaderAction{ + // { + // HeaderActionType: to.Ptr(armfrontdoor.HeaderActionTypeOverwrite), + // HeaderName: to.Ptr("Cache-Control"), + // Value: to.Ptr("public, max-age=31536000"), + // }}, + // }, + // MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ + // { + // RulesEngineMatchValue: []*string{ + // to.Ptr("jpg")}, + // RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariableRequestFilenameExtension), + // RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorEqual), + // Transforms: []*armfrontdoor.Transform{ + // to.Ptr(armfrontdoor.TransformLowercase)}, + // }}, + // Priority: to.Ptr[int32](2), + // }}, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorRulesEngineDelete.json +func ExampleRulesEnginesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armfrontdoor.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewRulesEnginesClient().BeginDelete(ctx, "rg1", "frontDoor1", "rulesEngine1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_time_rfc3339.go b/sdk/resourcemanager/frontdoor/armfrontdoor/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/frontdoor/armfrontdoor/time_rfc3339.go index 81fe39d11bd4..7b872581d65b 100644 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/frontdoor/armfrontdoor/time_rfc3339.go @@ -5,6 +5,7 @@ // 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 armfrontdoor @@ -61,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_experiments_client_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_experiments_client_test.go deleted file mode 100644 index da336f85fcff..000000000000 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_experiments_client_test.go +++ /dev/null @@ -1,166 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armfrontdoor_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/frontdoor/armfrontdoor" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentListExperiments.json -func ExampleExperimentsClient_NewListByProfilePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewExperimentsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByProfilePager("MyResourceGroup", - "MyProfile", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentGetExperiment.json -func ExampleExperimentsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewExperimentsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "MyResourceGroup", - "MyProfile", - "MyExperiment", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentCreateExperiment.json -func ExampleExperimentsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewExperimentsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "MyResourceGroup", - "MyProfile", - "MyExperiment", - armfrontdoor.Experiment{ - Properties: &armfrontdoor.ExperimentProperties{ - Description: to.Ptr("this is my first experiment!"), - EnabledState: to.Ptr(armfrontdoor.StateEnabled), - EndpointA: &armfrontdoor.Endpoint{ - Name: to.Ptr("endpoint A"), - Endpoint: to.Ptr("endpointA.net"), - }, - EndpointB: &armfrontdoor.Endpoint{ - Name: to.Ptr("endpoint B"), - Endpoint: to.Ptr("endpointB.net"), - }, - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentUpdateExperiment.json -func ExampleExperimentsClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewExperimentsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, - "MyResourceGroup", - "MyProfile", - "MyExperiment", - armfrontdoor.ExperimentUpdateModel{ - Properties: &armfrontdoor.ExperimentUpdateProperties{ - Description: to.Ptr("string"), - EnabledState: to.Ptr(armfrontdoor.StateEnabled), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentDeleteExperiment.json -func ExampleExperimentsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewExperimentsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "MyResourceGroup", - "MyProfile", - "MyExperiment", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_frontdoornameavailability_client_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_frontdoornameavailability_client_test.go deleted file mode 100644 index 407a1354ebc0..000000000000 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_frontdoornameavailability_client_test.go +++ /dev/null @@ -1,42 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armfrontdoor_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/frontdoor/armfrontdoor" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/CheckFrontdoorNameAvailability.json -func ExampleNameAvailabilityClient_Check() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewNameAvailabilityClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Check(ctx, - armfrontdoor.CheckNameAvailabilityInput{ - Name: to.Ptr("sampleName"), - Type: to.Ptr(armfrontdoor.ResourceTypeMicrosoftNetworkFrontDoors), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_frontdoornameavailabilitywithsubscription_client_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_frontdoornameavailabilitywithsubscription_client_test.go deleted file mode 100644 index 7f644a9cd05f..000000000000 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_frontdoornameavailabilitywithsubscription_client_test.go +++ /dev/null @@ -1,42 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armfrontdoor_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/frontdoor/armfrontdoor" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/CheckFrontdoorNameAvailabilityWithSubscription.json -func ExampleNameAvailabilityWithSubscriptionClient_Check() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewNameAvailabilityWithSubscriptionClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Check(ctx, - armfrontdoor.CheckNameAvailabilityInput{ - Name: to.Ptr("sampleName"), - Type: to.Ptr(armfrontdoor.ResourceTypeMicrosoftNetworkFrontDoorsFrontendEndpoints), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_frontdoors_client_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_frontdoors_client_test.go deleted file mode 100644 index c2e581a74f9c..000000000000 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_frontdoors_client_test.go +++ /dev/null @@ -1,284 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armfrontdoor_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/frontdoor/armfrontdoor" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorListAll.json -func ExampleFrontDoorsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewFrontDoorsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorList.json -func ExampleFrontDoorsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewFrontDoorsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("rg1", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorGet.json -func ExampleFrontDoorsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewFrontDoorsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "rg1", - "frontDoor1", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorCreate.json -func ExampleFrontDoorsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewFrontDoorsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "rg1", - "frontDoor1", - armfrontdoor.FrontDoor{ - Location: to.Ptr("westus"), - Tags: map[string]*string{ - "tag1": to.Ptr("value1"), - "tag2": to.Ptr("value2"), - }, - Properties: &armfrontdoor.Properties{ - BackendPools: []*armfrontdoor.BackendPool{ - { - Name: to.Ptr("backendPool1"), - Properties: &armfrontdoor.BackendPoolProperties{ - Backends: []*armfrontdoor.Backend{ - { - Address: to.Ptr("w3.contoso.com"), - HTTPPort: to.Ptr[int32](80), - HTTPSPort: to.Ptr[int32](443), - Priority: to.Ptr[int32](2), - Weight: to.Ptr[int32](1), - }, - { - Address: to.Ptr("contoso.com.website-us-west-2.othercloud.net"), - HTTPPort: to.Ptr[int32](80), - HTTPSPort: to.Ptr[int32](443), - Priority: to.Ptr[int32](1), - PrivateLinkApprovalMessage: to.Ptr("Please approve the connection request for this Private Link"), - PrivateLinkLocation: to.Ptr("eastus"), - PrivateLinkResourceID: to.Ptr("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.Network/privateLinkServices/pls1"), - Weight: to.Ptr[int32](2), - }, - { - Address: to.Ptr("10.0.1.5"), - HTTPPort: to.Ptr[int32](80), - HTTPSPort: to.Ptr[int32](443), - Priority: to.Ptr[int32](1), - PrivateLinkAlias: to.Ptr("APPSERVER.d84e61f0-0870-4d24-9746-7438fa0019d1.westus2.azure.privatelinkservice"), - PrivateLinkApprovalMessage: to.Ptr("Please approve this request to connect to the Private Link"), - Weight: to.Ptr[int32](1), - }}, - HealthProbeSettings: &armfrontdoor.SubResource{ - ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/healthProbeSettings/healthProbeSettings1"), - }, - LoadBalancingSettings: &armfrontdoor.SubResource{ - ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/loadBalancingSettings/loadBalancingSettings1"), - }, - }, - }}, - BackendPoolsSettings: &armfrontdoor.BackendPoolsSettings{ - EnforceCertificateNameCheck: to.Ptr(armfrontdoor.EnforceCertificateNameCheckEnabledStateEnabled), - SendRecvTimeoutSeconds: to.Ptr[int32](60), - }, - EnabledState: to.Ptr(armfrontdoor.FrontDoorEnabledStateEnabled), - FrontendEndpoints: []*armfrontdoor.FrontendEndpoint{ - { - Name: to.Ptr("frontendEndpoint1"), - Properties: &armfrontdoor.FrontendEndpointProperties{ - HostName: to.Ptr("www.contoso.com"), - SessionAffinityEnabledState: to.Ptr(armfrontdoor.SessionAffinityEnabledStateEnabled), - SessionAffinityTTLSeconds: to.Ptr[int32](60), - WebApplicationFirewallPolicyLink: &armfrontdoor.FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink{ - ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), - }, - }, - }, - { - Name: to.Ptr("default"), - Properties: &armfrontdoor.FrontendEndpointProperties{ - HostName: to.Ptr("frontDoor1.azurefd.net"), - }, - }}, - HealthProbeSettings: []*armfrontdoor.HealthProbeSettingsModel{ - { - Name: to.Ptr("healthProbeSettings1"), - Properties: &armfrontdoor.HealthProbeSettingsProperties{ - Path: to.Ptr("/"), - EnabledState: to.Ptr(armfrontdoor.HealthProbeEnabledEnabled), - HealthProbeMethod: to.Ptr(armfrontdoor.FrontDoorHealthProbeMethodHEAD), - IntervalInSeconds: to.Ptr[int32](120), - Protocol: to.Ptr(armfrontdoor.FrontDoorProtocolHTTP), - }, - }}, - LoadBalancingSettings: []*armfrontdoor.LoadBalancingSettingsModel{ - { - Name: to.Ptr("loadBalancingSettings1"), - Properties: &armfrontdoor.LoadBalancingSettingsProperties{ - SampleSize: to.Ptr[int32](4), - SuccessfulSamplesRequired: to.Ptr[int32](2), - }, - }}, - RoutingRules: []*armfrontdoor.RoutingRule{ - { - Name: to.Ptr("routingRule1"), - Properties: &armfrontdoor.RoutingRuleProperties{ - AcceptedProtocols: []*armfrontdoor.FrontDoorProtocol{ - to.Ptr(armfrontdoor.FrontDoorProtocolHTTP)}, - EnabledState: to.Ptr(armfrontdoor.RoutingRuleEnabledStateEnabled), - FrontendEndpoints: []*armfrontdoor.SubResource{ - { - ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/frontendEndpoint1"), - }, - { - ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/default"), - }}, - PatternsToMatch: []*string{ - to.Ptr("/*")}, - RouteConfiguration: &armfrontdoor.ForwardingConfiguration{ - ODataType: to.Ptr("#Microsoft.Azure.FrontDoor.Models.FrontdoorForwardingConfiguration"), - BackendPool: &armfrontdoor.SubResource{ - ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1"), - }, - }, - RulesEngine: &armfrontdoor.SubResource{ - ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/rulesEngines/rulesEngine1"), - }, - WebApplicationFirewallPolicyLink: &armfrontdoor.RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink{ - ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), - }, - }, - }}, - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorDelete.json -func ExampleFrontDoorsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewFrontDoorsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "rg1", - "frontDoor1", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorValidateCustomDomain.json -func ExampleFrontDoorsClient_ValidateCustomDomain() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewFrontDoorsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ValidateCustomDomain(ctx, - "rg1", - "frontDoor1", - armfrontdoor.ValidateCustomDomainInput{ - HostName: to.Ptr("www.someDomain.com"), - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_frontendendpoints_client_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_frontendendpoints_client_test.go deleted file mode 100644 index 3e31f7772743..000000000000 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_frontendendpoints_client_test.go +++ /dev/null @@ -1,66 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armfrontdoor_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/frontdoor/armfrontdoor" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorFrontendEndpointList.json -func ExampleFrontendEndpointsClient_NewListByFrontDoorPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewFrontendEndpointsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByFrontDoorPager("rg1", - "frontDoor1", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorFrontendEndpointGet.json -func ExampleFrontendEndpointsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewFrontendEndpointsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "rg1", - "frontDoor1", - "frontendEndpoint1", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_managedrulesets_client_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_managedrulesets_client_test.go deleted file mode 100644 index 9a475aee5682..000000000000 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_managedrulesets_client_test.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armfrontdoor_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/frontdoor/armfrontdoor" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-11-01/examples/WafListManagedRuleSets.json -func ExampleManagedRuleSetsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewManagedRuleSetsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_networkexperimentprofiles_client_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_networkexperimentprofiles_client_test.go deleted file mode 100644 index e0347e141bb9..000000000000 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_networkexperimentprofiles_client_test.go +++ /dev/null @@ -1,180 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armfrontdoor_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/frontdoor/armfrontdoor" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentListProfiles.json -func ExampleNetworkExperimentProfilesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewNetworkExperimentProfilesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentListProfiles.json -func ExampleNetworkExperimentProfilesClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewNetworkExperimentProfilesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByResourceGroupPager("MyResourceGroup", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentGetProfile.json -func ExampleNetworkExperimentProfilesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewNetworkExperimentProfilesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "MyResourceGroup", - "MyProfile", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentCreateProfile.json -func ExampleNetworkExperimentProfilesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewNetworkExperimentProfilesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "MyProfile", - "MyResourceGroup", - armfrontdoor.Profile{ - Location: to.Ptr("WestUs"), - Properties: &armfrontdoor.ProfileProperties{ - EnabledState: to.Ptr(armfrontdoor.StateEnabled), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentUpdateProfile.json -func ExampleNetworkExperimentProfilesClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewNetworkExperimentProfilesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginUpdate(ctx, - "MyResourceGroup", - "MyProfile", - armfrontdoor.ProfileUpdateModel{ - Properties: &armfrontdoor.ProfileUpdateProperties{ - EnabledState: to.Ptr(armfrontdoor.StateEnabled), - }, - Tags: map[string]*string{ - "key1": to.Ptr("value1"), - "key2": to.Ptr("value2"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentDeleteProfile.json -func ExampleNetworkExperimentProfilesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewNetworkExperimentProfilesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "MyResourceGroup", - "MyProfile", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_policies_client_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_policies_client_test.go deleted file mode 100644 index 28ea0b80f644..000000000000 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_policies_client_test.go +++ /dev/null @@ -1,210 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armfrontdoor_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/frontdoor/armfrontdoor" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-11-01/examples/WafListPolicies.json -func ExamplePoliciesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewPoliciesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("rg1", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-11-01/examples/WafPolicyGet.json -func ExamplePoliciesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewPoliciesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "rg1", - "Policy1", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-11-01/examples/WafPolicyCreateOrUpdate.json -func ExamplePoliciesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewPoliciesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "rg1", - "Policy1", - armfrontdoor.WebApplicationFirewallPolicy{ - Properties: &armfrontdoor.WebApplicationFirewallPolicyProperties{ - CustomRules: &armfrontdoor.CustomRuleList{ - Rules: []*armfrontdoor.CustomRule{ - { - Name: to.Ptr("Rule1"), - Action: to.Ptr(armfrontdoor.ActionTypeBlock), - MatchConditions: []*armfrontdoor.MatchCondition{ - { - MatchValue: []*string{ - to.Ptr("192.168.1.0/24"), - to.Ptr("10.0.0.0/24")}, - MatchVariable: to.Ptr(armfrontdoor.MatchVariableRemoteAddr), - Operator: to.Ptr(armfrontdoor.OperatorIPMatch), - }}, - Priority: to.Ptr[int32](1), - RateLimitThreshold: to.Ptr[int32](1000), - RuleType: to.Ptr(armfrontdoor.RuleTypeRateLimitRule), - }, - { - Name: to.Ptr("Rule2"), - Action: to.Ptr(armfrontdoor.ActionTypeBlock), - MatchConditions: []*armfrontdoor.MatchCondition{ - { - MatchValue: []*string{ - to.Ptr("CH")}, - MatchVariable: to.Ptr(armfrontdoor.MatchVariableRemoteAddr), - Operator: to.Ptr(armfrontdoor.OperatorGeoMatch), - }, - { - MatchValue: []*string{ - to.Ptr("windows")}, - MatchVariable: to.Ptr(armfrontdoor.MatchVariableRequestHeader), - Operator: to.Ptr(armfrontdoor.OperatorContains), - Selector: to.Ptr("UserAgent"), - Transforms: []*armfrontdoor.TransformType{ - to.Ptr(armfrontdoor.TransformTypeLowercase)}, - }}, - Priority: to.Ptr[int32](2), - RuleType: to.Ptr(armfrontdoor.RuleTypeMatchRule), - }}, - }, - ManagedRules: &armfrontdoor.ManagedRuleSetList{ - ManagedRuleSets: []*armfrontdoor.ManagedRuleSet{ - { - Exclusions: []*armfrontdoor.ManagedRuleExclusion{ - { - MatchVariable: to.Ptr(armfrontdoor.ManagedRuleExclusionMatchVariableRequestHeaderNames), - Selector: to.Ptr("User-Agent"), - SelectorMatchOperator: to.Ptr(armfrontdoor.ManagedRuleExclusionSelectorMatchOperatorEquals), - }}, - RuleGroupOverrides: []*armfrontdoor.ManagedRuleGroupOverride{ - { - Exclusions: []*armfrontdoor.ManagedRuleExclusion{ - { - MatchVariable: to.Ptr(armfrontdoor.ManagedRuleExclusionMatchVariableRequestCookieNames), - Selector: to.Ptr("token"), - SelectorMatchOperator: to.Ptr(armfrontdoor.ManagedRuleExclusionSelectorMatchOperatorStartsWith), - }}, - RuleGroupName: to.Ptr("SQLI"), - Rules: []*armfrontdoor.ManagedRuleOverride{ - { - Action: to.Ptr(armfrontdoor.ActionTypeRedirect), - EnabledState: to.Ptr(armfrontdoor.ManagedRuleEnabledStateEnabled), - Exclusions: []*armfrontdoor.ManagedRuleExclusion{ - { - MatchVariable: to.Ptr(armfrontdoor.ManagedRuleExclusionMatchVariableQueryStringArgNames), - Selector: to.Ptr("query"), - SelectorMatchOperator: to.Ptr(armfrontdoor.ManagedRuleExclusionSelectorMatchOperatorEquals), - }}, - RuleID: to.Ptr("942100"), - }, - { - EnabledState: to.Ptr(armfrontdoor.ManagedRuleEnabledStateDisabled), - RuleID: to.Ptr("942110"), - }}, - }}, - RuleSetAction: to.Ptr(armfrontdoor.ManagedRuleSetActionTypeBlock), - RuleSetType: to.Ptr("DefaultRuleSet"), - RuleSetVersion: to.Ptr("1.0"), - }}, - }, - PolicySettings: &armfrontdoor.PolicySettings{ - CustomBlockResponseBody: to.Ptr("PGh0bWw+CjxoZWFkZXI+PHRpdGxlPkhlbGxvPC90aXRsZT48L2hlYWRlcj4KPGJvZHk+CkhlbGxvIHdvcmxkCjwvYm9keT4KPC9odG1sPg=="), - CustomBlockResponseStatusCode: to.Ptr[int32](499), - EnabledState: to.Ptr(armfrontdoor.PolicyEnabledStateEnabled), - Mode: to.Ptr(armfrontdoor.PolicyModePrevention), - RedirectURL: to.Ptr("http://www.bing.com"), - RequestBodyCheck: to.Ptr(armfrontdoor.PolicyRequestBodyCheckDisabled), - }, - }, - SKU: &armfrontdoor.SKU{ - Name: to.Ptr(armfrontdoor.SKUNameClassicAzureFrontDoor), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-11-01/examples/WafPolicyDelete.json -func ExamplePoliciesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewPoliciesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "rg1", - "Policy1", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_preconfiguredendpoints_client_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_preconfiguredendpoints_client_test.go deleted file mode 100644 index 5b9785fd29c9..000000000000 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_preconfiguredendpoints_client_test.go +++ /dev/null @@ -1,43 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armfrontdoor_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/frontdoor/armfrontdoor" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentGetPreconfiguredEndpoints.json -func ExamplePreconfiguredEndpointsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewPreconfiguredEndpointsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("MyResourceGroup", - "MyProfile", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_reports_client_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_reports_client_test.go deleted file mode 100644 index 10c1642fa538..000000000000 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_reports_client_test.go +++ /dev/null @@ -1,74 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armfrontdoor_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/frontdoor/armfrontdoor" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentGetLatencyScorecard.json -func ExampleReportsClient_GetLatencyScorecards() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewReportsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetLatencyScorecards(ctx, - "MyResourceGroup", - "MyProfile", - "MyExperiment", - armfrontdoor.LatencyScorecardAggregationIntervalDaily, - &armfrontdoor.ReportsClientGetLatencyScorecardsOptions{EndDateTimeUTC: nil, - Country: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentGetTimeseries.json -func ExampleReportsClient_GetTimeseries() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewReportsClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetTimeseries(ctx, - "MyResourceGroup", - "MyProfile", - "MyExperiment", - func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-21T17:32:28Z"); return t }(), - func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-21T17:32:28Z"); return t }(), - armfrontdoor.TimeseriesAggregationIntervalHourly, - armfrontdoor.TimeseriesTypeMeasurementCounts, - &armfrontdoor.ReportsClientGetTimeseriesOptions{Endpoint: nil, - Country: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_rulesengines_client_test.go b/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_rulesengines_client_test.go deleted file mode 100644 index 2e9dc90bc477..000000000000 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/ze_generated_example_rulesengines_client_test.go +++ /dev/null @@ -1,198 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armfrontdoor_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/frontdoor/armfrontdoor" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorRulesEngineList.json -func ExampleRulesEnginesClient_NewListByFrontDoorPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewRulesEnginesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByFrontDoorPager("rg1", - "frontDoor1", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorRulesEngineGet.json -func ExampleRulesEnginesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewRulesEnginesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "rg1", - "frontDoor1", - "rulesEngine1", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorRulesEngineCreate.json -func ExampleRulesEnginesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewRulesEnginesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreateOrUpdate(ctx, - "rg1", - "frontDoor1", - "rulesEngine1", - armfrontdoor.RulesEngine{ - Properties: &armfrontdoor.RulesEngineProperties{ - Rules: []*armfrontdoor.RulesEngineRule{ - { - Name: to.Ptr("Rule1"), - Action: &armfrontdoor.RulesEngineAction{ - RouteConfigurationOverride: &armfrontdoor.RedirectConfiguration{ - ODataType: to.Ptr("#Microsoft.Azure.FrontDoor.Models.FrontdoorRedirectConfiguration"), - CustomFragment: to.Ptr("fragment"), - CustomHost: to.Ptr("www.bing.com"), - CustomPath: to.Ptr("/api"), - CustomQueryString: to.Ptr("a=b"), - RedirectProtocol: to.Ptr(armfrontdoor.FrontDoorRedirectProtocolHTTPSOnly), - RedirectType: to.Ptr(armfrontdoor.FrontDoorRedirectTypeMoved), - }, - }, - MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ - { - RulesEngineMatchValue: []*string{ - to.Ptr("CH")}, - RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariableRemoteAddr), - RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorGeoMatch), - }}, - MatchProcessingBehavior: to.Ptr(armfrontdoor.MatchProcessingBehaviorStop), - Priority: to.Ptr[int32](1), - }, - { - Name: to.Ptr("Rule2"), - Action: &armfrontdoor.RulesEngineAction{ - ResponseHeaderActions: []*armfrontdoor.HeaderAction{ - { - HeaderActionType: to.Ptr(armfrontdoor.HeaderActionTypeOverwrite), - HeaderName: to.Ptr("Cache-Control"), - Value: to.Ptr("public, max-age=31536000"), - }}, - }, - MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ - { - RulesEngineMatchValue: []*string{ - to.Ptr("jpg")}, - RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariableRequestFilenameExtension), - RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorEqual), - Transforms: []*armfrontdoor.Transform{ - to.Ptr(armfrontdoor.TransformLowercase)}, - }}, - Priority: to.Ptr[int32](2), - }, - { - Name: to.Ptr("Rule3"), - Action: &armfrontdoor.RulesEngineAction{ - RouteConfigurationOverride: &armfrontdoor.ForwardingConfiguration{ - ODataType: to.Ptr("#Microsoft.Azure.FrontDoor.Models.FrontdoorForwardingConfiguration"), - BackendPool: &armfrontdoor.SubResource{ - ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1"), - }, - CacheConfiguration: &armfrontdoor.CacheConfiguration{ - CacheDuration: to.Ptr("P1DT12H20M30S"), - DynamicCompression: to.Ptr(armfrontdoor.DynamicCompressionEnabledDisabled), - QueryParameterStripDirective: to.Ptr(armfrontdoor.FrontDoorQueryStripOnly), - QueryParameters: to.Ptr("a=b,p=q"), - }, - ForwardingProtocol: to.Ptr(armfrontdoor.FrontDoorForwardingProtocolHTTPSOnly), - }, - }, - MatchConditions: []*armfrontdoor.RulesEngineMatchCondition{ - { - NegateCondition: to.Ptr(false), - RulesEngineMatchValue: []*string{ - to.Ptr("allowoverride")}, - RulesEngineMatchVariable: to.Ptr(armfrontdoor.RulesEngineMatchVariableRequestHeader), - RulesEngineOperator: to.Ptr(armfrontdoor.RulesEngineOperatorEqual), - Selector: to.Ptr("Rules-Engine-Route-Forward"), - Transforms: []*armfrontdoor.Transform{ - to.Ptr(armfrontdoor.TransformLowercase)}, - }}, - Priority: to.Ptr[int32](3), - }}, - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/frontdoor/resource-manager/Microsoft.Network/stable/2020-05-01/examples/FrontdoorRulesEngineDelete.json -func ExampleRulesEnginesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armfrontdoor.NewRulesEnginesClient("subid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "rg1", - "frontDoor1", - "rulesEngine1", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_models_serde.go b/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_models_serde.go deleted file mode 100644 index 1c2413bd7124..000000000000 --- a/sdk/resourcemanager/frontdoor/armfrontdoor/zz_generated_models_serde.go +++ /dev/null @@ -1,670 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armfrontdoor - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type BackendPoolProperties. -func (b BackendPoolProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "backends", b.Backends) - populate(objectMap, "healthProbeSettings", b.HealthProbeSettings) - populate(objectMap, "loadBalancingSettings", b.LoadBalancingSettings) - populate(objectMap, "resourceState", b.ResourceState) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type BackendPoolUpdateParameters. -func (b BackendPoolUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "backends", b.Backends) - populate(objectMap, "healthProbeSettings", b.HealthProbeSettings) - populate(objectMap, "loadBalancingSettings", b.LoadBalancingSettings) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type CustomRule. -func (c CustomRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "action", c.Action) - populate(objectMap, "enabledState", c.EnabledState) - populate(objectMap, "matchConditions", c.MatchConditions) - populate(objectMap, "name", c.Name) - populate(objectMap, "priority", c.Priority) - populate(objectMap, "rateLimitDurationInMinutes", c.RateLimitDurationInMinutes) - populate(objectMap, "rateLimitThreshold", c.RateLimitThreshold) - populate(objectMap, "ruleType", c.RuleType) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type CustomRuleList. -func (c CustomRuleList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "rules", c.Rules) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type Experiment. -func (e Experiment) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", e.ID) - populate(objectMap, "location", e.Location) - populate(objectMap, "name", e.Name) - populate(objectMap, "properties", e.Properties) - populate(objectMap, "tags", e.Tags) - populate(objectMap, "type", e.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ExperimentUpdateModel. -func (e ExperimentUpdateModel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "properties", e.Properties) - populate(objectMap, "tags", e.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ForwardingConfiguration. -func (f ForwardingConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "backendPool", f.BackendPool) - populate(objectMap, "cacheConfiguration", f.CacheConfiguration) - populate(objectMap, "customForwardingPath", f.CustomForwardingPath) - populate(objectMap, "forwardingProtocol", f.ForwardingProtocol) - objectMap["@odata.type"] = "#Microsoft.Azure.FrontDoor.Models.FrontdoorForwardingConfiguration" - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ForwardingConfiguration. -func (f *ForwardingConfiguration) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", f, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "backendPool": - err = unpopulate(val, "BackendPool", &f.BackendPool) - delete(rawMsg, key) - case "cacheConfiguration": - err = unpopulate(val, "CacheConfiguration", &f.CacheConfiguration) - delete(rawMsg, key) - case "customForwardingPath": - err = unpopulate(val, "CustomForwardingPath", &f.CustomForwardingPath) - delete(rawMsg, key) - case "forwardingProtocol": - err = unpopulate(val, "ForwardingProtocol", &f.ForwardingProtocol) - delete(rawMsg, key) - case "@odata.type": - err = unpopulate(val, "ODataType", &f.ODataType) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", f, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type FrontDoor. -func (f FrontDoor) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", f.ID) - populate(objectMap, "location", f.Location) - populate(objectMap, "name", f.Name) - populate(objectMap, "properties", f.Properties) - populate(objectMap, "tags", f.Tags) - populate(objectMap, "type", f.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type LatencyScorecard. -func (l LatencyScorecard) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", l.ID) - populate(objectMap, "location", l.Location) - populate(objectMap, "name", l.Name) - populate(objectMap, "properties", l.Properties) - populate(objectMap, "tags", l.Tags) - populate(objectMap, "type", l.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type LatencyScorecardProperties. -func (l LatencyScorecardProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "country", l.Country) - populate(objectMap, "description", l.Description) - populateTimeRFC3339(objectMap, "endDateTimeUTC", l.EndDateTimeUTC) - populate(objectMap, "endpointA", l.EndpointA) - populate(objectMap, "endpointB", l.EndpointB) - populate(objectMap, "id", l.ID) - populate(objectMap, "latencyMetrics", l.LatencyMetrics) - populate(objectMap, "name", l.Name) - populateTimeRFC3339(objectMap, "startDateTimeUTC", l.StartDateTimeUTC) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type LatencyScorecardProperties. -func (l *LatencyScorecardProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", l, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "country": - err = unpopulate(val, "Country", &l.Country) - delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &l.Description) - delete(rawMsg, key) - case "endDateTimeUTC": - err = unpopulateTimeRFC3339(val, "EndDateTimeUTC", &l.EndDateTimeUTC) - delete(rawMsg, key) - case "endpointA": - err = unpopulate(val, "EndpointA", &l.EndpointA) - delete(rawMsg, key) - case "endpointB": - err = unpopulate(val, "EndpointB", &l.EndpointB) - delete(rawMsg, key) - case "id": - err = unpopulate(val, "ID", &l.ID) - delete(rawMsg, key) - case "latencyMetrics": - err = unpopulate(val, "LatencyMetrics", &l.LatencyMetrics) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &l.Name) - delete(rawMsg, key) - case "startDateTimeUTC": - err = unpopulateTimeRFC3339(val, "StartDateTimeUTC", &l.StartDateTimeUTC) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", l, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ManagedRuleGroupDefinition. -func (m ManagedRuleGroupDefinition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "description", m.Description) - populate(objectMap, "ruleGroupName", m.RuleGroupName) - populate(objectMap, "rules", m.Rules) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ManagedRuleGroupOverride. -func (m ManagedRuleGroupOverride) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "exclusions", m.Exclusions) - populate(objectMap, "ruleGroupName", m.RuleGroupName) - populate(objectMap, "rules", m.Rules) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ManagedRuleOverride. -func (m ManagedRuleOverride) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "action", m.Action) - populate(objectMap, "enabledState", m.EnabledState) - populate(objectMap, "exclusions", m.Exclusions) - populate(objectMap, "ruleId", m.RuleID) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ManagedRuleSet. -func (m ManagedRuleSet) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "exclusions", m.Exclusions) - populate(objectMap, "ruleGroupOverrides", m.RuleGroupOverrides) - populate(objectMap, "ruleSetAction", m.RuleSetAction) - populate(objectMap, "ruleSetType", m.RuleSetType) - populate(objectMap, "ruleSetVersion", m.RuleSetVersion) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ManagedRuleSetDefinition. -func (m ManagedRuleSetDefinition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", m.ID) - populate(objectMap, "location", m.Location) - populate(objectMap, "name", m.Name) - populate(objectMap, "properties", m.Properties) - populate(objectMap, "tags", m.Tags) - populate(objectMap, "type", m.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ManagedRuleSetDefinitionProperties. -func (m ManagedRuleSetDefinitionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "provisioningState", m.ProvisioningState) - populate(objectMap, "ruleGroups", m.RuleGroups) - populate(objectMap, "ruleSetId", m.RuleSetID) - populate(objectMap, "ruleSetType", m.RuleSetType) - populate(objectMap, "ruleSetVersion", m.RuleSetVersion) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ManagedRuleSetList. -func (m ManagedRuleSetList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "managedRuleSets", m.ManagedRuleSets) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type MatchCondition. -func (m MatchCondition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "matchValue", m.MatchValue) - populate(objectMap, "matchVariable", m.MatchVariable) - populate(objectMap, "negateCondition", m.NegateCondition) - populate(objectMap, "operator", m.Operator) - populate(objectMap, "selector", m.Selector) - populate(objectMap, "transforms", m.Transforms) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type PreconfiguredEndpoint. -func (p PreconfiguredEndpoint) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", p.ID) - populate(objectMap, "location", p.Location) - populate(objectMap, "name", p.Name) - populate(objectMap, "properties", p.Properties) - populate(objectMap, "tags", p.Tags) - populate(objectMap, "type", p.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type Profile. -func (p Profile) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "etag", p.Etag) - populate(objectMap, "id", p.ID) - populate(objectMap, "location", p.Location) - populate(objectMap, "name", p.Name) - populate(objectMap, "properties", p.Properties) - populate(objectMap, "tags", p.Tags) - populate(objectMap, "type", p.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ProfileUpdateModel. -func (p ProfileUpdateModel) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "properties", p.Properties) - populate(objectMap, "tags", p.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type Properties. -func (p Properties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "backendPools", p.BackendPools) - populate(objectMap, "backendPoolsSettings", p.BackendPoolsSettings) - populate(objectMap, "cname", p.Cname) - populate(objectMap, "enabledState", p.EnabledState) - populate(objectMap, "friendlyName", p.FriendlyName) - populate(objectMap, "frontdoorId", p.FrontdoorID) - populate(objectMap, "frontendEndpoints", p.FrontendEndpoints) - populate(objectMap, "healthProbeSettings", p.HealthProbeSettings) - populate(objectMap, "loadBalancingSettings", p.LoadBalancingSettings) - populate(objectMap, "provisioningState", p.ProvisioningState) - populate(objectMap, "resourceState", p.ResourceState) - populate(objectMap, "routingRules", p.RoutingRules) - populate(objectMap, "rulesEngines", p.RulesEngines) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type PurgeParameters. -func (p PurgeParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "contentPaths", p.ContentPaths) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type RedirectConfiguration. -func (r RedirectConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "customFragment", r.CustomFragment) - populate(objectMap, "customHost", r.CustomHost) - populate(objectMap, "customPath", r.CustomPath) - populate(objectMap, "customQueryString", r.CustomQueryString) - objectMap["@odata.type"] = "#Microsoft.Azure.FrontDoor.Models.FrontdoorRedirectConfiguration" - populate(objectMap, "redirectProtocol", r.RedirectProtocol) - populate(objectMap, "redirectType", r.RedirectType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type RedirectConfiguration. -func (r *RedirectConfiguration) 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", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "customFragment": - err = unpopulate(val, "CustomFragment", &r.CustomFragment) - delete(rawMsg, key) - case "customHost": - err = unpopulate(val, "CustomHost", &r.CustomHost) - delete(rawMsg, key) - case "customPath": - err = unpopulate(val, "CustomPath", &r.CustomPath) - delete(rawMsg, key) - case "customQueryString": - err = unpopulate(val, "CustomQueryString", &r.CustomQueryString) - delete(rawMsg, key) - case "@odata.type": - err = unpopulate(val, "ODataType", &r.ODataType) - delete(rawMsg, key) - case "redirectProtocol": - err = unpopulate(val, "RedirectProtocol", &r.RedirectProtocol) - delete(rawMsg, key) - case "redirectType": - err = unpopulate(val, "RedirectType", &r.RedirectType) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Resource. -func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", r.ID) - populate(objectMap, "location", r.Location) - populate(objectMap, "name", r.Name) - populate(objectMap, "tags", r.Tags) - populate(objectMap, "type", r.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type RoutingRuleProperties. -func (r RoutingRuleProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "acceptedProtocols", r.AcceptedProtocols) - populate(objectMap, "enabledState", r.EnabledState) - populate(objectMap, "frontendEndpoints", r.FrontendEndpoints) - populate(objectMap, "patternsToMatch", r.PatternsToMatch) - populate(objectMap, "resourceState", r.ResourceState) - populate(objectMap, "routeConfiguration", r.RouteConfiguration) - populate(objectMap, "rulesEngine", r.RulesEngine) - populate(objectMap, "webApplicationFirewallPolicyLink", r.WebApplicationFirewallPolicyLink) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type RoutingRuleProperties. -func (r *RoutingRuleProperties) 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", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "acceptedProtocols": - err = unpopulate(val, "AcceptedProtocols", &r.AcceptedProtocols) - delete(rawMsg, key) - case "enabledState": - err = unpopulate(val, "EnabledState", &r.EnabledState) - delete(rawMsg, key) - case "frontendEndpoints": - err = unpopulate(val, "FrontendEndpoints", &r.FrontendEndpoints) - delete(rawMsg, key) - case "patternsToMatch": - err = unpopulate(val, "PatternsToMatch", &r.PatternsToMatch) - delete(rawMsg, key) - case "resourceState": - err = unpopulate(val, "ResourceState", &r.ResourceState) - delete(rawMsg, key) - case "routeConfiguration": - r.RouteConfiguration, err = unmarshalRouteConfigurationClassification(val) - delete(rawMsg, key) - case "rulesEngine": - err = unpopulate(val, "RulesEngine", &r.RulesEngine) - delete(rawMsg, key) - case "webApplicationFirewallPolicyLink": - err = unpopulate(val, "WebApplicationFirewallPolicyLink", &r.WebApplicationFirewallPolicyLink) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type RoutingRuleUpdateParameters. -func (r RoutingRuleUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "acceptedProtocols", r.AcceptedProtocols) - populate(objectMap, "enabledState", r.EnabledState) - populate(objectMap, "frontendEndpoints", r.FrontendEndpoints) - populate(objectMap, "patternsToMatch", r.PatternsToMatch) - populate(objectMap, "routeConfiguration", r.RouteConfiguration) - populate(objectMap, "rulesEngine", r.RulesEngine) - populate(objectMap, "webApplicationFirewallPolicyLink", r.WebApplicationFirewallPolicyLink) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type RoutingRuleUpdateParameters. -func (r *RoutingRuleUpdateParameters) 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", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "acceptedProtocols": - err = unpopulate(val, "AcceptedProtocols", &r.AcceptedProtocols) - delete(rawMsg, key) - case "enabledState": - err = unpopulate(val, "EnabledState", &r.EnabledState) - delete(rawMsg, key) - case "frontendEndpoints": - err = unpopulate(val, "FrontendEndpoints", &r.FrontendEndpoints) - delete(rawMsg, key) - case "patternsToMatch": - err = unpopulate(val, "PatternsToMatch", &r.PatternsToMatch) - delete(rawMsg, key) - case "routeConfiguration": - r.RouteConfiguration, err = unmarshalRouteConfigurationClassification(val) - delete(rawMsg, key) - case "rulesEngine": - err = unpopulate(val, "RulesEngine", &r.RulesEngine) - delete(rawMsg, key) - case "webApplicationFirewallPolicyLink": - err = unpopulate(val, "WebApplicationFirewallPolicyLink", &r.WebApplicationFirewallPolicyLink) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type RulesEngineAction. -func (r RulesEngineAction) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "requestHeaderActions", r.RequestHeaderActions) - populate(objectMap, "responseHeaderActions", r.ResponseHeaderActions) - populate(objectMap, "routeConfigurationOverride", r.RouteConfigurationOverride) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type RulesEngineAction. -func (r *RulesEngineAction) 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", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "requestHeaderActions": - err = unpopulate(val, "RequestHeaderActions", &r.RequestHeaderActions) - delete(rawMsg, key) - case "responseHeaderActions": - err = unpopulate(val, "ResponseHeaderActions", &r.ResponseHeaderActions) - delete(rawMsg, key) - case "routeConfigurationOverride": - r.RouteConfigurationOverride, err = unmarshalRouteConfigurationClassification(val) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type RulesEngineMatchCondition. -func (r RulesEngineMatchCondition) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "negateCondition", r.NegateCondition) - populate(objectMap, "rulesEngineMatchValue", r.RulesEngineMatchValue) - populate(objectMap, "rulesEngineMatchVariable", r.RulesEngineMatchVariable) - populate(objectMap, "rulesEngineOperator", r.RulesEngineOperator) - populate(objectMap, "selector", r.Selector) - populate(objectMap, "transforms", r.Transforms) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type RulesEngineProperties. -func (r RulesEngineProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "resourceState", r.ResourceState) - populate(objectMap, "rules", r.Rules) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type RulesEngineRule. -func (r RulesEngineRule) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "action", r.Action) - populate(objectMap, "matchConditions", r.MatchConditions) - populate(objectMap, "matchProcessingBehavior", r.MatchProcessingBehavior) - populate(objectMap, "name", r.Name) - populate(objectMap, "priority", r.Priority) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type RulesEngineUpdateParameters. -func (r RulesEngineUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "rules", r.Rules) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type Timeseries. -func (t Timeseries) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) - populate(objectMap, "name", t.Name) - populate(objectMap, "properties", t.Properties) - populate(objectMap, "tags", t.Tags) - populate(objectMap, "type", t.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type TimeseriesProperties. -func (t TimeseriesProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "aggregationInterval", t.AggregationInterval) - populate(objectMap, "country", t.Country) - populate(objectMap, "endDateTimeUTC", t.EndDateTimeUTC) - populate(objectMap, "endpoint", t.Endpoint) - populate(objectMap, "startDateTimeUTC", t.StartDateTimeUTC) - populate(objectMap, "timeseriesData", t.TimeseriesData) - populate(objectMap, "timeseriesType", t.TimeseriesType) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type UpdateParameters. -func (u UpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "backendPools", u.BackendPools) - populate(objectMap, "backendPoolsSettings", u.BackendPoolsSettings) - populate(objectMap, "enabledState", u.EnabledState) - populate(objectMap, "friendlyName", u.FriendlyName) - populate(objectMap, "frontendEndpoints", u.FrontendEndpoints) - populate(objectMap, "healthProbeSettings", u.HealthProbeSettings) - populate(objectMap, "loadBalancingSettings", u.LoadBalancingSettings) - populate(objectMap, "routingRules", u.RoutingRules) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type WebApplicationFirewallPolicy. -func (w WebApplicationFirewallPolicy) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "etag", w.Etag) - populate(objectMap, "id", w.ID) - populate(objectMap, "location", w.Location) - populate(objectMap, "name", w.Name) - populate(objectMap, "properties", w.Properties) - populate(objectMap, "sku", w.SKU) - populate(objectMap, "tags", w.Tags) - populate(objectMap, "type", w.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type WebApplicationFirewallPolicyProperties. -func (w WebApplicationFirewallPolicyProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "customRules", w.CustomRules) - populate(objectMap, "frontendEndpointLinks", w.FrontendEndpointLinks) - populate(objectMap, "managedRules", w.ManagedRules) - populate(objectMap, "policySettings", w.PolicySettings) - populate(objectMap, "provisioningState", w.ProvisioningState) - populate(objectMap, "resourceState", w.ResourceState) - populate(objectMap, "routingRuleLinks", w.RoutingRuleLinks) - populate(objectMap, "securityPolicyLinks", w.SecurityPolicyLinks) - return json.Marshal(objectMap) -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} - -func unpopulate(data json.RawMessage, fn string, v interface{}) error { - if data == nil { - return nil - } - if err := json.Unmarshal(data, v); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - return nil -} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/CHANGELOG.md b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/CHANGELOG.md index 63f0592f3751..b42b5857a67e 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/CHANGELOG.md +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 1.0.0 (2022-05-17) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 1.0.0, which contains breaking changes. diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/README.md b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/README.md index 8fa1e46a7f3f..23e5e61a0822 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/README.md +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure Guest Configuration modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure Guest Configuration module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armguestconfiguration.NewAssignmentsClient(, cred, nil) +clientFactory, err := armguestconfiguration.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armguestconfiguration.NewAssignmentsClient(, cred, &options) +clientFactory, err := armguestconfiguration.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewAssignmentsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_assignmentreports_client.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreports_client.go similarity index 81% rename from sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_assignmentreports_client.go rename to sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreports_client.go index 6ef0aed788a6..4cc1953b94b2 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_assignmentreports_client.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreports_client.go @@ -5,6 +5,7 @@ // 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 armguestconfiguration @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,50 +24,42 @@ import ( // AssignmentReportsClient contains the methods for the GuestConfigurationAssignmentReports group. // Don't use this type directly, use NewAssignmentReportsClient() instead. type AssignmentReportsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAssignmentReportsClient creates a new instance of AssignmentReportsClient with the specified values. -// subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of -// the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of +// the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAssignmentReportsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AssignmentReportsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AssignmentReportsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AssignmentReportsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get a report for the guest configuration assignment, by reportId. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// resourceGroupName - The resource group name. -// guestConfigurationAssignmentName - The guest configuration assignment name. -// reportID - The GUID for the guest configuration assignment report. -// vmName - The name of the virtual machine. -// options - AssignmentReportsClientGetOptions contains the optional parameters for the AssignmentReportsClient.Get method. +// - resourceGroupName - The resource group name. +// - guestConfigurationAssignmentName - The guest configuration assignment name. +// - reportID - The GUID for the guest configuration assignment report. +// - vmName - The name of the virtual machine. +// - options - AssignmentReportsClientGetOptions contains the optional parameters for the AssignmentReportsClient.Get method. func (client *AssignmentReportsClient) Get(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, reportID string, vmName string, options *AssignmentReportsClientGetOptions) (AssignmentReportsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, guestConfigurationAssignmentName, reportID, vmName, options) if err != nil { return AssignmentReportsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentReportsClientGetResponse{}, err } @@ -101,7 +92,7 @@ func (client *AssignmentReportsClient) getCreateRequest(ctx context.Context, res return nil, errors.New("parameter vmName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vmName}", url.PathEscape(vmName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -123,17 +114,18 @@ func (client *AssignmentReportsClient) getHandleResponse(resp *http.Response) (A // List - List all reports for the guest configuration assignment, latest report first. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// resourceGroupName - The resource group name. -// guestConfigurationAssignmentName - The guest configuration assignment name. -// vmName - The name of the virtual machine. -// options - AssignmentReportsClientListOptions contains the optional parameters for the AssignmentReportsClient.List method. +// - resourceGroupName - The resource group name. +// - guestConfigurationAssignmentName - The guest configuration assignment name. +// - vmName - The name of the virtual machine. +// - options - AssignmentReportsClientListOptions contains the optional parameters for the AssignmentReportsClient.List method. func (client *AssignmentReportsClient) List(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, vmName string, options *AssignmentReportsClientListOptions) (AssignmentReportsClientListResponse, error) { req, err := client.listCreateRequest(ctx, resourceGroupName, guestConfigurationAssignmentName, vmName, options) if err != nil { return AssignmentReportsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentReportsClientListResponse{}, err } @@ -162,7 +154,7 @@ func (client *AssignmentReportsClient) listCreateRequest(ctx context.Context, re return nil, errors.New("parameter vmName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vmName}", url.PathEscape(vmName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreports_client_example_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreports_client_example_test.go new file mode 100644 index 000000000000..ed64e4485738 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreports_client_example_test.go @@ -0,0 +1,179 @@ +//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 armguestconfiguration_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listAllGuestConfigurationAssignmentReports.json +func ExampleAssignmentReportsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAssignmentReportsClient().List(ctx, "myResourceGroupName", "AuditSecureProtocol", "myVMName", 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.AssignmentReportList = armguestconfiguration.AssignmentReportList{ + // Value: []*armguestconfiguration.AssignmentReport{ + // { + // Name: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/myvm/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // Properties: &armguestconfiguration.AssignmentReportProperties{ + // Assignment: &armguestconfiguration.AssignmentInfo{ + // Name: to.Ptr("AuditSecureProtocol"), + // Configuration: &armguestconfiguration.ConfigurationInfo{ + // Name: to.Ptr("AuditSecureProtocol"), + // }, + // }, + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13Z"); return t}()), + // ReportID: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:13:53Z"); return t}()), + // VM: &armguestconfiguration.VMInfo{ + // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/myvm"), + // UUID: to.Ptr("vmuuid"), + // }, + // }, + // }, + // { + // Name: to.Ptr("41ee2caf-48f9-4999-a793-82ec7c6beb2c"), + // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/myvm/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/41ee2caf-48f9-4999-a793-82ec7c6beb2c"), + // Properties: &armguestconfiguration.AssignmentReportProperties{ + // Assignment: &armguestconfiguration.AssignmentInfo{ + // Name: to.Ptr("AuditSecureProtocol"), + // Configuration: &armguestconfiguration.ConfigurationInfo{ + // Name: to.Ptr("AuditSecureProtocol"), + // }, + // }, + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T20:14:13Z"); return t}()), + // ReportID: to.Ptr("41ee2caf-48f9-4999-a793-82ec7c6beb2c"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T20:13:53Z"); return t}()), + // VM: &armguestconfiguration.VMInfo{ + // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/myvm"), + // UUID: to.Ptr("vmuuid"), + // }, + // }, + // }}, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/getGuestConfigurationAssignmentReportById.json +func ExampleAssignmentReportsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAssignmentReportsClient().Get(ctx, "myResourceGroupName", "AuditSecureProtocol", "7367cbb8-ae99-47d0-a33b-a283564d2cb1", "myvm", 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.AssignmentReport = armguestconfiguration.AssignmentReport{ + // Name: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/myvm/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // Properties: &armguestconfiguration.AssignmentReportProperties{ + // Assignment: &armguestconfiguration.AssignmentInfo{ + // Name: to.Ptr("AuditSecureProtocol"), + // Configuration: &armguestconfiguration.ConfigurationInfo{ + // Name: to.Ptr("AuditSecureProtocol"), + // Version: to.Ptr("1.0.0.0"), + // }, + // }, + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13Z"); return t}()), + // ReportID: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:13:53Z"); return t}()), + // VM: &armguestconfiguration.VMInfo{ + // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/myvm"), + // UUID: to.Ptr("vmuuid"), + // }, + // Details: &armguestconfiguration.AssignmentReportDetails{ + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13Z"); return t}()), + // JobID: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // OperationType: to.Ptr(armguestconfiguration.TypeConsistency), + // Resources: []*armguestconfiguration.AssignmentReportResource{ + // { + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), + // Properties: map[string]any{ + // "ConfigurationName": "IsWebServerSecure", + // "DependsOn": nil, + // "IsSingleInstance": "Yes", + // "ModuleName": "SecureProtocolWebServer", + // "ModuleVersion": "1.0.0.3", + // "Protocols":[]any{ + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "SSL 2.0", + // }, + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "SSL 3.0", + // }, + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "TLS 1.0", + // }, + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "PCT 1.0", + // }, + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "Multi-Protocol Unified Hello", + // }, + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "TLS 1.1", + // }, + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "TLS 1.2", + // }, + // }, + // "PsDscRunAsCredential": nil, + // "Reasons": nil, + // "ResourceId": "[SecureWebServer]s1", + // "SourceInfo": nil, + // }, + // Reasons: []*armguestconfiguration.AssignmentReportResourceComplianceReason{ + // { + // Code: to.Ptr("DSC::RESOURCE::SUCCESS"), + // Phrase: to.Ptr("Operation successful."), + // }}, + // }}, + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:13:53Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_assignmentreportsvmss_client.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreportsvmss_client.go similarity index 81% rename from sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_assignmentreportsvmss_client.go rename to sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreportsvmss_client.go index 8b5f5360f87b..f08cc6b2e6e0 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_assignmentreportsvmss_client.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreportsvmss_client.go @@ -5,6 +5,7 @@ // 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 armguestconfiguration @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,51 +24,43 @@ import ( // AssignmentReportsVMSSClient contains the methods for the GuestConfigurationAssignmentReportsVMSS group. // Don't use this type directly, use NewAssignmentReportsVMSSClient() instead. type AssignmentReportsVMSSClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAssignmentReportsVMSSClient creates a new instance of AssignmentReportsVMSSClient with the specified values. -// subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of -// the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of +// the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAssignmentReportsVMSSClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AssignmentReportsVMSSClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AssignmentReportsVMSSClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AssignmentReportsVMSSClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get a report for the VMSS guest configuration assignment, by reportId. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// resourceGroupName - The resource group name. -// vmssName - The name of the virtual machine scale set. -// name - The guest configuration assignment name. -// id - The GUID for the guest configuration assignment report. -// options - AssignmentReportsVMSSClientGetOptions contains the optional parameters for the AssignmentReportsVMSSClient.Get -// method. +// - resourceGroupName - The resource group name. +// - vmssName - The name of the virtual machine scale set. +// - name - The guest configuration assignment name. +// - id - The GUID for the guest configuration assignment report. +// - options - AssignmentReportsVMSSClientGetOptions contains the optional parameters for the AssignmentReportsVMSSClient.Get +// method. func (client *AssignmentReportsVMSSClient) Get(ctx context.Context, resourceGroupName string, vmssName string, name string, id string, options *AssignmentReportsVMSSClientGetOptions) (AssignmentReportsVMSSClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, vmssName, name, id, options) if err != nil { return AssignmentReportsVMSSClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentReportsVMSSClientGetResponse{}, err } @@ -102,7 +93,7 @@ func (client *AssignmentReportsVMSSClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter id cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{id}", url.PathEscape(id)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -123,13 +114,13 @@ func (client *AssignmentReportsVMSSClient) getHandleResponse(resp *http.Response } // NewListPager - List all reports for the VMSS guest configuration assignment, latest report first. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// resourceGroupName - The resource group name. -// vmssName - The name of the virtual machine scale set. -// name - The guest configuration assignment name. -// options - AssignmentReportsVMSSClientListOptions contains the optional parameters for the AssignmentReportsVMSSClient.List -// method. +// - resourceGroupName - The resource group name. +// - vmssName - The name of the virtual machine scale set. +// - name - The guest configuration assignment name. +// - options - AssignmentReportsVMSSClientListOptions contains the optional parameters for the AssignmentReportsVMSSClient.NewListPager +// method. func (client *AssignmentReportsVMSSClient) NewListPager(resourceGroupName string, vmssName string, name string, options *AssignmentReportsVMSSClientListOptions) *runtime.Pager[AssignmentReportsVMSSClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AssignmentReportsVMSSClientListResponse]{ More: func(page AssignmentReportsVMSSClientListResponse) bool { @@ -140,7 +131,7 @@ func (client *AssignmentReportsVMSSClient) NewListPager(resourceGroupName string if err != nil { return AssignmentReportsVMSSClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentReportsVMSSClientListResponse{}, err } @@ -171,7 +162,7 @@ func (client *AssignmentReportsVMSSClient) listCreateRequest(ctx context.Context return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreportsvmss_client_example_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreportsvmss_client_example_test.go new file mode 100644 index 000000000000..716b216433ea --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentreportsvmss_client_example_test.go @@ -0,0 +1,184 @@ +//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 armguestconfiguration_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listAllVMSSGuestConfigurationAssignmentReports.json +func ExampleAssignmentReportsVMSSClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAssignmentReportsVMSSClient().NewListPager("myResourceGroupName", "myVMSSName", "AuditSecureProtocol", 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.AssignmentReportList = armguestconfiguration.AssignmentReportList{ + // Value: []*armguestconfiguration.AssignmentReport{ + // { + // Name: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachineScaleSets/myVMSSName/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // Properties: &armguestconfiguration.AssignmentReportProperties{ + // Assignment: &armguestconfiguration.AssignmentInfo{ + // Name: to.Ptr("AuditSecureProtocol"), + // Configuration: &armguestconfiguration.ConfigurationInfo{ + // Name: to.Ptr("AuditSecureProtocol"), + // }, + // }, + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13Z"); return t}()), + // ReportID: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:13:53Z"); return t}()), + // VM: &armguestconfiguration.VMInfo{ + // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachineScaleSets/myVMSSName/virtualMachines/1"), + // UUID: to.Ptr("vmuuid"), + // }, + // }, + // }, + // { + // Name: to.Ptr("41ee2caf-48f9-4999-a793-82ec7c6beb2c"), + // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachineScaleSets/myVMSSName/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/41ee2caf-48f9-4999-a793-82ec7c6beb2c"), + // Properties: &armguestconfiguration.AssignmentReportProperties{ + // Assignment: &armguestconfiguration.AssignmentInfo{ + // Name: to.Ptr("AuditSecureProtocol"), + // Configuration: &armguestconfiguration.ConfigurationInfo{ + // Name: to.Ptr("AuditSecureProtocol"), + // }, + // }, + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T20:14:13Z"); return t}()), + // ReportID: to.Ptr("41ee2caf-48f9-4999-a793-82ec7c6beb2c"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T20:13:53Z"); return t}()), + // VM: &armguestconfiguration.VMInfo{ + // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachineScaleSets/myVMSSName/virtualMachines/1"), + // UUID: to.Ptr("vmuuid"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/getVMSSGuestConfigurationAssignmentReportById.json +func ExampleAssignmentReportsVMSSClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAssignmentReportsVMSSClient().Get(ctx, "myResourceGroupName", "myvmss", "AuditSecureProtocol", "7367cbb8-ae99-47d0-a33b-a283564d2cb1", 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.AssignmentReport = armguestconfiguration.AssignmentReport{ + // Name: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachineScaleSets/myvmss/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // Properties: &armguestconfiguration.AssignmentReportProperties{ + // Assignment: &armguestconfiguration.AssignmentInfo{ + // Name: to.Ptr("AuditSecureProtocol"), + // Configuration: &armguestconfiguration.ConfigurationInfo{ + // Name: to.Ptr("AuditSecureProtocol"), + // Version: to.Ptr("1.0.0.0"), + // }, + // }, + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13Z"); return t}()), + // ReportID: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:13:53Z"); return t}()), + // VM: &armguestconfiguration.VMInfo{ + // ID: to.Ptr("/subscriptions/mySubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachineScaleSets/myvmss/virtualMachines/1"), + // UUID: to.Ptr("vmuuid"), + // }, + // Details: &armguestconfiguration.AssignmentReportDetails{ + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13Z"); return t}()), + // JobID: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // OperationType: to.Ptr(armguestconfiguration.TypeConsistency), + // Resources: []*armguestconfiguration.AssignmentReportResource{ + // { + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), + // Properties: map[string]any{ + // "ConfigurationName": "IsWebServerSecure", + // "DependsOn": nil, + // "IsSingleInstance": "Yes", + // "ModuleName": "SecureProtocolWebServer", + // "ModuleVersion": "1.0.0.3", + // "Protocols":[]any{ + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "SSL 2.0", + // }, + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "SSL 3.0", + // }, + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "TLS 1.0", + // }, + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "PCT 1.0", + // }, + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "Multi-Protocol Unified Hello", + // }, + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "TLS 1.1", + // }, + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "TLS 1.2", + // }, + // }, + // "PsDscRunAsCredential": nil, + // "Reasons": nil, + // "ResourceId": "[SecureWebServer]s1", + // "SourceInfo": nil, + // }, + // Reasons: []*armguestconfiguration.AssignmentReportResourceComplianceReason{ + // { + // Code: to.Ptr("DSC::RESOURCE::SUCCESS"), + // Phrase: to.Ptr("Operation successful."), + // }}, + // }}, + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:13:53Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_assignments_client.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignments_client.go similarity index 85% rename from sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_assignments_client.go rename to sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignments_client.go index 46042c0addf6..57db90a0032a 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_assignments_client.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignments_client.go @@ -5,6 +5,7 @@ // 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 armguestconfiguration @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,51 +24,43 @@ import ( // AssignmentsClient contains the methods for the GuestConfigurationAssignments group. // Don't use this type directly, use NewAssignmentsClient() instead. type AssignmentsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAssignmentsClient creates a new instance of AssignmentsClient with the specified values. -// subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of -// the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of +// the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AssignmentsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AssignmentsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AssignmentsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Creates an association between a VM and guest configuration // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// guestConfigurationAssignmentName - Name of the guest configuration assignment. -// resourceGroupName - The resource group name. -// vmName - The name of the virtual machine. -// parameters - Parameters supplied to the create or update guest configuration assignment. -// options - AssignmentsClientCreateOrUpdateOptions contains the optional parameters for the AssignmentsClient.CreateOrUpdate -// method. +// - guestConfigurationAssignmentName - Name of the guest configuration assignment. +// - resourceGroupName - The resource group name. +// - vmName - The name of the virtual machine. +// - parameters - Parameters supplied to the create or update guest configuration assignment. +// - options - AssignmentsClientCreateOrUpdateOptions contains the optional parameters for the AssignmentsClient.CreateOrUpdate +// method. func (client *AssignmentsClient) CreateOrUpdate(ctx context.Context, guestConfigurationAssignmentName string, resourceGroupName string, vmName string, parameters Assignment, options *AssignmentsClientCreateOrUpdateOptions) (AssignmentsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, guestConfigurationAssignmentName, resourceGroupName, vmName, parameters, options) if err != nil { return AssignmentsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentsClientCreateOrUpdateResponse{}, err } @@ -98,7 +89,7 @@ func (client *AssignmentsClient) createOrUpdateCreateRequest(ctx context.Context return nil, errors.New("parameter vmName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vmName}", url.PathEscape(vmName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -120,17 +111,18 @@ func (client *AssignmentsClient) createOrUpdateHandleResponse(resp *http.Respons // Delete - Delete a guest configuration assignment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// resourceGroupName - The resource group name. -// guestConfigurationAssignmentName - Name of the guest configuration assignment -// vmName - The name of the virtual machine. -// options - AssignmentsClientDeleteOptions contains the optional parameters for the AssignmentsClient.Delete method. +// - resourceGroupName - The resource group name. +// - guestConfigurationAssignmentName - Name of the guest configuration assignment +// - vmName - The name of the virtual machine. +// - options - AssignmentsClientDeleteOptions contains the optional parameters for the AssignmentsClient.Delete method. func (client *AssignmentsClient) Delete(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, vmName string, options *AssignmentsClientDeleteOptions) (AssignmentsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, guestConfigurationAssignmentName, vmName, options) if err != nil { return AssignmentsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentsClientDeleteResponse{}, err } @@ -159,7 +151,7 @@ func (client *AssignmentsClient) deleteCreateRequest(ctx context.Context, resour return nil, errors.New("parameter vmName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vmName}", url.PathEscape(vmName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -172,17 +164,18 @@ func (client *AssignmentsClient) deleteCreateRequest(ctx context.Context, resour // Get - Get information about a guest configuration assignment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// resourceGroupName - The resource group name. -// guestConfigurationAssignmentName - The guest configuration assignment name. -// vmName - The name of the virtual machine. -// options - AssignmentsClientGetOptions contains the optional parameters for the AssignmentsClient.Get method. +// - resourceGroupName - The resource group name. +// - guestConfigurationAssignmentName - The guest configuration assignment name. +// - vmName - The name of the virtual machine. +// - options - AssignmentsClientGetOptions contains the optional parameters for the AssignmentsClient.Get method. func (client *AssignmentsClient) Get(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, vmName string, options *AssignmentsClientGetOptions) (AssignmentsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, guestConfigurationAssignmentName, vmName, options) if err != nil { return AssignmentsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentsClientGetResponse{}, err } @@ -211,7 +204,7 @@ func (client *AssignmentsClient) getCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter vmName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vmName}", url.PathEscape(vmName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -232,11 +225,11 @@ func (client *AssignmentsClient) getHandleResponse(resp *http.Response) (Assignm } // NewListPager - List all guest configuration assignments for a virtual machine. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// resourceGroupName - The resource group name. -// vmName - The name of the virtual machine. -// options - AssignmentsClientListOptions contains the optional parameters for the AssignmentsClient.List method. +// - resourceGroupName - The resource group name. +// - vmName - The name of the virtual machine. +// - options - AssignmentsClientListOptions contains the optional parameters for the AssignmentsClient.NewListPager method. func (client *AssignmentsClient) NewListPager(resourceGroupName string, vmName string, options *AssignmentsClientListOptions) *runtime.Pager[AssignmentsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AssignmentsClientListResponse]{ More: func(page AssignmentsClientListResponse) bool { @@ -247,7 +240,7 @@ func (client *AssignmentsClient) NewListPager(resourceGroupName string, vmName s if err != nil { return AssignmentsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentsClientListResponse{}, err } @@ -274,7 +267,7 @@ func (client *AssignmentsClient) listCreateRequest(ctx context.Context, resource return nil, errors.New("parameter vmName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vmName}", url.PathEscape(vmName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -295,10 +288,10 @@ func (client *AssignmentsClient) listHandleResponse(resp *http.Response) (Assign } // NewRGListPager - List all guest configuration assignments for a resource group. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// resourceGroupName - The resource group name. -// options - AssignmentsClientRGListOptions contains the optional parameters for the AssignmentsClient.RGList method. +// - resourceGroupName - The resource group name. +// - options - AssignmentsClientRGListOptions contains the optional parameters for the AssignmentsClient.NewRGListPager method. func (client *AssignmentsClient) NewRGListPager(resourceGroupName string, options *AssignmentsClientRGListOptions) *runtime.Pager[AssignmentsClientRGListResponse] { return runtime.NewPager(runtime.PagingHandler[AssignmentsClientRGListResponse]{ More: func(page AssignmentsClientRGListResponse) bool { @@ -309,7 +302,7 @@ func (client *AssignmentsClient) NewRGListPager(resourceGroupName string, option if err != nil { return AssignmentsClientRGListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentsClientRGListResponse{}, err } @@ -332,7 +325,7 @@ func (client *AssignmentsClient) rgListCreateRequest(ctx context.Context, resour return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -353,10 +346,10 @@ func (client *AssignmentsClient) rgListHandleResponse(resp *http.Response) (Assi } // NewSubscriptionListPager - List all guest configuration assignments for a subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// options - AssignmentsClientSubscriptionListOptions contains the optional parameters for the AssignmentsClient.SubscriptionList -// method. +// - options - AssignmentsClientSubscriptionListOptions contains the optional parameters for the AssignmentsClient.NewSubscriptionListPager +// method. func (client *AssignmentsClient) NewSubscriptionListPager(options *AssignmentsClientSubscriptionListOptions) *runtime.Pager[AssignmentsClientSubscriptionListResponse] { return runtime.NewPager(runtime.PagingHandler[AssignmentsClientSubscriptionListResponse]{ More: func(page AssignmentsClientSubscriptionListResponse) bool { @@ -367,7 +360,7 @@ func (client *AssignmentsClient) NewSubscriptionListPager(options *AssignmentsCl if err != nil { return AssignmentsClientSubscriptionListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentsClientSubscriptionListResponse{}, err } @@ -386,7 +379,7 @@ func (client *AssignmentsClient) subscriptionListCreateRequest(ctx context.Conte return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignments_client_example_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignments_client_example_test.go new file mode 100644 index 000000000000..b918d7e2cfa5 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignments_client_example_test.go @@ -0,0 +1,215 @@ +//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 armguestconfiguration_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/guestconfiguration/armguestconfiguration" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/createOrUpdateGuestConfigurationAssignment.json +func ExampleAssignmentsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAssignmentsClient().CreateOrUpdate(ctx, "NotInstalledApplicationForWindows", "myResourceGroupName", "myVMName", armguestconfiguration.Assignment{ + Name: to.Ptr("NotInstalledApplicationForWindows"), + Location: to.Ptr("westcentralus"), + Properties: &armguestconfiguration.AssignmentProperties{ + Context: to.Ptr("Azure policy"), + GuestConfiguration: &armguestconfiguration.Navigation{ + Name: to.Ptr("NotInstalledApplicationForWindows"), + AssignmentType: to.Ptr(armguestconfiguration.AssignmentTypeApplyAndAutoCorrect), + ConfigurationParameter: []*armguestconfiguration.ConfigurationParameter{ + { + Name: to.Ptr("[InstalledApplication]NotInstalledApplicationResource1;Name"), + Value: to.Ptr("NotePad,sql"), + }}, + ContentHash: to.Ptr("123contenthash"), + ContentURI: to.Ptr("https://thisisfake/pacakge"), + Version: to.Ptr("1.*"), + }, + }, + }, 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.Assignment = armguestconfiguration.Assignment{ + // Name: to.Ptr("NotInstalledApplicationForWindows"), + // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/myvm/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/NotInstalledApplicationForWindows"), + // Location: to.Ptr("westcentralus"), + // Properties: &armguestconfiguration.AssignmentProperties{ + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusPending), + // Context: to.Ptr("Azure policy"), + // GuestConfiguration: &armguestconfiguration.Navigation{ + // Name: to.Ptr("NotInstalledApplicationForWindows"), + // AssignmentSource: to.Ptr("AzurePolicy"), + // ConfigurationParameter: []*armguestconfiguration.ConfigurationParameter{ + // { + // Name: to.Ptr("[InstalledApplication]NotInstalledApplicationResource1;Name"), + // Value: to.Ptr("NotePad,sql"), + // }}, + // Version: to.Ptr("1.0.0.3"), + // }, + // ProvisioningState: to.Ptr(armguestconfiguration.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/getGuestConfigurationAssignment.json +func ExampleAssignmentsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAssignmentsClient().Get(ctx, "myResourceGroupName", "SecureProtocol", "myVMName", 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.Assignment = armguestconfiguration.Assignment{ + // Name: to.Ptr("AuditSecureProtocol"), + // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/myvm/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol"), + // Location: to.Ptr("centraluseuap"), + // Properties: &armguestconfiguration.AssignmentProperties{ + // AssignmentHash: to.Ptr("E0D8941DD713F284284561648C00C18FA76C8602943C7CD38AFD73B56AE4C35F.E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855"), + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), + // GuestConfiguration: &armguestconfiguration.Navigation{ + // Name: to.Ptr("AuditSecureProtocol"), + // ConfigurationParameter: []*armguestconfiguration.ConfigurationParameter{ + // }, + // ContentHash: to.Ptr("content hash"), + // ContentURI: to.Ptr("https://mystorageaccount.blob.core.windows.net/builtinconfig/AuditSecureProtocol/AuditSecureProtocol_1.0.0.3.zip"), + // Version: to.Ptr("1.0.0.3"), + // }, + // LastComplianceStatusChecked: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13Z"); return t}()), + // LatestReportID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachines/myvm/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // ProvisioningState: to.Ptr(armguestconfiguration.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/deleteGuestConfigurationAssignment.json +func ExampleAssignmentsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewAssignmentsClient().Delete(ctx, "myResourceGroupName", "SecureProtocol", "myVMName", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listSubGuestConfigurationAssignments.json +func ExampleAssignmentsClient_NewSubscriptionListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAssignmentsClient().NewSubscriptionListPager(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.AssignmentList = armguestconfiguration.AssignmentList{ + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listRGGuestConfigurationAssignments.json +func ExampleAssignmentsClient_NewRGListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAssignmentsClient().NewRGListPager("myResourceGroupName", 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.AssignmentList = armguestconfiguration.AssignmentList{ + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listGuestConfigurationAssignments.json +func ExampleAssignmentsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAssignmentsClient().NewListPager("myResourceGroupName", "myVMName", 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.AssignmentList = armguestconfiguration.AssignmentList{ + // } + } +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_assignmentsvmss_client.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentsvmss_client.go similarity index 83% rename from sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_assignmentsvmss_client.go rename to sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentsvmss_client.go index 108c1b190041..492f545485df 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_assignmentsvmss_client.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentsvmss_client.go @@ -5,6 +5,7 @@ // 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 armguestconfiguration @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,49 +24,41 @@ import ( // AssignmentsVMSSClient contains the methods for the GuestConfigurationAssignmentsVMSS group. // Don't use this type directly, use NewAssignmentsVMSSClient() instead. type AssignmentsVMSSClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewAssignmentsVMSSClient creates a new instance of AssignmentsVMSSClient with the specified values. -// subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of -// the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of +// the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewAssignmentsVMSSClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AssignmentsVMSSClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".AssignmentsVMSSClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &AssignmentsVMSSClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Delete - Delete a guest configuration assignment for VMSS // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// resourceGroupName - The resource group name. -// vmssName - The name of the virtual machine scale set. -// name - The guest configuration assignment name. -// options - AssignmentsVMSSClientDeleteOptions contains the optional parameters for the AssignmentsVMSSClient.Delete method. +// - resourceGroupName - The resource group name. +// - vmssName - The name of the virtual machine scale set. +// - name - The guest configuration assignment name. +// - options - AssignmentsVMSSClientDeleteOptions contains the optional parameters for the AssignmentsVMSSClient.Delete method. func (client *AssignmentsVMSSClient) Delete(ctx context.Context, resourceGroupName string, vmssName string, name string, options *AssignmentsVMSSClientDeleteOptions) (AssignmentsVMSSClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, vmssName, name, options) if err != nil { return AssignmentsVMSSClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentsVMSSClientDeleteResponse{}, err } @@ -96,7 +87,7 @@ func (client *AssignmentsVMSSClient) deleteCreateRequest(ctx context.Context, re return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -118,17 +109,18 @@ func (client *AssignmentsVMSSClient) deleteHandleResponse(resp *http.Response) ( // Get - Get information about a guest configuration assignment for VMSS // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// resourceGroupName - The resource group name. -// vmssName - The name of the virtual machine scale set. -// name - The guest configuration assignment name. -// options - AssignmentsVMSSClientGetOptions contains the optional parameters for the AssignmentsVMSSClient.Get method. +// - resourceGroupName - The resource group name. +// - vmssName - The name of the virtual machine scale set. +// - name - The guest configuration assignment name. +// - options - AssignmentsVMSSClientGetOptions contains the optional parameters for the AssignmentsVMSSClient.Get method. func (client *AssignmentsVMSSClient) Get(ctx context.Context, resourceGroupName string, vmssName string, name string, options *AssignmentsVMSSClientGetOptions) (AssignmentsVMSSClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, vmssName, name, options) if err != nil { return AssignmentsVMSSClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentsVMSSClientGetResponse{}, err } @@ -157,7 +149,7 @@ func (client *AssignmentsVMSSClient) getCreateRequest(ctx context.Context, resou return nil, errors.New("parameter name cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{name}", url.PathEscape(name)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -178,11 +170,12 @@ func (client *AssignmentsVMSSClient) getHandleResponse(resp *http.Response) (Ass } // NewListPager - List all guest configuration assignments for VMSS. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// resourceGroupName - The resource group name. -// vmssName - The name of the virtual machine scale set. -// options - AssignmentsVMSSClientListOptions contains the optional parameters for the AssignmentsVMSSClient.List method. +// - resourceGroupName - The resource group name. +// - vmssName - The name of the virtual machine scale set. +// - options - AssignmentsVMSSClientListOptions contains the optional parameters for the AssignmentsVMSSClient.NewListPager +// method. func (client *AssignmentsVMSSClient) NewListPager(resourceGroupName string, vmssName string, options *AssignmentsVMSSClientListOptions) *runtime.Pager[AssignmentsVMSSClientListResponse] { return runtime.NewPager(runtime.PagingHandler[AssignmentsVMSSClientListResponse]{ More: func(page AssignmentsVMSSClientListResponse) bool { @@ -193,7 +186,7 @@ func (client *AssignmentsVMSSClient) NewListPager(resourceGroupName string, vmss if err != nil { return AssignmentsVMSSClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return AssignmentsVMSSClientListResponse{}, err } @@ -220,7 +213,7 @@ func (client *AssignmentsVMSSClient) listCreateRequest(ctx context.Context, reso return nil, errors.New("parameter vmssName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{vmssName}", url.PathEscape(vmssName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentsvmss_client_example_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentsvmss_client_example_test.go new file mode 100644 index 000000000000..9a937f8c3d5b --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/assignmentsvmss_client_example_test.go @@ -0,0 +1,125 @@ +//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 armguestconfiguration_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/getVMSSGuestConfigurationAssignment.json +func ExampleAssignmentsVMSSClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAssignmentsVMSSClient().Get(ctx, "myResourceGroupName", "myVMSSName", "SecureProtocol", 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.Assignment = armguestconfiguration.Assignment{ + // Name: to.Ptr("AuditSecureProtocol"), + // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachineScaleSets/myVMSSName/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol"), + // Location: to.Ptr("centraluseuap"), + // Properties: &armguestconfiguration.AssignmentProperties{ + // AssignmentHash: to.Ptr("E0D8941DD713F284284561648C00C18FA76C8602943C7CD38AFD73B56AE4C35F.E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855"), + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), + // GuestConfiguration: &armguestconfiguration.Navigation{ + // Name: to.Ptr("AuditSecureProtocol"), + // ConfigurationParameter: []*armguestconfiguration.ConfigurationParameter{ + // }, + // ContentHash: to.Ptr("content hash"), + // ContentURI: to.Ptr("https://mystorageaccount.blob.core.windows.net/builtinconfig/AuditSecureProtocol/AuditSecureProtocol_1.0.0.3.zip"), + // Version: to.Ptr("1.0.0.3"), + // }, + // LastComplianceStatusChecked: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13Z"); return t}()), + // ProvisioningState: to.Ptr(armguestconfiguration.ProvisioningStateSucceeded), + // ResourceType: to.Ptr("VMSS"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/deleteGuestConfigurationVMSSAssignment.json +func ExampleAssignmentsVMSSClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAssignmentsVMSSClient().Delete(ctx, "myResourceGroupName", "myVMSSName", "SecureProtocol", 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.Assignment = armguestconfiguration.Assignment{ + // Name: to.Ptr("AuditSecureProtocol"), + // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.Compute/virtualMachineScaleSets/myVMSSName/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol"), + // Location: to.Ptr("centraluseuap"), + // Properties: &armguestconfiguration.AssignmentProperties{ + // AssignmentHash: to.Ptr("E0D8941DD713F284284561648C00C18FA76C8602943C7CD38AFD73B56AE4C35F.E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855"), + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), + // GuestConfiguration: &armguestconfiguration.Navigation{ + // Name: to.Ptr("AuditSecureProtocol"), + // ConfigurationParameter: []*armguestconfiguration.ConfigurationParameter{ + // }, + // ContentHash: to.Ptr("content hash"), + // ContentURI: to.Ptr("https://mystorageaccount.blob.core.windows.net/builtinconfig/AuditSecureProtocol/AuditSecureProtocol_1.0.0.3.zip"), + // Version: to.Ptr("1.0.0.3"), + // }, + // LastComplianceStatusChecked: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13Z"); return t}()), + // ProvisioningState: to.Ptr(armguestconfiguration.ProvisioningStateSucceeded), + // ResourceType: to.Ptr("VMSS"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listVMSSGuestConfigurationAssignments.json +func ExampleAssignmentsVMSSClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAssignmentsVMSSClient().NewListPager("myResourceGroupName", "myVMSSName", 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.AssignmentList = armguestconfiguration.AssignmentList{ + // } + } +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/autorest.md b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/autorest.md index 058f994cf6dc..ca3fd950e435 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/autorest.md +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 1.1.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/client_factory.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/client_factory.go new file mode 100644 index 000000000000..45b058cab883 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/client_factory.go @@ -0,0 +1,75 @@ +//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 armguestconfiguration + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of +// the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewAssignmentsClient() *AssignmentsClient { + subClient, _ := NewAssignmentsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAssignmentReportsClient() *AssignmentReportsClient { + subClient, _ := NewAssignmentReportsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewHCRPAssignmentsClient() *HCRPAssignmentsClient { + subClient, _ := NewHCRPAssignmentsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewHCRPAssignmentReportsClient() *HCRPAssignmentReportsClient { + subClient, _ := NewHCRPAssignmentReportsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAssignmentsVMSSClient() *AssignmentsVMSSClient { + subClient, _ := NewAssignmentsVMSSClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewAssignmentReportsVMSSClient() *AssignmentReportsVMSSClient { + subClient, _ := NewAssignmentReportsVMSSClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_constants.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/constants.go similarity index 99% rename from sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_constants.go rename to sdk/resourcemanager/guestconfiguration/armguestconfiguration/constants.go index b331a2497500..d370beb433d6 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_constants.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/constants.go @@ -5,12 +5,13 @@ // 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 armguestconfiguration const ( moduleName = "armguestconfiguration" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // ActionAfterReboot - Specifies what happens after a reboot during the application of a configuration. The possible values diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.mod b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.mod index fb7574c3f37f..078a43510798 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.mod +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/ go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.sum b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.sum +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_hcrpassignmentreports_client.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignmentreports_client.go similarity index 81% rename from sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_hcrpassignmentreports_client.go rename to sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignmentreports_client.go index 60e09c5a964d..ad0e986af3c2 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_hcrpassignmentreports_client.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignmentreports_client.go @@ -5,6 +5,7 @@ // 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 armguestconfiguration @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,51 +24,43 @@ import ( // HCRPAssignmentReportsClient contains the methods for the GuestConfigurationHCRPAssignmentReports group. // Don't use this type directly, use NewHCRPAssignmentReportsClient() instead. type HCRPAssignmentReportsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewHCRPAssignmentReportsClient creates a new instance of HCRPAssignmentReportsClient with the specified values. -// subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of -// the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of +// the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewHCRPAssignmentReportsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*HCRPAssignmentReportsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".HCRPAssignmentReportsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &HCRPAssignmentReportsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // Get - Get a report for the guest configuration assignment, by reportId. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// resourceGroupName - The resource group name. -// guestConfigurationAssignmentName - The guest configuration assignment name. -// reportID - The GUID for the guest configuration assignment report. -// machineName - The name of the ARC machine. -// options - HCRPAssignmentReportsClientGetOptions contains the optional parameters for the HCRPAssignmentReportsClient.Get -// method. +// - resourceGroupName - The resource group name. +// - guestConfigurationAssignmentName - The guest configuration assignment name. +// - reportID - The GUID for the guest configuration assignment report. +// - machineName - The name of the ARC machine. +// - options - HCRPAssignmentReportsClientGetOptions contains the optional parameters for the HCRPAssignmentReportsClient.Get +// method. func (client *HCRPAssignmentReportsClient) Get(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, reportID string, machineName string, options *HCRPAssignmentReportsClientGetOptions) (HCRPAssignmentReportsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, guestConfigurationAssignmentName, reportID, machineName, options) if err != nil { return HCRPAssignmentReportsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HCRPAssignmentReportsClientGetResponse{}, err } @@ -102,7 +93,7 @@ func (client *HCRPAssignmentReportsClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter machineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{machineName}", url.PathEscape(machineName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -124,18 +115,19 @@ func (client *HCRPAssignmentReportsClient) getHandleResponse(resp *http.Response // List - List all reports for the guest configuration assignment, latest report first. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// resourceGroupName - The resource group name. -// guestConfigurationAssignmentName - The guest configuration assignment name. -// machineName - The name of the ARC machine. -// options - HCRPAssignmentReportsClientListOptions contains the optional parameters for the HCRPAssignmentReportsClient.List -// method. +// - resourceGroupName - The resource group name. +// - guestConfigurationAssignmentName - The guest configuration assignment name. +// - machineName - The name of the ARC machine. +// - options - HCRPAssignmentReportsClientListOptions contains the optional parameters for the HCRPAssignmentReportsClient.List +// method. func (client *HCRPAssignmentReportsClient) List(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, machineName string, options *HCRPAssignmentReportsClientListOptions) (HCRPAssignmentReportsClientListResponse, error) { req, err := client.listCreateRequest(ctx, resourceGroupName, guestConfigurationAssignmentName, machineName, options) if err != nil { return HCRPAssignmentReportsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HCRPAssignmentReportsClientListResponse{}, err } @@ -164,7 +156,7 @@ func (client *HCRPAssignmentReportsClient) listCreateRequest(ctx context.Context return nil, errors.New("parameter machineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{machineName}", url.PathEscape(machineName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignmentreports_client_example_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignmentreports_client_example_test.go new file mode 100644 index 000000000000..45c5967dabaf --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignmentreports_client_example_test.go @@ -0,0 +1,179 @@ +//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 armguestconfiguration_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listAllGuestConfigurationHCRPAssignmentReports.json +func ExampleHCRPAssignmentReportsClient_List() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewHCRPAssignmentReportsClient().List(ctx, "myResourceGroupName", "AuditSecureProtocol", "myMachineName", 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.AssignmentReportList = armguestconfiguration.AssignmentReportList{ + // Value: []*armguestconfiguration.AssignmentReport{ + // { + // Name: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.HybridCompute/machines/myMachineName/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // Properties: &armguestconfiguration.AssignmentReportProperties{ + // Assignment: &armguestconfiguration.AssignmentInfo{ + // Name: to.Ptr("AuditSecureProtocol"), + // Configuration: &armguestconfiguration.ConfigurationInfo{ + // Name: to.Ptr("AuditSecureProtocol"), + // }, + // }, + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13Z"); return t}()), + // ReportID: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:13:53Z"); return t}()), + // VM: &armguestconfiguration.VMInfo{ + // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.HybridCompute/machines/myMachineName"), + // UUID: to.Ptr("vmuuid"), + // }, + // }, + // }, + // { + // Name: to.Ptr("41ee2caf-48f9-4999-a793-82ec7c6beb2c"), + // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.HybridCompute/machines/myMachineName/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/41ee2caf-48f9-4999-a793-82ec7c6beb2c"), + // Properties: &armguestconfiguration.AssignmentReportProperties{ + // Assignment: &armguestconfiguration.AssignmentInfo{ + // Name: to.Ptr("AuditSecureProtocol"), + // Configuration: &armguestconfiguration.ConfigurationInfo{ + // Name: to.Ptr("AuditSecureProtocol"), + // }, + // }, + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T20:14:13Z"); return t}()), + // ReportID: to.Ptr("41ee2caf-48f9-4999-a793-82ec7c6beb2c"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T20:13:53Z"); return t}()), + // VM: &armguestconfiguration.VMInfo{ + // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.HybridCompute/machines/myMachineName"), + // UUID: to.Ptr("vmuuid"), + // }, + // }, + // }}, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/getGuestConfigurationHCRPAssignmentReportById.json +func ExampleHCRPAssignmentReportsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewHCRPAssignmentReportsClient().Get(ctx, "myResourceGroupName", "AuditSecureProtocol", "7367cbb8-ae99-47d0-a33b-a283564d2cb1", "myMachineName", 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.AssignmentReport = armguestconfiguration.AssignmentReport{ + // Name: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.HybridCompute/machines/myMachineName/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // Properties: &armguestconfiguration.AssignmentReportProperties{ + // Assignment: &armguestconfiguration.AssignmentInfo{ + // Name: to.Ptr("AuditSecureProtocol"), + // Configuration: &armguestconfiguration.ConfigurationInfo{ + // Name: to.Ptr("AuditSecureProtocol"), + // Version: to.Ptr("1.0.0.0"), + // }, + // }, + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13Z"); return t}()), + // ReportID: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:13:53Z"); return t}()), + // VM: &armguestconfiguration.VMInfo{ + // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/Microsoft.HybridCompute/machines/myMachineName"), + // UUID: to.Ptr("vmuuid"), + // }, + // Details: &armguestconfiguration.AssignmentReportDetails{ + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13Z"); return t}()), + // JobID: to.Ptr("7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // OperationType: to.Ptr(armguestconfiguration.TypeConsistency), + // Resources: []*armguestconfiguration.AssignmentReportResource{ + // { + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), + // Properties: map[string]any{ + // "ConfigurationName": "IsWebServerSecure", + // "DependsOn": nil, + // "IsSingleInstance": "Yes", + // "ModuleName": "SecureProtocolWebServer", + // "ModuleVersion": "1.0.0.3", + // "Protocols":[]any{ + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "SSL 2.0", + // }, + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "SSL 3.0", + // }, + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "TLS 1.0", + // }, + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "PCT 1.0", + // }, + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "Multi-Protocol Unified Hello", + // }, + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "TLS 1.1", + // }, + // map[string]any{ + // "Ensure": "Absent", + // "Protocol": "TLS 1.2", + // }, + // }, + // "PsDscRunAsCredential": nil, + // "Reasons": nil, + // "ResourceId": "[SecureWebServer]s1", + // "SourceInfo": nil, + // }, + // Reasons: []*armguestconfiguration.AssignmentReportResourceComplianceReason{ + // { + // Code: to.Ptr("DSC::RESOURCE::SUCCESS"), + // Phrase: to.Ptr("Operation successful."), + // }}, + // }}, + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:13:53Z"); return t}()), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_hcrpassignments_client.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignments_client.go similarity index 84% rename from sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_hcrpassignments_client.go rename to sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignments_client.go index f39f4e853b90..d6ce7d6b71d6 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_hcrpassignments_client.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignments_client.go @@ -5,6 +5,7 @@ // 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 armguestconfiguration @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,51 +24,43 @@ import ( // HCRPAssignmentsClient contains the methods for the GuestConfigurationHCRPAssignments group. // Don't use this type directly, use NewHCRPAssignmentsClient() instead. type HCRPAssignmentsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewHCRPAssignmentsClient creates a new instance of HCRPAssignmentsClient with the specified values. -// subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of -// the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of +// the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewHCRPAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*HCRPAssignmentsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".HCRPAssignmentsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &HCRPAssignmentsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // CreateOrUpdate - Creates an association between a ARC machine and guest configuration // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// guestConfigurationAssignmentName - Name of the guest configuration assignment. -// resourceGroupName - The resource group name. -// machineName - The name of the ARC machine. -// parameters - Parameters supplied to the create or update guest configuration assignment. -// options - HCRPAssignmentsClientCreateOrUpdateOptions contains the optional parameters for the HCRPAssignmentsClient.CreateOrUpdate -// method. +// - guestConfigurationAssignmentName - Name of the guest configuration assignment. +// - resourceGroupName - The resource group name. +// - machineName - The name of the ARC machine. +// - parameters - Parameters supplied to the create or update guest configuration assignment. +// - options - HCRPAssignmentsClientCreateOrUpdateOptions contains the optional parameters for the HCRPAssignmentsClient.CreateOrUpdate +// method. func (client *HCRPAssignmentsClient) CreateOrUpdate(ctx context.Context, guestConfigurationAssignmentName string, resourceGroupName string, machineName string, parameters Assignment, options *HCRPAssignmentsClientCreateOrUpdateOptions) (HCRPAssignmentsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, guestConfigurationAssignmentName, resourceGroupName, machineName, parameters, options) if err != nil { return HCRPAssignmentsClientCreateOrUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HCRPAssignmentsClientCreateOrUpdateResponse{}, err } @@ -98,7 +89,7 @@ func (client *HCRPAssignmentsClient) createOrUpdateCreateRequest(ctx context.Con return nil, errors.New("parameter machineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{machineName}", url.PathEscape(machineName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -120,17 +111,18 @@ func (client *HCRPAssignmentsClient) createOrUpdateHandleResponse(resp *http.Res // Delete - Delete a guest configuration assignment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// resourceGroupName - The resource group name. -// guestConfigurationAssignmentName - Name of the guest configuration assignment -// machineName - The name of the ARC machine. -// options - HCRPAssignmentsClientDeleteOptions contains the optional parameters for the HCRPAssignmentsClient.Delete method. +// - resourceGroupName - The resource group name. +// - guestConfigurationAssignmentName - Name of the guest configuration assignment +// - machineName - The name of the ARC machine. +// - options - HCRPAssignmentsClientDeleteOptions contains the optional parameters for the HCRPAssignmentsClient.Delete method. func (client *HCRPAssignmentsClient) Delete(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, machineName string, options *HCRPAssignmentsClientDeleteOptions) (HCRPAssignmentsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, guestConfigurationAssignmentName, machineName, options) if err != nil { return HCRPAssignmentsClientDeleteResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HCRPAssignmentsClientDeleteResponse{}, err } @@ -159,7 +151,7 @@ func (client *HCRPAssignmentsClient) deleteCreateRequest(ctx context.Context, re return nil, errors.New("parameter machineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{machineName}", url.PathEscape(machineName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -172,17 +164,18 @@ func (client *HCRPAssignmentsClient) deleteCreateRequest(ctx context.Context, re // Get - Get information about a guest configuration assignment // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// resourceGroupName - The resource group name. -// guestConfigurationAssignmentName - The guest configuration assignment name. -// machineName - The name of the ARC machine. -// options - HCRPAssignmentsClientGetOptions contains the optional parameters for the HCRPAssignmentsClient.Get method. +// - resourceGroupName - The resource group name. +// - guestConfigurationAssignmentName - The guest configuration assignment name. +// - machineName - The name of the ARC machine. +// - options - HCRPAssignmentsClientGetOptions contains the optional parameters for the HCRPAssignmentsClient.Get method. func (client *HCRPAssignmentsClient) Get(ctx context.Context, resourceGroupName string, guestConfigurationAssignmentName string, machineName string, options *HCRPAssignmentsClientGetOptions) (HCRPAssignmentsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, guestConfigurationAssignmentName, machineName, options) if err != nil { return HCRPAssignmentsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HCRPAssignmentsClientGetResponse{}, err } @@ -211,7 +204,7 @@ func (client *HCRPAssignmentsClient) getCreateRequest(ctx context.Context, resou return nil, errors.New("parameter machineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{machineName}", url.PathEscape(machineName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -232,11 +225,12 @@ func (client *HCRPAssignmentsClient) getHandleResponse(resp *http.Response) (HCR } // NewListPager - List all guest configuration assignments for an ARC machine. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// resourceGroupName - The resource group name. -// machineName - The name of the ARC machine. -// options - HCRPAssignmentsClientListOptions contains the optional parameters for the HCRPAssignmentsClient.List method. +// - resourceGroupName - The resource group name. +// - machineName - The name of the ARC machine. +// - options - HCRPAssignmentsClientListOptions contains the optional parameters for the HCRPAssignmentsClient.NewListPager +// method. func (client *HCRPAssignmentsClient) NewListPager(resourceGroupName string, machineName string, options *HCRPAssignmentsClientListOptions) *runtime.Pager[HCRPAssignmentsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[HCRPAssignmentsClientListResponse]{ More: func(page HCRPAssignmentsClientListResponse) bool { @@ -247,7 +241,7 @@ func (client *HCRPAssignmentsClient) NewListPager(resourceGroupName string, mach if err != nil { return HCRPAssignmentsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return HCRPAssignmentsClientListResponse{}, err } @@ -274,7 +268,7 @@ func (client *HCRPAssignmentsClient) listCreateRequest(ctx context.Context, reso return nil, errors.New("parameter machineName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{machineName}", url.PathEscape(machineName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignments_client_example_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignments_client_example_test.go new file mode 100644 index 000000000000..7f77a4f26f97 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/hcrpassignments_client_example_test.go @@ -0,0 +1,162 @@ +//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 armguestconfiguration_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/guestconfiguration/armguestconfiguration" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/createOrUpdateGuestConfigurationHCRPAssignment.json +func ExampleHCRPAssignmentsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewHCRPAssignmentsClient().CreateOrUpdate(ctx, "NotInstalledApplicationForWindows", "myResourceGroupName", "myMachineName", armguestconfiguration.Assignment{ + Name: to.Ptr("NotInstalledApplicationForWindows"), + Location: to.Ptr("westcentralus"), + Properties: &armguestconfiguration.AssignmentProperties{ + Context: to.Ptr("Azure policy"), + GuestConfiguration: &armguestconfiguration.Navigation{ + Name: to.Ptr("NotInstalledApplicationForWindows"), + AssignmentType: to.Ptr(armguestconfiguration.AssignmentTypeApplyAndAutoCorrect), + ConfigurationParameter: []*armguestconfiguration.ConfigurationParameter{ + { + Name: to.Ptr("[InstalledApplication]NotInstalledApplicationResource1;Name"), + Value: to.Ptr("NotePad,sql"), + }}, + ContentHash: to.Ptr("123contenthash"), + ContentURI: to.Ptr("https://thisisfake/pacakge"), + Version: to.Ptr("1.*"), + }, + }, + }, 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.Assignment = armguestconfiguration.Assignment{ + // Name: to.Ptr("NotInstalledApplicationForWindows"), + // ID: to.Ptr("/subscriptions/mysubscriptionid/resourceGroups/myResourceGroupName/providers/HybridRP.Compute/virtualMachines/myvm/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/NotInstalledApplicationForWindows"), + // Location: to.Ptr("westcentralus"), + // Properties: &armguestconfiguration.AssignmentProperties{ + // AssignmentHash: to.Ptr("abcdr453g"), + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusPending), + // Context: to.Ptr("Azure policy"), + // GuestConfiguration: &armguestconfiguration.Navigation{ + // Name: to.Ptr("NotInstalledApplicationForWindows"), + // ConfigurationParameter: []*armguestconfiguration.ConfigurationParameter{ + // { + // Name: to.Ptr("[InstalledApplication]NotInstalledApplicationResource1;Name"), + // Value: to.Ptr("NotePad,sql"), + // }}, + // Version: to.Ptr("1.0.0.3"), + // }, + // LatestReportID: to.Ptr("a2a64e5d-a1a9-4344-a866-fb9e1541f723"), + // ProvisioningState: to.Ptr(armguestconfiguration.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/getGuestConfigurationHCRPAssignment.json +func ExampleHCRPAssignmentsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewHCRPAssignmentsClient().Get(ctx, "myResourceGroupName", "SecureProtocol", "myMachineName", 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.Assignment = armguestconfiguration.Assignment{ + // Name: to.Ptr("AuditSecureProtocol"), + // ID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.HybridCompute/machines/myMachineName/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol"), + // Location: to.Ptr("centraluseuap"), + // Properties: &armguestconfiguration.AssignmentProperties{ + // AssignmentHash: to.Ptr("E0D8941DD713F284284561648C00C18FA76C8602943C7CD38AFD73B56AE4C35F.E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855"), + // ComplianceStatus: to.Ptr(armguestconfiguration.ComplianceStatusCompliant), + // GuestConfiguration: &armguestconfiguration.Navigation{ + // Name: to.Ptr("AuditSecureProtocol"), + // ConfigurationParameter: []*armguestconfiguration.ConfigurationParameter{ + // }, + // ContentHash: to.Ptr("content hash"), + // ContentURI: to.Ptr("https://mystorageaccount.blob.core.windows.net/builtinconfig/AuditSecureProtocol/AuditSecureProtocol_1.0.0.3.zip"), + // Version: to.Ptr("1.0.0.3"), + // }, + // LastComplianceStatusChecked: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T22:14:13Z"); return t}()), + // LatestReportID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.HybridCompute/machines/myMachineName/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/AuditSecureProtocol/reports/7367cbb8-ae99-47d0-a33b-a283564d2cb1"), + // ProvisioningState: to.Ptr(armguestconfiguration.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/deleteGuestConfigurationHCRPAssignment.json +func ExampleHCRPAssignmentsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewHCRPAssignmentsClient().Delete(ctx, "myResourceGroupName", "SecureProtocol", "myMachineName", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listGuestConfigurationHCRPAssignments.json +func ExampleHCRPAssignmentsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armguestconfiguration.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewHCRPAssignmentsClient().NewListPager("myResourceGroupName", "myMachineName", 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.AssignmentList = armguestconfiguration.AssignmentList{ + // } + } +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_models.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/models.go similarity index 97% rename from sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_models.go rename to sdk/resourcemanager/guestconfiguration/armguestconfiguration/models.go index 105482fed828..0e85f0eb25be 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_models.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/models.go @@ -5,6 +5,7 @@ // 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 armguestconfiguration @@ -162,7 +163,7 @@ type AssignmentReportResource struct { ComplianceStatus *ComplianceStatus `json:"complianceStatus,omitempty" azure:"ro"` // READ-ONLY; Properties of a guest configuration assignment resource. - Properties interface{} `json:"properties,omitempty" azure:"ro"` + Properties any `json:"properties,omitempty" azure:"ro"` // READ-ONLY; Name of the guest configuration assignment resource setting. ResourceID *string `json:"resourceId,omitempty" azure:"ro"` @@ -192,7 +193,8 @@ type AssignmentReportsVMSSClientGetOptions struct { // placeholder for future optional parameters } -// AssignmentReportsVMSSClientListOptions contains the optional parameters for the AssignmentReportsVMSSClient.List method. +// AssignmentReportsVMSSClientListOptions contains the optional parameters for the AssignmentReportsVMSSClient.NewListPager +// method. type AssignmentReportsVMSSClientListOptions struct { // placeholder for future optional parameters } @@ -212,17 +214,18 @@ type AssignmentsClientGetOptions struct { // placeholder for future optional parameters } -// AssignmentsClientListOptions contains the optional parameters for the AssignmentsClient.List method. +// AssignmentsClientListOptions contains the optional parameters for the AssignmentsClient.NewListPager method. type AssignmentsClientListOptions struct { // placeholder for future optional parameters } -// AssignmentsClientRGListOptions contains the optional parameters for the AssignmentsClient.RGList method. +// AssignmentsClientRGListOptions contains the optional parameters for the AssignmentsClient.NewRGListPager method. type AssignmentsClientRGListOptions struct { // placeholder for future optional parameters } -// AssignmentsClientSubscriptionListOptions contains the optional parameters for the AssignmentsClient.SubscriptionList method. +// AssignmentsClientSubscriptionListOptions contains the optional parameters for the AssignmentsClient.NewSubscriptionListPager +// method. type AssignmentsClientSubscriptionListOptions struct { // placeholder for future optional parameters } @@ -237,7 +240,7 @@ type AssignmentsVMSSClientGetOptions struct { // placeholder for future optional parameters } -// AssignmentsVMSSClientListOptions contains the optional parameters for the AssignmentsVMSSClient.List method. +// AssignmentsVMSSClientListOptions contains the optional parameters for the AssignmentsVMSSClient.NewListPager method. type AssignmentsVMSSClientListOptions struct { // placeholder for future optional parameters } @@ -357,7 +360,7 @@ type HCRPAssignmentsClientGetOptions struct { // placeholder for future optional parameters } -// HCRPAssignmentsClientListOptions contains the optional parameters for the HCRPAssignmentsClient.List method. +// HCRPAssignmentsClientListOptions contains the optional parameters for the HCRPAssignmentsClient.NewListPager method. type HCRPAssignmentsClientListOptions struct { // placeholder for future optional parameters } @@ -440,7 +443,7 @@ type OperationProperties struct { StatusCode *string `json:"statusCode,omitempty"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/models_serde.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/models_serde.go new file mode 100644 index 000000000000..55b15120efb3 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/models_serde.go @@ -0,0 +1,1067 @@ +//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 armguestconfiguration + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Assignment. +func (a Assignment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "location", a.Location) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Assignment. +func (a *Assignment) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &a.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AssignmentInfo. +func (a AssignmentInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "configuration", a.Configuration) + populate(objectMap, "name", a.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentInfo. +func (a *AssignmentInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "configuration": + err = unpopulate(val, "Configuration", &a.Configuration) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AssignmentList. +func (a AssignmentList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentList. +func (a *AssignmentList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AssignmentProperties. +func (a AssignmentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "assignmentHash", a.AssignmentHash) + populate(objectMap, "complianceStatus", a.ComplianceStatus) + populate(objectMap, "context", a.Context) + populate(objectMap, "guestConfiguration", a.GuestConfiguration) + populateTimeRFC3339(objectMap, "lastComplianceStatusChecked", a.LastComplianceStatusChecked) + populate(objectMap, "latestAssignmentReport", a.LatestAssignmentReport) + populate(objectMap, "latestReportId", a.LatestReportID) + populate(objectMap, "parameterHash", a.ParameterHash) + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "resourceType", a.ResourceType) + populate(objectMap, "targetResourceId", a.TargetResourceID) + populate(objectMap, "vmssVMList", a.VmssVMList) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentProperties. +func (a *AssignmentProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "assignmentHash": + err = unpopulate(val, "AssignmentHash", &a.AssignmentHash) + delete(rawMsg, key) + case "complianceStatus": + err = unpopulate(val, "ComplianceStatus", &a.ComplianceStatus) + delete(rawMsg, key) + case "context": + err = unpopulate(val, "Context", &a.Context) + delete(rawMsg, key) + case "guestConfiguration": + err = unpopulate(val, "GuestConfiguration", &a.GuestConfiguration) + delete(rawMsg, key) + case "lastComplianceStatusChecked": + err = unpopulateTimeRFC3339(val, "LastComplianceStatusChecked", &a.LastComplianceStatusChecked) + delete(rawMsg, key) + case "latestAssignmentReport": + err = unpopulate(val, "LatestAssignmentReport", &a.LatestAssignmentReport) + delete(rawMsg, key) + case "latestReportId": + err = unpopulate(val, "LatestReportID", &a.LatestReportID) + delete(rawMsg, key) + case "parameterHash": + err = unpopulate(val, "ParameterHash", &a.ParameterHash) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &a.ResourceType) + delete(rawMsg, key) + case "targetResourceId": + err = unpopulate(val, "TargetResourceID", &a.TargetResourceID) + delete(rawMsg, key) + case "vmssVMList": + err = unpopulate(val, "VmssVMList", &a.VmssVMList) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AssignmentReport. +func (a AssignmentReport) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentReport. +func (a *AssignmentReport) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AssignmentReportDetails. +func (a AssignmentReportDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "complianceStatus", a.ComplianceStatus) + populateTimeRFC3339(objectMap, "endTime", a.EndTime) + populate(objectMap, "jobId", a.JobID) + populate(objectMap, "operationType", a.OperationType) + populate(objectMap, "resources", a.Resources) + populateTimeRFC3339(objectMap, "startTime", a.StartTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentReportDetails. +func (a *AssignmentReportDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "complianceStatus": + err = unpopulate(val, "ComplianceStatus", &a.ComplianceStatus) + delete(rawMsg, key) + case "endTime": + err = unpopulateTimeRFC3339(val, "EndTime", &a.EndTime) + delete(rawMsg, key) + case "jobId": + err = unpopulate(val, "JobID", &a.JobID) + delete(rawMsg, key) + case "operationType": + err = unpopulate(val, "OperationType", &a.OperationType) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &a.Resources) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &a.StartTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AssignmentReportList. +func (a AssignmentReportList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentReportList. +func (a *AssignmentReportList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AssignmentReportProperties. +func (a AssignmentReportProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "assignment", a.Assignment) + populate(objectMap, "complianceStatus", a.ComplianceStatus) + populate(objectMap, "details", a.Details) + populateTimeRFC3339(objectMap, "endTime", a.EndTime) + populate(objectMap, "reportId", a.ReportID) + populateTimeRFC3339(objectMap, "startTime", a.StartTime) + populate(objectMap, "vm", a.VM) + populate(objectMap, "vmssResourceId", a.VmssResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentReportProperties. +func (a *AssignmentReportProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "assignment": + err = unpopulate(val, "Assignment", &a.Assignment) + delete(rawMsg, key) + case "complianceStatus": + err = unpopulate(val, "ComplianceStatus", &a.ComplianceStatus) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &a.Details) + delete(rawMsg, key) + case "endTime": + err = unpopulateTimeRFC3339(val, "EndTime", &a.EndTime) + delete(rawMsg, key) + case "reportId": + err = unpopulate(val, "ReportID", &a.ReportID) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &a.StartTime) + delete(rawMsg, key) + case "vm": + err = unpopulate(val, "VM", &a.VM) + delete(rawMsg, key) + case "vmssResourceId": + err = unpopulate(val, "VmssResourceID", &a.VmssResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AssignmentReportResource. +func (a AssignmentReportResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "complianceStatus", a.ComplianceStatus) + populate(objectMap, "properties", &a.Properties) + populate(objectMap, "reasons", a.Reasons) + populate(objectMap, "resourceId", a.ResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentReportResource. +func (a *AssignmentReportResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "complianceStatus": + err = unpopulate(val, "ComplianceStatus", &a.ComplianceStatus) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "reasons": + err = unpopulate(val, "Reasons", &a.Reasons) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &a.ResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AssignmentReportResourceComplianceReason. +func (a AssignmentReportResourceComplianceReason) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", a.Code) + populate(objectMap, "phrase", a.Phrase) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentReportResourceComplianceReason. +func (a *AssignmentReportResourceComplianceReason) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &a.Code) + delete(rawMsg, key) + case "phrase": + err = unpopulate(val, "Phrase", &a.Phrase) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommonAssignmentReport. +func (c CommonAssignmentReport) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "assignment", c.Assignment) + populate(objectMap, "complianceStatus", c.ComplianceStatus) + populateTimeRFC3339(objectMap, "endTime", c.EndTime) + populate(objectMap, "id", c.ID) + populate(objectMap, "operationType", c.OperationType) + populate(objectMap, "reportId", c.ReportID) + populate(objectMap, "resources", c.Resources) + populateTimeRFC3339(objectMap, "startTime", c.StartTime) + populate(objectMap, "vm", c.VM) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommonAssignmentReport. +func (c *CommonAssignmentReport) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "assignment": + err = unpopulate(val, "Assignment", &c.Assignment) + delete(rawMsg, key) + case "complianceStatus": + err = unpopulate(val, "ComplianceStatus", &c.ComplianceStatus) + delete(rawMsg, key) + case "endTime": + err = unpopulateTimeRFC3339(val, "EndTime", &c.EndTime) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "operationType": + err = unpopulate(val, "OperationType", &c.OperationType) + delete(rawMsg, key) + case "reportId": + err = unpopulate(val, "ReportID", &c.ReportID) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &c.Resources) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &c.StartTime) + delete(rawMsg, key) + case "vm": + err = unpopulate(val, "VM", &c.VM) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ConfigurationInfo. +func (c ConfigurationInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "version", c.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigurationInfo. +func (c *ConfigurationInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &c.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ConfigurationParameter. +func (c ConfigurationParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigurationParameter. +func (c *ConfigurationParameter) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ConfigurationSetting. +func (c ConfigurationSetting) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionAfterReboot", c.ActionAfterReboot) + populate(objectMap, "allowModuleOverwrite", c.AllowModuleOverwrite) + populate(objectMap, "configurationMode", c.ConfigurationMode) + populate(objectMap, "configurationModeFrequencyMins", c.ConfigurationModeFrequencyMins) + populate(objectMap, "rebootIfNeeded", c.RebootIfNeeded) + populate(objectMap, "refreshFrequencyMins", c.RefreshFrequencyMins) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConfigurationSetting. +func (c *ConfigurationSetting) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionAfterReboot": + err = unpopulate(val, "ActionAfterReboot", &c.ActionAfterReboot) + delete(rawMsg, key) + case "allowModuleOverwrite": + err = unpopulate(val, "AllowModuleOverwrite", &c.AllowModuleOverwrite) + delete(rawMsg, key) + case "configurationMode": + err = unpopulate(val, "ConfigurationMode", &c.ConfigurationMode) + delete(rawMsg, key) + case "configurationModeFrequencyMins": + err = unpopulate(val, "ConfigurationModeFrequencyMins", &c.ConfigurationModeFrequencyMins) + delete(rawMsg, key) + case "rebootIfNeeded": + err = unpopulate(val, "RebootIfNeeded", &c.RebootIfNeeded) + delete(rawMsg, key) + case "refreshFrequencyMins": + err = unpopulate(val, "RefreshFrequencyMins", &c.RefreshFrequencyMins) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type 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 ErrorResponseError. +func (e ErrorResponseError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", e.Code) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponseError. +func (e *ErrorResponseError) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Navigation. +func (n Navigation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "assignmentSource", n.AssignmentSource) + populate(objectMap, "assignmentType", n.AssignmentType) + populate(objectMap, "configurationParameter", n.ConfigurationParameter) + populate(objectMap, "configurationProtectedParameter", n.ConfigurationProtectedParameter) + populate(objectMap, "configurationSetting", n.ConfigurationSetting) + populate(objectMap, "contentHash", n.ContentHash) + populate(objectMap, "contentType", n.ContentType) + populate(objectMap, "contentUri", n.ContentURI) + populate(objectMap, "kind", n.Kind) + populate(objectMap, "name", n.Name) + populate(objectMap, "version", n.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Navigation. +func (n *Navigation) 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", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "assignmentSource": + err = unpopulate(val, "AssignmentSource", &n.AssignmentSource) + delete(rawMsg, key) + case "assignmentType": + err = unpopulate(val, "AssignmentType", &n.AssignmentType) + delete(rawMsg, key) + case "configurationParameter": + err = unpopulate(val, "ConfigurationParameter", &n.ConfigurationParameter) + delete(rawMsg, key) + case "configurationProtectedParameter": + err = unpopulate(val, "ConfigurationProtectedParameter", &n.ConfigurationProtectedParameter) + delete(rawMsg, key) + case "configurationSetting": + err = unpopulate(val, "ConfigurationSetting", &n.ConfigurationSetting) + delete(rawMsg, key) + case "contentHash": + err = unpopulate(val, "ContentHash", &n.ContentHash) + delete(rawMsg, key) + case "contentType": + err = unpopulate(val, "ContentType", &n.ContentType) + delete(rawMsg, key) + case "contentUri": + err = unpopulate(val, "ContentURI", &n.ContentURI) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &n.Kind) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &n.Name) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &n.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", o.Display) + populate(objectMap, "name", o.Name) + populate(objectMap, "properties", o.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// 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) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationList. +func (o OperationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationList. +func (o *OperationList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationProperties. +func (o OperationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "statusCode", o.StatusCode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationProperties. +func (o *OperationProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "statusCode": + err = unpopulate(val, "StatusCode", &o.StatusCode) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProxyResource. +func (p ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "location", p.Location) + populate(objectMap, "name", p.Name) + 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 "location": + err = unpopulate(val, "Location", &p.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + 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) + populate(objectMap, "id", r.ID) + populate(objectMap, "location", r.Location) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &r.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VMInfo. +func (v VMInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", v.ID) + populate(objectMap, "uuid", v.UUID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMInfo. +func (v *VMInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &v.ID) + delete(rawMsg, key) + case "uuid": + err = unpopulate(val, "UUID", &v.UUID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VMSSVMInfo. +func (v VMSSVMInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "complianceStatus", v.ComplianceStatus) + populateTimeRFC3339(objectMap, "lastComplianceChecked", v.LastComplianceChecked) + populate(objectMap, "latestReportId", v.LatestReportID) + populate(objectMap, "vmId", v.VMID) + populate(objectMap, "vmResourceId", v.VMResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMSSVMInfo. +func (v *VMSSVMInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "complianceStatus": + err = unpopulate(val, "ComplianceStatus", &v.ComplianceStatus) + delete(rawMsg, key) + case "lastComplianceChecked": + err = unpopulateTimeRFC3339(val, "LastComplianceChecked", &v.LastComplianceChecked) + delete(rawMsg, key) + case "latestReportId": + err = unpopulate(val, "LatestReportID", &v.LatestReportID) + delete(rawMsg, key) + case "vmId": + err = unpopulate(val, "VMID", &v.VMID) + delete(rawMsg, key) + case "vmResourceId": + err = unpopulate(val, "VMResourceID", &v.VMResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_operations_client.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/operations_client.go similarity index 76% rename from sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_operations_client.go rename to sdk/resourcemanager/guestconfiguration/armguestconfiguration/operations_client.go index 23f31383674e..03ea8d88f76e 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_operations_client.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/operations_client.go @@ -5,6 +5,7 @@ // 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 armguestconfiguration @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,36 +21,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Lists all of the available GuestConfiguration REST API operations. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2022-01-25 -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - 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 { @@ -62,7 +52,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -77,7 +67,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.GuestConfiguration/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/operations_client_example_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/operations_client_example_test.go new file mode 100644 index 000000000000..4170a250fe02 --- /dev/null +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/operations_client_example_test.go @@ -0,0 +1,82 @@ +//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 armguestconfiguration_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listOperations.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 := armguestconfiguration.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.OperationList = armguestconfiguration.OperationList{ + // Value: []*armguestconfiguration.Operation{ + // { + // Name: to.Ptr("Microsoft.GuestConfiguration/guestConfigurationAssignments/write"), + // Display: &armguestconfiguration.OperationDisplay{ + // Description: to.Ptr("Create new guest configuration assignment."), + // Operation: to.Ptr("Microsoft.GuestConfiguration/guestConfigurationAssignments/write"), + // Provider: to.Ptr("Microsoft Guest Configuration"), + // Resource: to.Ptr("Microsoft.GuestConfiguration/guestConfigurationAssignments"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.GuestConfiguration/register/action"), + // Display: &armguestconfiguration.OperationDisplay{ + // Description: to.Ptr("Registers the subscription for the Microsoft.GuestConfiguration resource provider."), + // Operation: to.Ptr("Registers the feature for Microsoft.GuestConfiguration."), + // Provider: to.Ptr("Microsoft Guest Configuration"), + // Resource: to.Ptr("Register"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.GuestConfiguration/guestConfigurationAssignments/read"), + // Display: &armguestconfiguration.OperationDisplay{ + // Description: to.Ptr("Get guest configuration assignment."), + // Operation: to.Ptr("Microsoft.GuestConfiguration/guestConfigurationAssignments/read"), + // Provider: to.Ptr("Microsoft Guest Configuration"), + // Resource: to.Ptr("Microsoft.GuestConfiguration/guestConfigurationAssignments"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.GuestConfiguration/guestConfigurationAssignments/reports/read"), + // Display: &armguestconfiguration.OperationDisplay{ + // Description: to.Ptr("Get guest configuration assignment report."), + // Operation: to.Ptr("Microsoft.GuestConfiguration/guestConfigurationAssignments/reports/read"), + // Provider: to.Ptr("Microsoft Guest Configuration"), + // Resource: to.Ptr("Microsoft.GuestConfiguration/guestConfigurationAssignments"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_response_types.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/response_types.go similarity index 91% rename from sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_response_types.go rename to sdk/resourcemanager/guestconfiguration/armguestconfiguration/response_types.go index 79b444da5352..f7ec5710b68f 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_response_types.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/response_types.go @@ -5,6 +5,7 @@ // 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 armguestconfiguration @@ -23,7 +24,7 @@ type AssignmentReportsVMSSClientGetResponse struct { AssignmentReport } -// AssignmentReportsVMSSClientListResponse contains the response from method AssignmentReportsVMSSClient.List. +// AssignmentReportsVMSSClientListResponse contains the response from method AssignmentReportsVMSSClient.NewListPager. type AssignmentReportsVMSSClientListResponse struct { AssignmentReportList } @@ -43,17 +44,17 @@ type AssignmentsClientGetResponse struct { Assignment } -// AssignmentsClientListResponse contains the response from method AssignmentsClient.List. +// AssignmentsClientListResponse contains the response from method AssignmentsClient.NewListPager. type AssignmentsClientListResponse struct { AssignmentList } -// AssignmentsClientRGListResponse contains the response from method AssignmentsClient.RGList. +// AssignmentsClientRGListResponse contains the response from method AssignmentsClient.NewRGListPager. type AssignmentsClientRGListResponse struct { AssignmentList } -// AssignmentsClientSubscriptionListResponse contains the response from method AssignmentsClient.SubscriptionList. +// AssignmentsClientSubscriptionListResponse contains the response from method AssignmentsClient.NewSubscriptionListPager. type AssignmentsClientSubscriptionListResponse struct { AssignmentList } @@ -68,7 +69,7 @@ type AssignmentsVMSSClientGetResponse struct { Assignment } -// AssignmentsVMSSClientListResponse contains the response from method AssignmentsVMSSClient.List. +// AssignmentsVMSSClientListResponse contains the response from method AssignmentsVMSSClient.NewListPager. type AssignmentsVMSSClientListResponse struct { AssignmentList } @@ -98,12 +99,12 @@ type HCRPAssignmentsClientGetResponse struct { Assignment } -// HCRPAssignmentsClientListResponse contains the response from method HCRPAssignmentsClient.List. +// HCRPAssignmentsClientListResponse contains the response from method HCRPAssignmentsClient.NewListPager. type HCRPAssignmentsClientListResponse struct { AssignmentList } -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationList } diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_time_rfc3339.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/time_rfc3339.go similarity index 96% rename from sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/guestconfiguration/armguestconfiguration/time_rfc3339.go index 448d935f9295..857a4026e125 100644 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/time_rfc3339.go @@ -5,6 +5,7 @@ // 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 armguestconfiguration @@ -61,7 +62,7 @@ func (t *timeRFC3339) Parse(layout, value string) error { return err } -func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_guestconfigurationassignmentreports_client_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_guestconfigurationassignmentreports_client_test.go deleted file mode 100644 index aebdbd824d74..000000000000 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_guestconfigurationassignmentreports_client_test.go +++ /dev/null @@ -1,64 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armguestconfiguration_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listAllGuestConfigurationAssignmentReports.json -func ExampleAssignmentReportsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewAssignmentReportsClient("mySubscriptionid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.List(ctx, - "myResourceGroupName", - "AuditSecureProtocol", - "myVMName", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/getGuestConfigurationAssignmentReportById.json -func ExampleAssignmentReportsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewAssignmentReportsClient("mySubscriptionid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "myResourceGroupName", - "AuditSecureProtocol", - "7367cbb8-ae99-47d0-a33b-a283564d2cb1", - "myvm", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_guestconfigurationassignmentreportsvmss_client_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_guestconfigurationassignmentreportsvmss_client_test.go deleted file mode 100644 index fb868506c157..000000000000 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_guestconfigurationassignmentreportsvmss_client_test.go +++ /dev/null @@ -1,68 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armguestconfiguration_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listAllVMSSGuestConfigurationAssignmentReports.json -func ExampleAssignmentReportsVMSSClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewAssignmentReportsVMSSClient("mySubscriptionid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("myResourceGroupName", - "myVMSSName", - "AuditSecureProtocol", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/getVMSSGuestConfigurationAssignmentReportById.json -func ExampleAssignmentReportsVMSSClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewAssignmentReportsVMSSClient("mySubscriptionid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "myResourceGroupName", - "myvmss", - "AuditSecureProtocol", - "7367cbb8-ae99-47d0-a33b-a283564d2cb1", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_guestconfigurationassignments_client_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_guestconfigurationassignments_client_test.go deleted file mode 100644 index af08163277d6..000000000000 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_guestconfigurationassignments_client_test.go +++ /dev/null @@ -1,179 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armguestconfiguration_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/guestconfiguration/armguestconfiguration" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/createOrUpdateGuestConfigurationAssignment.json -func ExampleAssignmentsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewAssignmentsClient("mySubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "NotInstalledApplicationForWindows", - "myResourceGroupName", - "myVMName", - armguestconfiguration.Assignment{ - Name: to.Ptr("NotInstalledApplicationForWindows"), - Location: to.Ptr("westcentralus"), - Properties: &armguestconfiguration.AssignmentProperties{ - Context: to.Ptr("Azure policy"), - GuestConfiguration: &armguestconfiguration.Navigation{ - Name: to.Ptr("NotInstalledApplicationForWindows"), - AssignmentType: to.Ptr(armguestconfiguration.AssignmentTypeApplyAndAutoCorrect), - ConfigurationParameter: []*armguestconfiguration.ConfigurationParameter{ - { - Name: to.Ptr("[InstalledApplication]NotInstalledApplicationResource1;Name"), - Value: to.Ptr("NotePad,sql"), - }}, - ContentHash: to.Ptr("123contenthash"), - ContentURI: to.Ptr("https://thisisfake/pacakge"), - Version: to.Ptr("1.*"), - }, - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/getGuestConfigurationAssignment.json -func ExampleAssignmentsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewAssignmentsClient("mySubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "myResourceGroupName", - "SecureProtocol", - "myVMName", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/deleteGuestConfigurationAssignment.json -func ExampleAssignmentsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewAssignmentsClient("mySubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "myResourceGroupName", - "SecureProtocol", - "myVMName", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listSubGuestConfigurationAssignments.json -func ExampleAssignmentsClient_NewSubscriptionListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewAssignmentsClient("mySubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewSubscriptionListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listRGGuestConfigurationAssignments.json -func ExampleAssignmentsClient_NewRGListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewAssignmentsClient("mySubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewRGListPager("myResourceGroupName", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listGuestConfigurationAssignments.json -func ExampleAssignmentsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewAssignmentsClient("mySubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("myResourceGroupName", - "myVMName", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_guestconfigurationassignmentsvmss_client_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_guestconfigurationassignmentsvmss_client_test.go deleted file mode 100644 index f1cfd280d866..000000000000 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_guestconfigurationassignmentsvmss_client_test.go +++ /dev/null @@ -1,89 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armguestconfiguration_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/getVMSSGuestConfigurationAssignment.json -func ExampleAssignmentsVMSSClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewAssignmentsVMSSClient("mySubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "myResourceGroupName", - "myVMSSName", - "SecureProtocol", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/deleteGuestConfigurationVMSSAssignment.json -func ExampleAssignmentsVMSSClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewAssignmentsVMSSClient("mySubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Delete(ctx, - "myResourceGroupName", - "myVMSSName", - "SecureProtocol", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listVMSSGuestConfigurationAssignments.json -func ExampleAssignmentsVMSSClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewAssignmentsVMSSClient("mySubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("myResourceGroupName", - "myVMSSName", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_guestconfigurationhcrpassignmentreports_client_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_guestconfigurationhcrpassignmentreports_client_test.go deleted file mode 100644 index 9c894275ae7d..000000000000 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_guestconfigurationhcrpassignmentreports_client_test.go +++ /dev/null @@ -1,64 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armguestconfiguration_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listAllGuestConfigurationHCRPAssignmentReports.json -func ExampleHCRPAssignmentReportsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewHCRPAssignmentReportsClient("mySubscriptionid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.List(ctx, - "myResourceGroupName", - "AuditSecureProtocol", - "myMachineName", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/getGuestConfigurationHCRPAssignmentReportById.json -func ExampleHCRPAssignmentReportsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewHCRPAssignmentReportsClient("mySubscriptionid", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "myResourceGroupName", - "AuditSecureProtocol", - "7367cbb8-ae99-47d0-a33b-a283564d2cb1", - "myMachineName", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_guestconfigurationhcrpassignments_client_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_guestconfigurationhcrpassignments_client_test.go deleted file mode 100644 index bf5e4466efab..000000000000 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_guestconfigurationhcrpassignments_client_test.go +++ /dev/null @@ -1,130 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armguestconfiguration_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/guestconfiguration/armguestconfiguration" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/createOrUpdateGuestConfigurationHCRPAssignment.json -func ExampleHCRPAssignmentsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewHCRPAssignmentsClient("mySubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.CreateOrUpdate(ctx, - "NotInstalledApplicationForWindows", - "myResourceGroupName", - "myMachineName", - armguestconfiguration.Assignment{ - Name: to.Ptr("NotInstalledApplicationForWindows"), - Location: to.Ptr("westcentralus"), - Properties: &armguestconfiguration.AssignmentProperties{ - Context: to.Ptr("Azure policy"), - GuestConfiguration: &armguestconfiguration.Navigation{ - Name: to.Ptr("NotInstalledApplicationForWindows"), - AssignmentType: to.Ptr(armguestconfiguration.AssignmentTypeApplyAndAutoCorrect), - ConfigurationParameter: []*armguestconfiguration.ConfigurationParameter{ - { - Name: to.Ptr("[InstalledApplication]NotInstalledApplicationResource1;Name"), - Value: to.Ptr("NotePad,sql"), - }}, - ContentHash: to.Ptr("123contenthash"), - ContentURI: to.Ptr("https://thisisfake/pacakge"), - Version: to.Ptr("1.*"), - }, - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/getGuestConfigurationHCRPAssignment.json -func ExampleHCRPAssignmentsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewHCRPAssignmentsClient("mySubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "myResourceGroupName", - "SecureProtocol", - "myMachineName", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/deleteGuestConfigurationHCRPAssignment.json -func ExampleHCRPAssignmentsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewHCRPAssignmentsClient("mySubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Delete(ctx, - "myResourceGroupName", - "SecureProtocol", - "myMachineName", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listGuestConfigurationHCRPAssignments.json -func ExampleHCRPAssignmentsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewHCRPAssignmentsClient("mySubscriptionId", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("myResourceGroupName", - "myMachineName", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_operations_client_test.go deleted file mode 100644 index 56bcbd5b59ad..000000000000 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/ze_generated_example_operations_client_test.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armguestconfiguration_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/guestconfiguration/armguestconfiguration" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2022-01-25/examples/listOperations.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armguestconfiguration.NewOperationsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_models_serde.go b/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_models_serde.go deleted file mode 100644 index afcc1690fc10..000000000000 --- a/sdk/resourcemanager/guestconfiguration/armguestconfiguration/zz_generated_models_serde.go +++ /dev/null @@ -1,359 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armguestconfiguration - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type AssignmentProperties. -func (a AssignmentProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "assignmentHash", a.AssignmentHash) - populate(objectMap, "complianceStatus", a.ComplianceStatus) - populate(objectMap, "context", a.Context) - populate(objectMap, "guestConfiguration", a.GuestConfiguration) - populateTimeRFC3339(objectMap, "lastComplianceStatusChecked", a.LastComplianceStatusChecked) - populate(objectMap, "latestAssignmentReport", a.LatestAssignmentReport) - populate(objectMap, "latestReportId", a.LatestReportID) - populate(objectMap, "parameterHash", a.ParameterHash) - populate(objectMap, "provisioningState", a.ProvisioningState) - populate(objectMap, "resourceType", a.ResourceType) - populate(objectMap, "targetResourceId", a.TargetResourceID) - populate(objectMap, "vmssVMList", a.VmssVMList) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentProperties. -func (a *AssignmentProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "assignmentHash": - err = unpopulate(val, "AssignmentHash", &a.AssignmentHash) - delete(rawMsg, key) - case "complianceStatus": - err = unpopulate(val, "ComplianceStatus", &a.ComplianceStatus) - delete(rawMsg, key) - case "context": - err = unpopulate(val, "Context", &a.Context) - delete(rawMsg, key) - case "guestConfiguration": - err = unpopulate(val, "GuestConfiguration", &a.GuestConfiguration) - delete(rawMsg, key) - case "lastComplianceStatusChecked": - err = unpopulateTimeRFC3339(val, "LastComplianceStatusChecked", &a.LastComplianceStatusChecked) - delete(rawMsg, key) - case "latestAssignmentReport": - err = unpopulate(val, "LatestAssignmentReport", &a.LatestAssignmentReport) - delete(rawMsg, key) - case "latestReportId": - err = unpopulate(val, "LatestReportID", &a.LatestReportID) - delete(rawMsg, key) - case "parameterHash": - err = unpopulate(val, "ParameterHash", &a.ParameterHash) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) - delete(rawMsg, key) - case "resourceType": - err = unpopulate(val, "ResourceType", &a.ResourceType) - delete(rawMsg, key) - case "targetResourceId": - err = unpopulate(val, "TargetResourceID", &a.TargetResourceID) - delete(rawMsg, key) - case "vmssVMList": - err = unpopulate(val, "VmssVMList", &a.VmssVMList) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentReportDetails. -func (a *AssignmentReportDetails) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "complianceStatus": - err = unpopulate(val, "ComplianceStatus", &a.ComplianceStatus) - delete(rawMsg, key) - case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &a.EndTime) - delete(rawMsg, key) - case "jobId": - err = unpopulate(val, "JobID", &a.JobID) - delete(rawMsg, key) - case "operationType": - err = unpopulate(val, "OperationType", &a.OperationType) - delete(rawMsg, key) - case "resources": - err = unpopulate(val, "Resources", &a.Resources) - delete(rawMsg, key) - case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &a.StartTime) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AssignmentReportProperties. -func (a *AssignmentReportProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "assignment": - err = unpopulate(val, "Assignment", &a.Assignment) - delete(rawMsg, key) - case "complianceStatus": - err = unpopulate(val, "ComplianceStatus", &a.ComplianceStatus) - delete(rawMsg, key) - case "details": - err = unpopulate(val, "Details", &a.Details) - delete(rawMsg, key) - case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &a.EndTime) - delete(rawMsg, key) - case "reportId": - err = unpopulate(val, "ReportID", &a.ReportID) - delete(rawMsg, key) - case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &a.StartTime) - delete(rawMsg, key) - case "vm": - err = unpopulate(val, "VM", &a.VM) - delete(rawMsg, key) - case "vmssResourceId": - err = unpopulate(val, "VmssResourceID", &a.VmssResourceID) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", a, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type AssignmentReportResource. -func (a AssignmentReportResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "complianceStatus", a.ComplianceStatus) - populate(objectMap, "properties", &a.Properties) - populate(objectMap, "reasons", a.Reasons) - populate(objectMap, "resourceId", a.ResourceID) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type CommonAssignmentReport. -func (c CommonAssignmentReport) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "assignment", c.Assignment) - populate(objectMap, "complianceStatus", c.ComplianceStatus) - populateTimeRFC3339(objectMap, "endTime", c.EndTime) - populate(objectMap, "id", c.ID) - populate(objectMap, "operationType", c.OperationType) - populate(objectMap, "reportId", c.ReportID) - populate(objectMap, "resources", c.Resources) - populateTimeRFC3339(objectMap, "startTime", c.StartTime) - populate(objectMap, "vm", c.VM) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type CommonAssignmentReport. -func (c *CommonAssignmentReport) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "assignment": - err = unpopulate(val, "Assignment", &c.Assignment) - delete(rawMsg, key) - case "complianceStatus": - err = unpopulate(val, "ComplianceStatus", &c.ComplianceStatus) - delete(rawMsg, key) - case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &c.EndTime) - delete(rawMsg, key) - case "id": - err = unpopulate(val, "ID", &c.ID) - delete(rawMsg, key) - case "operationType": - err = unpopulate(val, "OperationType", &c.OperationType) - delete(rawMsg, key) - case "reportId": - err = unpopulate(val, "ReportID", &c.ReportID) - delete(rawMsg, key) - case "resources": - err = unpopulate(val, "Resources", &c.Resources) - delete(rawMsg, key) - case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &c.StartTime) - delete(rawMsg, key) - case "vm": - err = unpopulate(val, "VM", &c.VM) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type Navigation. -func (n Navigation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "assignmentSource", n.AssignmentSource) - populate(objectMap, "assignmentType", n.AssignmentType) - populate(objectMap, "configurationParameter", n.ConfigurationParameter) - populate(objectMap, "configurationProtectedParameter", n.ConfigurationProtectedParameter) - populate(objectMap, "configurationSetting", n.ConfigurationSetting) - populate(objectMap, "contentHash", n.ContentHash) - populate(objectMap, "contentType", n.ContentType) - populate(objectMap, "contentUri", n.ContentURI) - populate(objectMap, "kind", n.Kind) - populate(objectMap, "name", n.Name) - populate(objectMap, "version", n.Version) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type SystemData. -func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) - populate(objectMap, "createdBy", s.CreatedBy) - populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) - populate(objectMap, "lastModifiedBy", s.LastModifiedBy) - populate(objectMap, "lastModifiedByType", s.LastModifiedByType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. -func (s *SystemData) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) - delete(rawMsg, key) - case "createdBy": - err = unpopulate(val, "CreatedBy", &s.CreatedBy) - delete(rawMsg, key) - case "createdByType": - err = unpopulate(val, "CreatedByType", &s.CreatedByType) - delete(rawMsg, key) - case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) - delete(rawMsg, key) - case "lastModifiedBy": - err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) - delete(rawMsg, key) - case "lastModifiedByType": - err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", s, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type VMSSVMInfo. -func (v VMSSVMInfo) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "complianceStatus", v.ComplianceStatus) - populateTimeRFC3339(objectMap, "lastComplianceChecked", v.LastComplianceChecked) - populate(objectMap, "latestReportId", v.LatestReportID) - populate(objectMap, "vmId", v.VMID) - populate(objectMap, "vmResourceId", v.VMResourceID) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type VMSSVMInfo. -func (v *VMSSVMInfo) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "complianceStatus": - err = unpopulate(val, "ComplianceStatus", &v.ComplianceStatus) - delete(rawMsg, key) - case "lastComplianceChecked": - err = unpopulateTimeRFC3339(val, "LastComplianceChecked", &v.LastComplianceChecked) - delete(rawMsg, key) - case "latestReportId": - err = unpopulate(val, "LatestReportID", &v.LatestReportID) - delete(rawMsg, key) - case "vmId": - err = unpopulate(val, "VMID", &v.VMID) - delete(rawMsg, key) - case "vmResourceId": - err = unpopulate(val, "VMResourceID", &v.VMResourceID) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - } - return nil -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} - -func unpopulate(data json.RawMessage, fn string, v interface{}) error { - if data == nil { - return nil - } - if err := json.Unmarshal(data, v); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - return nil -} diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/CHANGELOG.md b/sdk/resourcemanager/hanaonazure/armhanaonazure/CHANGELOG.md index f5b49d29c4cb..3d7985e319ea 100644 --- a/sdk/resourcemanager/hanaonazure/armhanaonazure/CHANGELOG.md +++ b/sdk/resourcemanager/hanaonazure/armhanaonazure/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 0.6.0 (2023-03-28) +### Features Added + +- New struct `ClientFactory` which is a client factory used to create any client in this module + + ## 0.5.0 (2022-05-18) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hanaonazure/armhanaonazure` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 0.5.0, which contains breaking changes. diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/README.md b/sdk/resourcemanager/hanaonazure/armhanaonazure/README.md index 971e5a6d454d..fd9f45b6b6e4 100644 --- a/sdk/resourcemanager/hanaonazure/armhanaonazure/README.md +++ b/sdk/resourcemanager/hanaonazure/armhanaonazure/README.md @@ -33,12 +33,12 @@ cred, err := azidentity.NewDefaultAzureCredential(nil) For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). -## Clients +## Client Factory -Azure SAP HANA modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. +Azure SAP HANA module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -client, err := armhanaonazure.NewSapMonitorsClient(, cred, nil) +clientFactory, err := armhanaonazure.NewClientFactory(, cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -49,7 +49,15 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -client, err := armhanaonazure.NewSapMonitorsClient(, cred, &options) +clientFactory, err := armhanaonazure.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewSapMonitorsClient() ``` ## Provide Feedback diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/autorest.md b/sdk/resourcemanager/hanaonazure/armhanaonazure/autorest.md index 15b6d7e70028..b004af5d7bf6 100644 --- a/sdk/resourcemanager/hanaonazure/armhanaonazure/autorest.md +++ b/sdk/resourcemanager/hanaonazure/armhanaonazure/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/hanaonazure/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/hanaonazure/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.5.0 +module-version: 0.6.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/client_factory.go b/sdk/resourcemanager/hanaonazure/armhanaonazure/client_factory.go new file mode 100644 index 000000000000..947e173a8c6c --- /dev/null +++ b/sdk/resourcemanager/hanaonazure/armhanaonazure/client_factory.go @@ -0,0 +1,55 @@ +//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 armhanaonazure + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of +// the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewSapMonitorsClient() *SapMonitorsClient { + subClient, _ := NewSapMonitorsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewProviderInstancesClient() *ProviderInstancesClient { + subClient, _ := NewProviderInstancesClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_constants.go b/sdk/resourcemanager/hanaonazure/armhanaonazure/constants.go similarity index 97% rename from sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_constants.go rename to sdk/resourcemanager/hanaonazure/armhanaonazure/constants.go index 4c2077e98c3f..8742da9a74b9 100644 --- a/sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_constants.go +++ b/sdk/resourcemanager/hanaonazure/armhanaonazure/constants.go @@ -5,12 +5,13 @@ // 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 armhanaonazure const ( moduleName = "armhanaonazure" - moduleVersion = "v0.5.0" + moduleVersion = "v0.6.0" ) // HanaProvisioningStatesEnum - State of provisioning of the HanaInstance diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/go.mod b/sdk/resourcemanager/hanaonazure/armhanaonazure/go.mod index b315805c1a74..c023485a2ecd 100644 --- a/sdk/resourcemanager/hanaonazure/armhanaonazure/go.mod +++ b/sdk/resourcemanager/hanaonazure/armhanaonazure/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hanaonazure/armhana go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/text v0.3.7 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect ) diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/go.sum b/sdk/resourcemanager/hanaonazure/armhanaonazure/go.sum index ed5b814680ee..8ba445a8c4da 100644 --- a/sdk/resourcemanager/hanaonazure/armhanaonazure/go.sum +++ b/sdk/resourcemanager/hanaonazure/armhanaonazure/go.sum @@ -1,33 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= +github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_models.go b/sdk/resourcemanager/hanaonazure/armhanaonazure/models.go similarity index 98% rename from sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_models.go rename to sdk/resourcemanager/hanaonazure/armhanaonazure/models.go index ab01d42ef495..0614c3b699d6 100644 --- a/sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_models.go +++ b/sdk/resourcemanager/hanaonazure/armhanaonazure/models.go @@ -5,6 +5,7 @@ // 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 armhanaonazure @@ -64,7 +65,7 @@ type OperationList struct { Value []*Operation `json:"value,omitempty"` } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. type OperationsClientListOptions struct { // placeholder for future optional parameters } @@ -127,7 +128,7 @@ type ProviderInstancesClientGetOptions struct { // placeholder for future optional parameters } -// ProviderInstancesClientListOptions contains the optional parameters for the ProviderInstancesClient.List method. +// ProviderInstancesClientListOptions contains the optional parameters for the ProviderInstancesClient.NewListPager method. type ProviderInstancesClientListOptions struct { // placeholder for future optional parameters } @@ -231,7 +232,7 @@ type SapMonitorsClientGetOptions struct { // placeholder for future optional parameters } -// SapMonitorsClientListOptions contains the optional parameters for the SapMonitorsClient.List method. +// SapMonitorsClientListOptions contains the optional parameters for the SapMonitorsClient.NewListPager method. type SapMonitorsClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/models_serde.go b/sdk/resourcemanager/hanaonazure/armhanaonazure/models_serde.go new file mode 100644 index 000000000000..50b33b7b71f2 --- /dev/null +++ b/sdk/resourcemanager/hanaonazure/armhanaonazure/models_serde.go @@ -0,0 +1,578 @@ +//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 armhanaonazure + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Display. +func (d Display) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", d.Description) + populate(objectMap, "operation", d.Operation) + populate(objectMap, "origin", d.Origin) + populate(objectMap, "provider", d.Provider) + populate(objectMap, "resource", d.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Display. +func (d *Display) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &d.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &d.Operation) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &d.Origin) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &d.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &d.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", e.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponseError. +func (e ErrorResponseError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", e.Code) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponseError. +func (e *ErrorResponseError) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "display", o.Display) + populate(objectMap, "name", o.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationList. +func (o OperationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationList. +func (o *OperationList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProviderInstance. +func (p ProviderInstance) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProviderInstance. +func (p *ProviderInstance) 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 "properties": + err = unpopulate(val, "Properties", &p.Properties) + 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 ProviderInstanceListResult. +func (p ProviderInstanceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProviderInstanceListResult. +func (p *ProviderInstanceListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + 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 ProviderInstanceProperties. +func (p ProviderInstanceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "metadata", p.Metadata) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProviderInstanceProperties. +func (p *ProviderInstanceProperties) 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 "metadata": + err = unpopulate(val, "Metadata", &p.Metadata) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + 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 ProxyResource. +func (p ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + 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 "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) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SapMonitor. +func (s SapMonitor) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "location", s.Location) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SapMonitor. +func (s *SapMonitor) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &s.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SapMonitorListResult. +func (s SapMonitorListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SapMonitorListResult. +func (s *SapMonitorListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SapMonitorProperties. +func (s SapMonitorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "enableCustomerAnalytics", s.EnableCustomerAnalytics) + populate(objectMap, "logAnalyticsWorkspaceArmId", s.LogAnalyticsWorkspaceArmID) + populate(objectMap, "logAnalyticsWorkspaceId", s.LogAnalyticsWorkspaceID) + populate(objectMap, "logAnalyticsWorkspaceSharedKey", s.LogAnalyticsWorkspaceSharedKey) + populate(objectMap, "managedResourceGroupName", s.ManagedResourceGroupName) + populate(objectMap, "monitorSubnet", s.MonitorSubnet) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "sapMonitorCollectorVersion", s.SapMonitorCollectorVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SapMonitorProperties. +func (s *SapMonitorProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "enableCustomerAnalytics": + err = unpopulate(val, "EnableCustomerAnalytics", &s.EnableCustomerAnalytics) + delete(rawMsg, key) + case "logAnalyticsWorkspaceArmId": + err = unpopulate(val, "LogAnalyticsWorkspaceArmID", &s.LogAnalyticsWorkspaceArmID) + delete(rawMsg, key) + case "logAnalyticsWorkspaceId": + err = unpopulate(val, "LogAnalyticsWorkspaceID", &s.LogAnalyticsWorkspaceID) + delete(rawMsg, key) + case "logAnalyticsWorkspaceSharedKey": + err = unpopulate(val, "LogAnalyticsWorkspaceSharedKey", &s.LogAnalyticsWorkspaceSharedKey) + delete(rawMsg, key) + case "managedResourceGroupName": + err = unpopulate(val, "ManagedResourceGroupName", &s.ManagedResourceGroupName) + delete(rawMsg, key) + case "monitorSubnet": + err = unpopulate(val, "MonitorSubnet", &s.MonitorSubnet) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "sapMonitorCollectorVersion": + err = unpopulate(val, "SapMonitorCollectorVersion", &s.SapMonitorCollectorVersion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Tags. +func (t Tags) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", t.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Tags. +func (t *Tags) 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 "tags": + err = unpopulate(val, "Tags", &t.Tags) + 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 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, "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 "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 +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_operations_client.go b/sdk/resourcemanager/hanaonazure/armhanaonazure/operations_client.go similarity index 76% rename from sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_operations_client.go rename to sdk/resourcemanager/hanaonazure/armhanaonazure/operations_client.go index f96e35b056f1..bf47e7ef0339 100644 --- a/sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_operations_client.go +++ b/sdk/resourcemanager/hanaonazure/armhanaonazure/operations_client.go @@ -5,6 +5,7 @@ // 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 armhanaonazure @@ -12,8 +13,6 @@ import ( "context" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,36 +21,27 @@ import ( // OperationsClient contains the methods for the Operations group. // Don't use this type directly, use NewOperationsClient() instead. type OperationsClient struct { - host string - pl runtime.Pipeline + internal *arm.Client } // NewOperationsClient creates a new instance of OperationsClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &OperationsClient{ - host: ep, - pl: pl, + internal: cl, } return client, nil } // NewListPager - Gets a list of SAP HANA management operations. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-02-07-preview -// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +// - 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 { @@ -62,7 +52,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationsClientListResponse{}, err } @@ -77,7 +67,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption // listCreateRequest creates the List request. func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.HanaOnAzure/operations" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/operations_client_example_test.go b/sdk/resourcemanager/hanaonazure/armhanaonazure/operations_client_example_test.go new file mode 100644 index 000000000000..f3a70923263b --- /dev/null +++ b/sdk/resourcemanager/hanaonazure/armhanaonazure/operations_client_example_test.go @@ -0,0 +1,66 @@ +//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 armhanaonazure_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hanaonazure/armhanaonazure" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/HanaOperations_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 := armhanaonazure.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.OperationList = armhanaonazure.OperationList{ + // Value: []*armhanaonazure.Operation{ + // { + // Name: to.Ptr("HanaOp1"), + // Display: &armhanaonazure.Display{ + // Description: to.Ptr("HanaOp1Description"), + // Operation: to.Ptr("HanaOp1OperationName"), + // Origin: to.Ptr("HanaOp1Origin"), + // Provider: to.Ptr("HanaOp1ProviderName"), + // Resource: to.Ptr("HanaOp1ResourceName"), + // }, + // }, + // { + // Name: to.Ptr("HanaOp2"), + // Display: &armhanaonazure.Display{ + // Description: to.Ptr("HanaOp2Description"), + // Operation: to.Ptr("HanaOp2OperationName"), + // Origin: to.Ptr("HanaOp2Origin"), + // Provider: to.Ptr("HanaOp2ProviderName"), + // Resource: to.Ptr("HanaOp2ResourceName"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_providerinstances_client.go b/sdk/resourcemanager/hanaonazure/armhanaonazure/providerinstances_client.go similarity index 84% rename from sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_providerinstances_client.go rename to sdk/resourcemanager/hanaonazure/armhanaonazure/providerinstances_client.go index 20618017fc9a..28f379203a2a 100644 --- a/sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_providerinstances_client.go +++ b/sdk/resourcemanager/hanaonazure/armhanaonazure/providerinstances_client.go @@ -5,6 +5,7 @@ // 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 armhanaonazure @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,32 +24,23 @@ import ( // ProviderInstancesClient contains the methods for the ProviderInstances group. // Don't use this type directly, use NewProviderInstancesClient() instead. type ProviderInstancesClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewProviderInstancesClient creates a new instance of ProviderInstancesClient with the specified values. -// subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of -// the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of +// the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewProviderInstancesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProviderInstancesClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".ProviderInstancesClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &ProviderInstancesClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } @@ -58,34 +48,36 @@ func NewProviderInstancesClient(subscriptionID string, credential azcore.TokenCr // BeginCreate - Creates a provider instance for the specified subscription, resource group, SapMonitor name, and resource // name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-02-07-preview -// resourceGroupName - Name of the resource group. -// sapMonitorName - Name of the SAP monitor resource. -// providerInstanceName - Name of the provider instance. -// providerInstanceParameter - Request body representing a provider instance -// options - ProviderInstancesClientBeginCreateOptions contains the optional parameters for the ProviderInstancesClient.BeginCreate -// method. +// - resourceGroupName - Name of the resource group. +// - sapMonitorName - Name of the SAP monitor resource. +// - providerInstanceName - Name of the provider instance. +// - providerInstanceParameter - Request body representing a provider instance +// - options - ProviderInstancesClientBeginCreateOptions contains the optional parameters for the ProviderInstancesClient.BeginCreate +// method. func (client *ProviderInstancesClient) BeginCreate(ctx context.Context, resourceGroupName string, sapMonitorName string, providerInstanceName string, providerInstanceParameter ProviderInstance, options *ProviderInstancesClientBeginCreateOptions) (*runtime.Poller[ProviderInstancesClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, sapMonitorName, providerInstanceName, providerInstanceParameter, options) if err != nil { return nil, err } - return runtime.NewPoller[ProviderInstancesClientCreateResponse](resp, client.pl, nil) + return runtime.NewPoller[ProviderInstancesClientCreateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ProviderInstancesClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ProviderInstancesClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Creates a provider instance for the specified subscription, resource group, SapMonitor name, and resource name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-02-07-preview func (client *ProviderInstancesClient) create(ctx context.Context, resourceGroupName string, sapMonitorName string, providerInstanceName string, providerInstanceParameter ProviderInstance, options *ProviderInstancesClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, sapMonitorName, providerInstanceName, providerInstanceParameter, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -114,7 +106,7 @@ func (client *ProviderInstancesClient) createCreateRequest(ctx context.Context, return nil, errors.New("parameter providerInstanceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{providerInstanceName}", url.PathEscape(providerInstanceName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -128,33 +120,35 @@ func (client *ProviderInstancesClient) createCreateRequest(ctx context.Context, // BeginDelete - Deletes a provider instance for the specified subscription, resource group, SapMonitor name, and resource // name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-02-07-preview -// resourceGroupName - Name of the resource group. -// sapMonitorName - Name of the SAP monitor resource. -// providerInstanceName - Name of the provider instance. -// options - ProviderInstancesClientBeginDeleteOptions contains the optional parameters for the ProviderInstancesClient.BeginDelete -// method. +// - resourceGroupName - Name of the resource group. +// - sapMonitorName - Name of the SAP monitor resource. +// - providerInstanceName - Name of the provider instance. +// - options - ProviderInstancesClientBeginDeleteOptions contains the optional parameters for the ProviderInstancesClient.BeginDelete +// method. func (client *ProviderInstancesClient) BeginDelete(ctx context.Context, resourceGroupName string, sapMonitorName string, providerInstanceName string, options *ProviderInstancesClientBeginDeleteOptions) (*runtime.Poller[ProviderInstancesClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, sapMonitorName, providerInstanceName, options) if err != nil { return nil, err } - return runtime.NewPoller[ProviderInstancesClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[ProviderInstancesClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[ProviderInstancesClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[ProviderInstancesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a provider instance for the specified subscription, resource group, SapMonitor name, and resource name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-02-07-preview func (client *ProviderInstancesClient) deleteOperation(ctx context.Context, resourceGroupName string, sapMonitorName string, providerInstanceName string, options *ProviderInstancesClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, sapMonitorName, providerInstanceName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -183,7 +177,7 @@ func (client *ProviderInstancesClient) deleteCreateRequest(ctx context.Context, return nil, errors.New("parameter providerInstanceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{providerInstanceName}", url.PathEscape(providerInstanceName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -197,17 +191,18 @@ func (client *ProviderInstancesClient) deleteCreateRequest(ctx context.Context, // Get - Gets properties of a provider instance for the specified subscription, resource group, SapMonitor name, and resource // name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-02-07-preview -// resourceGroupName - Name of the resource group. -// sapMonitorName - Name of the SAP monitor resource. -// providerInstanceName - Name of the provider instance. -// options - ProviderInstancesClientGetOptions contains the optional parameters for the ProviderInstancesClient.Get method. +// - resourceGroupName - Name of the resource group. +// - sapMonitorName - Name of the SAP monitor resource. +// - providerInstanceName - Name of the provider instance. +// - options - ProviderInstancesClientGetOptions contains the optional parameters for the ProviderInstancesClient.Get method. func (client *ProviderInstancesClient) Get(ctx context.Context, resourceGroupName string, sapMonitorName string, providerInstanceName string, options *ProviderInstancesClientGetOptions) (ProviderInstancesClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, sapMonitorName, providerInstanceName, options) if err != nil { return ProviderInstancesClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProviderInstancesClientGetResponse{}, err } @@ -236,7 +231,7 @@ func (client *ProviderInstancesClient) getCreateRequest(ctx context.Context, res return nil, errors.New("parameter providerInstanceName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{providerInstanceName}", url.PathEscape(providerInstanceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -258,11 +253,12 @@ func (client *ProviderInstancesClient) getHandleResponse(resp *http.Response) (P // NewListPager - Gets a list of provider instances in the specified SAP monitor. The operations returns various properties // of each provider instances. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-02-07-preview -// resourceGroupName - Name of the resource group. -// sapMonitorName - Name of the SAP monitor resource. -// options - ProviderInstancesClientListOptions contains the optional parameters for the ProviderInstancesClient.List method. +// - resourceGroupName - Name of the resource group. +// - sapMonitorName - Name of the SAP monitor resource. +// - options - ProviderInstancesClientListOptions contains the optional parameters for the ProviderInstancesClient.NewListPager +// method. func (client *ProviderInstancesClient) NewListPager(resourceGroupName string, sapMonitorName string, options *ProviderInstancesClientListOptions) *runtime.Pager[ProviderInstancesClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ProviderInstancesClientListResponse]{ More: func(page ProviderInstancesClientListResponse) bool { @@ -279,7 +275,7 @@ func (client *ProviderInstancesClient) NewListPager(resourceGroupName string, sa if err != nil { return ProviderInstancesClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return ProviderInstancesClientListResponse{}, err } @@ -306,7 +302,7 @@ func (client *ProviderInstancesClient) listCreateRequest(ctx context.Context, re return nil, errors.New("parameter sapMonitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sapMonitorName}", url.PathEscape(sapMonitorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/providerinstances_client_example_test.go b/sdk/resourcemanager/hanaonazure/armhanaonazure/providerinstances_client_example_test.go new file mode 100644 index 000000000000..ab4df312a11e --- /dev/null +++ b/sdk/resourcemanager/hanaonazure/armhanaonazure/providerinstances_client_example_test.go @@ -0,0 +1,169 @@ +//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 armhanaonazure_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/hanaonazure/armhanaonazure" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/ProviderInstances_List.json +func ExampleProviderInstancesClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armhanaonazure.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewProviderInstancesClient().NewListPager("myResourceGroup", "mySapMonitor", 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.ProviderInstanceListResult = armhanaonazure.ProviderInstanceListResult{ + // Value: []*armhanaonazure.ProviderInstance{ + // { + // Name: to.Ptr("myProviderInstance1"), + // Type: to.Ptr("Microsoft.HanaOnAzure/sapMonitors/providerInstances"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.HanaOnAzure/sapMonitors/mySapMonitor/providerInstances/myProviderInstance1"), + // Properties: &armhanaonazure.ProviderInstanceProperties{ + // Type: to.Ptr("SapHana"), + // Metadata: to.Ptr("{\"key\":\"value\"}"), + // Properties: to.Ptr("{\"hostname\":\"10.0.0.6\",\"dbName\":\"SYSTEMDB\",\"sqlPort\":30013,\"dbUsername\":\"SYSTEM\"}"), + // }, + // }, + // { + // Name: to.Ptr("myProviderInstance2"), + // Type: to.Ptr("Microsoft.HanaOnAzure/sapMonitors/providerInstances"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.HanaOnAzure/sapMonitors/mySapMonitor/providerInstances/myProviderInstance2"), + // Properties: &armhanaonazure.ProviderInstanceProperties{ + // Type: to.Ptr("PrometheusHaCluster"), + // Metadata: to.Ptr("{\"key\":\"value\"}"), + // Properties: to.Ptr("{\"prometheusUrl\":\"http://10.0.0.21:9664/metrics\"}"), + // }, + // }, + // { + // Name: to.Ptr("myProviderInstance2"), + // Type: to.Ptr("Microsoft.HanaOnAzure/sapMonitors/providerInstances"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.HanaOnAzure/sapMonitors/mySapMonitor/providerInstances/myProviderInstance2"), + // Properties: &armhanaonazure.ProviderInstanceProperties{ + // Type: to.Ptr("MsSqlServer"), + // Metadata: to.Ptr("{\"key\":\"value\"}"), + // Properties: to.Ptr("{\"sqlHostname\":\"10.0.0.6\",\"sqlPort\":1433,\"sqlUsername\":\"sqladmin\"}"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/ProviderInstances_Get.json +func ExampleProviderInstancesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armhanaonazure.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewProviderInstancesClient().Get(ctx, "myResourceGroup", "mySapMonitor", "myProviderInstance", 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.ProviderInstance = armhanaonazure.ProviderInstance{ + // Name: to.Ptr("myProviderInstance"), + // Type: to.Ptr("Microsoft.HanaOnAzure/sapMonitors/providerInstances"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.HanaOnAzure/sapMonitors/mySapMonitor/providerInstances/myProviderInstance"), + // Properties: &armhanaonazure.ProviderInstanceProperties{ + // Type: to.Ptr("SapHana"), + // Metadata: to.Ptr("{\"key\":\"value\"}"), + // Properties: to.Ptr("{\"hostname\":\"10.0.0.6\",\"dbName\":\"SYSTEMDB\",\"sqlPort\":30013,\"dbUsername\":\"SYSTEM\"}"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/ProviderInstances_Create.json +func ExampleProviderInstancesClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armhanaonazure.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewProviderInstancesClient().BeginCreate(ctx, "myResourceGroup", "mySapMonitor", "myProviderInstance", armhanaonazure.ProviderInstance{ + Properties: &armhanaonazure.ProviderInstanceProperties{ + Type: to.Ptr("hana"), + Metadata: to.Ptr("{\"key\":\"value\"}"), + Properties: to.Ptr("{\"hostname\":\"10.0.0.6\",\"dbName\":\"SYSTEMDB\",\"sqlPort\":30013,\"dbUsername\":\"SYSTEM\",\"dbPassword\":\"PASSWORD\"}"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ProviderInstance = armhanaonazure.ProviderInstance{ + // Name: to.Ptr("myProviderInstance"), + // Type: to.Ptr("Microsoft.HanaOnAzure/sapMonitors/providerInstances"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.HanaOnAzure/sapMonitors/mySapMonitor/providerInstances/myProviderInstance"), + // Properties: &armhanaonazure.ProviderInstanceProperties{ + // Type: to.Ptr("SapHana"), + // Metadata: to.Ptr("{\"key\":\"value\"}"), + // Properties: to.Ptr("{\"hostname\":\"10.0.0.6\",\"dbName\":\"SYSTEMDB\",\"sqlPort\":30013,\"dbUsername\":\"SYSTEM\"}"), + // ProvisioningState: to.Ptr(armhanaonazure.HanaProvisioningStatesEnumSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/ProviderInstances_Delete.json +func ExampleProviderInstancesClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armhanaonazure.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewProviderInstancesClient().BeginDelete(ctx, "myResourceGroup", "mySapMonitor", "myProviderInstance", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_response_types.go b/sdk/resourcemanager/hanaonazure/armhanaonazure/response_types.go similarity index 85% rename from sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_response_types.go rename to sdk/resourcemanager/hanaonazure/armhanaonazure/response_types.go index 6a2f0526a7e3..47c287785ff4 100644 --- a/sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_response_types.go +++ b/sdk/resourcemanager/hanaonazure/armhanaonazure/response_types.go @@ -5,20 +5,21 @@ // 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 armhanaonazure -// OperationsClientListResponse contains the response from method OperationsClient.List. +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { OperationList } -// ProviderInstancesClientCreateResponse contains the response from method ProviderInstancesClient.Create. +// ProviderInstancesClientCreateResponse contains the response from method ProviderInstancesClient.BeginCreate. type ProviderInstancesClientCreateResponse struct { ProviderInstance } -// ProviderInstancesClientDeleteResponse contains the response from method ProviderInstancesClient.Delete. +// ProviderInstancesClientDeleteResponse contains the response from method ProviderInstancesClient.BeginDelete. type ProviderInstancesClientDeleteResponse struct { // placeholder for future response values } @@ -28,17 +29,17 @@ type ProviderInstancesClientGetResponse struct { ProviderInstance } -// ProviderInstancesClientListResponse contains the response from method ProviderInstancesClient.List. +// ProviderInstancesClientListResponse contains the response from method ProviderInstancesClient.NewListPager. type ProviderInstancesClientListResponse struct { ProviderInstanceListResult } -// SapMonitorsClientCreateResponse contains the response from method SapMonitorsClient.Create. +// SapMonitorsClientCreateResponse contains the response from method SapMonitorsClient.BeginCreate. type SapMonitorsClientCreateResponse struct { SapMonitor } -// SapMonitorsClientDeleteResponse contains the response from method SapMonitorsClient.Delete. +// SapMonitorsClientDeleteResponse contains the response from method SapMonitorsClient.BeginDelete. type SapMonitorsClientDeleteResponse struct { // placeholder for future response values } @@ -48,7 +49,7 @@ type SapMonitorsClientGetResponse struct { SapMonitor } -// SapMonitorsClientListResponse contains the response from method SapMonitorsClient.List. +// SapMonitorsClientListResponse contains the response from method SapMonitorsClient.NewListPager. type SapMonitorsClientListResponse struct { SapMonitorListResult } diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_sapmonitors_client.go b/sdk/resourcemanager/hanaonazure/armhanaonazure/sapmonitors_client.go similarity index 85% rename from sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_sapmonitors_client.go rename to sdk/resourcemanager/hanaonazure/armhanaonazure/sapmonitors_client.go index f668969c35a4..08fb4425d270 100644 --- a/sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_sapmonitors_client.go +++ b/sdk/resourcemanager/hanaonazure/armhanaonazure/sapmonitors_client.go @@ -5,6 +5,7 @@ // 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 armhanaonazure @@ -13,8 +14,6 @@ import ( "errors" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -25,64 +24,57 @@ import ( // SapMonitorsClient contains the methods for the SapMonitors group. // Don't use this type directly, use NewSapMonitorsClient() instead. type SapMonitorsClient struct { - host string + internal *arm.Client subscriptionID string - pl runtime.Pipeline } // NewSapMonitorsClient creates a new instance of SapMonitorsClient with the specified values. -// subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of -// the URI for every service call. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. +// - subscriptionID - Subscription ID which uniquely identify Microsoft Azure subscription. The subscription ID forms part of +// the URI for every service call. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. func NewSapMonitorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SapMonitorsClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + cl, err := arm.NewClient(moduleName+".SapMonitorsClient", moduleVersion, credential, options) if err != nil { return nil, err } client := &SapMonitorsClient{ subscriptionID: subscriptionID, - host: ep, - pl: pl, + internal: cl, } return client, nil } // BeginCreate - Creates a SAP monitor for the specified subscription, resource group, and resource name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-02-07-preview -// resourceGroupName - Name of the resource group. -// sapMonitorName - Name of the SAP monitor resource. -// sapMonitorParameter - Request body representing a SAP Monitor -// options - SapMonitorsClientBeginCreateOptions contains the optional parameters for the SapMonitorsClient.BeginCreate method. +// - resourceGroupName - Name of the resource group. +// - sapMonitorName - Name of the SAP monitor resource. +// - sapMonitorParameter - Request body representing a SAP Monitor +// - options - SapMonitorsClientBeginCreateOptions contains the optional parameters for the SapMonitorsClient.BeginCreate method. func (client *SapMonitorsClient) BeginCreate(ctx context.Context, resourceGroupName string, sapMonitorName string, sapMonitorParameter SapMonitor, options *SapMonitorsClientBeginCreateOptions) (*runtime.Poller[SapMonitorsClientCreateResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.create(ctx, resourceGroupName, sapMonitorName, sapMonitorParameter, options) if err != nil { return nil, err } - return runtime.NewPoller[SapMonitorsClientCreateResponse](resp, client.pl, nil) + return runtime.NewPoller[SapMonitorsClientCreateResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[SapMonitorsClientCreateResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SapMonitorsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Create - Creates a SAP monitor for the specified subscription, resource group, and resource name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-02-07-preview func (client *SapMonitorsClient) create(ctx context.Context, resourceGroupName string, sapMonitorName string, sapMonitorParameter SapMonitor, options *SapMonitorsClientBeginCreateOptions) (*http.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, sapMonitorName, sapMonitorParameter, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -107,7 +99,7 @@ func (client *SapMonitorsClient) createCreateRequest(ctx context.Context, resour return nil, errors.New("parameter sapMonitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sapMonitorName}", url.PathEscape(sapMonitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -120,31 +112,33 @@ func (client *SapMonitorsClient) createCreateRequest(ctx context.Context, resour // BeginDelete - Deletes a SAP monitor with the specified subscription, resource group, and monitor name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-02-07-preview -// resourceGroupName - Name of the resource group. -// sapMonitorName - Name of the SAP monitor resource. -// options - SapMonitorsClientBeginDeleteOptions contains the optional parameters for the SapMonitorsClient.BeginDelete method. +// - resourceGroupName - Name of the resource group. +// - sapMonitorName - Name of the SAP monitor resource. +// - options - SapMonitorsClientBeginDeleteOptions contains the optional parameters for the SapMonitorsClient.BeginDelete method. func (client *SapMonitorsClient) BeginDelete(ctx context.Context, resourceGroupName string, sapMonitorName string, options *SapMonitorsClientBeginDeleteOptions) (*runtime.Poller[SapMonitorsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { resp, err := client.deleteOperation(ctx, resourceGroupName, sapMonitorName, options) if err != nil { return nil, err } - return runtime.NewPoller[SapMonitorsClientDeleteResponse](resp, client.pl, nil) + return runtime.NewPoller[SapMonitorsClientDeleteResponse](resp, client.internal.Pipeline(), nil) } else { - return runtime.NewPollerFromResumeToken[SapMonitorsClientDeleteResponse](options.ResumeToken, client.pl, nil) + return runtime.NewPollerFromResumeToken[SapMonitorsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) } } // Delete - Deletes a SAP monitor with the specified subscription, resource group, and monitor name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-02-07-preview func (client *SapMonitorsClient) deleteOperation(ctx context.Context, resourceGroupName string, sapMonitorName string, options *SapMonitorsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, sapMonitorName, options) if err != nil { return nil, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } @@ -169,7 +163,7 @@ func (client *SapMonitorsClient) deleteCreateRequest(ctx context.Context, resour return nil, errors.New("parameter sapMonitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sapMonitorName}", url.PathEscape(sapMonitorName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -182,16 +176,17 @@ func (client *SapMonitorsClient) deleteCreateRequest(ctx context.Context, resour // Get - Gets properties of a SAP monitor for the specified subscription, resource group, and resource name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-02-07-preview -// resourceGroupName - Name of the resource group. -// sapMonitorName - Name of the SAP monitor resource. -// options - SapMonitorsClientGetOptions contains the optional parameters for the SapMonitorsClient.Get method. +// - resourceGroupName - Name of the resource group. +// - sapMonitorName - Name of the SAP monitor resource. +// - options - SapMonitorsClientGetOptions contains the optional parameters for the SapMonitorsClient.Get method. func (client *SapMonitorsClient) Get(ctx context.Context, resourceGroupName string, sapMonitorName string, options *SapMonitorsClientGetOptions) (SapMonitorsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, sapMonitorName, options) if err != nil { return SapMonitorsClientGetResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SapMonitorsClientGetResponse{}, err } @@ -216,7 +211,7 @@ func (client *SapMonitorsClient) getCreateRequest(ctx context.Context, resourceG return nil, errors.New("parameter sapMonitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sapMonitorName}", url.PathEscape(sapMonitorName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -238,9 +233,9 @@ func (client *SapMonitorsClient) getHandleResponse(resp *http.Response) (SapMoni // NewListPager - Gets a list of SAP monitors in the specified subscription. The operations returns various properties of // each SAP monitor. -// If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-02-07-preview -// options - SapMonitorsClientListOptions contains the optional parameters for the SapMonitorsClient.List method. +// - options - SapMonitorsClientListOptions contains the optional parameters for the SapMonitorsClient.NewListPager method. func (client *SapMonitorsClient) NewListPager(options *SapMonitorsClientListOptions) *runtime.Pager[SapMonitorsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[SapMonitorsClientListResponse]{ More: func(page SapMonitorsClientListResponse) bool { @@ -257,7 +252,7 @@ func (client *SapMonitorsClient) NewListPager(options *SapMonitorsClientListOpti if err != nil { return SapMonitorsClientListResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SapMonitorsClientListResponse{}, err } @@ -276,7 +271,7 @@ func (client *SapMonitorsClient) listCreateRequest(ctx context.Context, options return nil, errors.New("parameter client.subscriptionID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } @@ -298,17 +293,18 @@ func (client *SapMonitorsClient) listHandleResponse(resp *http.Response) (SapMon // Update - Patches the Tags field of a SAP monitor for the specified subscription, resource group, and monitor name. // If the operation fails it returns an *azcore.ResponseError type. +// // Generated from API version 2020-02-07-preview -// resourceGroupName - Name of the resource group. -// sapMonitorName - Name of the SAP monitor resource. -// tagsParameter - Request body that only contains the new Tags field -// options - SapMonitorsClientUpdateOptions contains the optional parameters for the SapMonitorsClient.Update method. +// - resourceGroupName - Name of the resource group. +// - sapMonitorName - Name of the SAP monitor resource. +// - tagsParameter - Request body that only contains the new Tags field +// - options - SapMonitorsClientUpdateOptions contains the optional parameters for the SapMonitorsClient.Update method. func (client *SapMonitorsClient) Update(ctx context.Context, resourceGroupName string, sapMonitorName string, tagsParameter Tags, options *SapMonitorsClientUpdateOptions) (SapMonitorsClientUpdateResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, sapMonitorName, tagsParameter, options) if err != nil { return SapMonitorsClientUpdateResponse{}, err } - resp, err := client.pl.Do(req) + resp, err := client.internal.Pipeline().Do(req) if err != nil { return SapMonitorsClientUpdateResponse{}, err } @@ -333,7 +329,7 @@ func (client *SapMonitorsClient) updateCreateRequest(ctx context.Context, resour return nil, errors.New("parameter sapMonitorName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{sapMonitorName}", url.PathEscape(sapMonitorName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/sapmonitors_client_example_test.go b/sdk/resourcemanager/hanaonazure/armhanaonazure/sapmonitors_client_example_test.go new file mode 100644 index 000000000000..d04e1cc284cd --- /dev/null +++ b/sdk/resourcemanager/hanaonazure/armhanaonazure/sapmonitors_client_example_test.go @@ -0,0 +1,283 @@ +//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 armhanaonazure_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/hanaonazure/armhanaonazure" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/SapMonitors_List.json +func ExampleSapMonitorsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armhanaonazure.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSapMonitorsClient().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.SapMonitorListResult = armhanaonazure.SapMonitorListResult{ + // Value: []*armhanaonazure.SapMonitor{ + // { + // Name: to.Ptr("mySapMonitor1"), + // Type: to.Ptr("Microsoft.HanaOnAzure/sapMonitors"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.HanaOnAzure/sapMonitors/mySapMonitor1"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, + // Properties: &armhanaonazure.SapMonitorProperties{ + // EnableCustomerAnalytics: to.Ptr(true), + // LogAnalyticsWorkspaceArmID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.operationalinsights/workspaces/myWorkspace"), + // LogAnalyticsWorkspaceID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // LogAnalyticsWorkspaceSharedKey: to.Ptr("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000=="), + // ManagedResourceGroupName: to.Ptr("myManagedResourceGroup"), + // MonitorSubnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // ProvisioningState: to.Ptr(armhanaonazure.HanaProvisioningStatesEnumSucceeded), + // SapMonitorCollectorVersion: to.Ptr("v1.0"), + // }, + // }, + // { + // Name: to.Ptr("mySapMonitor2"), + // Type: to.Ptr("Microsoft.HanaOnAzure/sapMonitors"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.HanaOnAzure/sapMonitors/mySapMonitor2"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, + // Properties: &armhanaonazure.SapMonitorProperties{ + // EnableCustomerAnalytics: to.Ptr(true), + // LogAnalyticsWorkspaceArmID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.operationalinsights/workspaces/myWorkspace"), + // LogAnalyticsWorkspaceID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // LogAnalyticsWorkspaceSharedKey: to.Ptr("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000=="), + // ManagedResourceGroupName: to.Ptr("myManagedResourceGroup"), + // MonitorSubnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // ProvisioningState: to.Ptr(armhanaonazure.HanaProvisioningStatesEnumSucceeded), + // SapMonitorCollectorVersion: to.Ptr("v1.0"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/SapMonitors_Get.json +func ExampleSapMonitorsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armhanaonazure.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSapMonitorsClient().Get(ctx, "myResourceGroup", "mySapMonitor", 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.SapMonitor = armhanaonazure.SapMonitor{ + // Name: to.Ptr("mySapMonitor"), + // Type: to.Ptr("Microsoft.HanaOnAzure/sapMonitors"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.HanaOnAzure/sapMonitors/mySapMonitor"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, + // Properties: &armhanaonazure.SapMonitorProperties{ + // EnableCustomerAnalytics: to.Ptr(true), + // LogAnalyticsWorkspaceArmID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.operationalinsights/workspaces/myWorkspace"), + // LogAnalyticsWorkspaceID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // LogAnalyticsWorkspaceSharedKey: to.Ptr("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000=="), + // ManagedResourceGroupName: to.Ptr("myManagedResourceGroup"), + // MonitorSubnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // ProvisioningState: to.Ptr(armhanaonazure.HanaProvisioningStatesEnumSucceeded), + // SapMonitorCollectorVersion: to.Ptr("v1.0"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/SapMonitors_Create.json +func ExampleSapMonitorsClient_BeginCreate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armhanaonazure.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewSapMonitorsClient().BeginCreate(ctx, "myResourceGroup", "mySapMonitor", armhanaonazure.SapMonitor{ + Location: to.Ptr("westus"), + Tags: map[string]*string{ + "key": to.Ptr("value"), + }, + Properties: &armhanaonazure.SapMonitorProperties{ + EnableCustomerAnalytics: to.Ptr(true), + LogAnalyticsWorkspaceArmID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.operationalinsights/workspaces/myWorkspace"), + LogAnalyticsWorkspaceID: to.Ptr("00000000-0000-0000-0000-000000000000"), + LogAnalyticsWorkspaceSharedKey: to.Ptr("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000=="), + MonitorSubnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SapMonitor = armhanaonazure.SapMonitor{ + // Name: to.Ptr("myHanaInstance"), + // Type: to.Ptr("Microsoft.HanaOnAzure/hanaInstances"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.HanaOnAzure/hanaInstances/myHanaInstance"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, + // Properties: &armhanaonazure.SapMonitorProperties{ + // EnableCustomerAnalytics: to.Ptr(true), + // LogAnalyticsWorkspaceArmID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.operationalinsights/workspaces/myWorkspace"), + // LogAnalyticsWorkspaceID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // LogAnalyticsWorkspaceSharedKey: to.Ptr("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000=="), + // ManagedResourceGroupName: to.Ptr("myManagedResourceGroup"), + // MonitorSubnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // ProvisioningState: to.Ptr(armhanaonazure.HanaProvisioningStatesEnumSucceeded), + // SapMonitorCollectorVersion: to.Ptr("v1.0"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/SapMonitors_Delete.json +func ExampleSapMonitorsClient_BeginDelete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armhanaonazure.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewSapMonitorsClient().BeginDelete(ctx, "myResourceGroup", "mySapMonitor", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/SapMonitors_PatchTags_Delete.json +func ExampleSapMonitorsClient_Update_deleteTagsFieldOfASapMonitor() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armhanaonazure.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSapMonitorsClient().Update(ctx, "myResourceGroup", "mySapMonitor", armhanaonazure.Tags{ + Tags: map[string]*string{}, + }, 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.SapMonitor = armhanaonazure.SapMonitor{ + // Name: to.Ptr("mySapMonitor"), + // Type: to.Ptr("Microsoft.HanaOnAzure/sapMonitors"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.HanaOnAzure/sapMonitors/mySapMonitor"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // }, + // Properties: &armhanaonazure.SapMonitorProperties{ + // EnableCustomerAnalytics: to.Ptr(true), + // LogAnalyticsWorkspaceArmID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.operationalinsights/workspaces/myWorkspace"), + // LogAnalyticsWorkspaceID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // LogAnalyticsWorkspaceSharedKey: to.Ptr("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000=="), + // ManagedResourceGroupName: to.Ptr("myManagedResourceGroup"), + // MonitorSubnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // ProvisioningState: to.Ptr(armhanaonazure.HanaProvisioningStatesEnumSucceeded), + // SapMonitorCollectorVersion: to.Ptr("v1.0"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/SapMonitors_PatchTags.json +func ExampleSapMonitorsClient_Update_updateTagsFieldOfASapMonitor() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armhanaonazure.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSapMonitorsClient().Update(ctx, "myResourceGroup", "mySapMonitor", armhanaonazure.Tags{ + Tags: map[string]*string{ + "testkey": to.Ptr("testvalue"), + }, + }, 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.SapMonitor = armhanaonazure.SapMonitor{ + // Name: to.Ptr("mySapMonitor"), + // Type: to.Ptr("Microsoft.HanaOnAzure/sapMonitors"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.HanaOnAzure/sapMonitors/mySapMonitor"), + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "testkey": to.Ptr("testvalue"), + // }, + // Properties: &armhanaonazure.SapMonitorProperties{ + // EnableCustomerAnalytics: to.Ptr(true), + // LogAnalyticsWorkspaceArmID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.operationalinsights/workspaces/myWorkspace"), + // LogAnalyticsWorkspaceID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // LogAnalyticsWorkspaceSharedKey: to.Ptr("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000=="), + // ManagedResourceGroupName: to.Ptr("myManagedResourceGroup"), + // MonitorSubnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + // ProvisioningState: to.Ptr(armhanaonazure.HanaProvisioningStatesEnumSucceeded), + // SapMonitorCollectorVersion: to.Ptr("v1.0"), + // }, + // } +} diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/hanaonazure/armhanaonazure/ze_generated_example_operations_client_test.go deleted file mode 100644 index 254ae00499d6..000000000000 --- a/sdk/resourcemanager/hanaonazure/armhanaonazure/ze_generated_example_operations_client_test.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armhanaonazure_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hanaonazure/armhanaonazure" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/HanaOperations_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() - client, err := armhanaonazure.NewOperationsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/ze_generated_example_providerinstances_client_test.go b/sdk/resourcemanager/hanaonazure/armhanaonazure/ze_generated_example_providerinstances_client_test.go deleted file mode 100644 index 514eddfb8cca..000000000000 --- a/sdk/resourcemanager/hanaonazure/armhanaonazure/ze_generated_example_providerinstances_client_test.go +++ /dev/null @@ -1,126 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armhanaonazure_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/hanaonazure/armhanaonazure" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/ProviderInstances_List.json -func ExampleProviderInstancesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armhanaonazure.NewProviderInstancesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("myResourceGroup", - "mySapMonitor", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/ProviderInstances_Get.json -func ExampleProviderInstancesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armhanaonazure.NewProviderInstancesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "myResourceGroup", - "mySapMonitor", - "myProviderInstance", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/ProviderInstances_Create.json -func ExampleProviderInstancesClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armhanaonazure.NewProviderInstancesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, - "myResourceGroup", - "mySapMonitor", - "myProviderInstance", - armhanaonazure.ProviderInstance{ - Properties: &armhanaonazure.ProviderInstanceProperties{ - Type: to.Ptr("hana"), - Metadata: to.Ptr("{\"key\":\"value\"}"), - Properties: to.Ptr("{\"hostname\":\"10.0.0.6\",\"dbName\":\"SYSTEMDB\",\"sqlPort\":30013,\"dbUsername\":\"SYSTEM\",\"dbPassword\":\"PASSWORD\"}"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/ProviderInstances_Delete.json -func ExampleProviderInstancesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armhanaonazure.NewProviderInstancesClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "myResourceGroup", - "mySapMonitor", - "myProviderInstance", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/ze_generated_example_sapmonitors_client_test.go b/sdk/resourcemanager/hanaonazure/armhanaonazure/ze_generated_example_sapmonitors_client_test.go deleted file mode 100644 index 59cd856b1e3f..000000000000 --- a/sdk/resourcemanager/hanaonazure/armhanaonazure/ze_generated_example_sapmonitors_client_test.go +++ /dev/null @@ -1,152 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armhanaonazure_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/hanaonazure/armhanaonazure" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/SapMonitors_List.json -func ExampleSapMonitorsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armhanaonazure.NewSapMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/SapMonitors_Get.json -func ExampleSapMonitorsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armhanaonazure.NewSapMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "myResourceGroup", - "mySapMonitor", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/SapMonitors_Create.json -func ExampleSapMonitorsClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armhanaonazure.NewSapMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginCreate(ctx, - "myResourceGroup", - "mySapMonitor", - armhanaonazure.SapMonitor{ - Location: to.Ptr("westus"), - Tags: map[string]*string{ - "key": to.Ptr("value"), - }, - Properties: &armhanaonazure.SapMonitorProperties{ - EnableCustomerAnalytics: to.Ptr(true), - LogAnalyticsWorkspaceArmID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.operationalinsights/workspaces/myWorkspace"), - LogAnalyticsWorkspaceID: to.Ptr("00000000-0000-0000-0000-000000000000"), - LogAnalyticsWorkspaceSharedKey: to.Ptr("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000=="), - MonitorSubnet: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), - }, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/SapMonitors_Delete.json -func ExampleSapMonitorsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armhanaonazure.NewSapMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.BeginDelete(ctx, - "myResourceGroup", - "mySapMonitor", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hanaonazure/resource-manager/Microsoft.HanaOnAzure/preview/2020-02-07-preview/examples/SapMonitors_PatchTags_Delete.json -func ExampleSapMonitorsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armhanaonazure.NewSapMonitorsClient("00000000-0000-0000-0000-000000000000", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Update(ctx, - "myResourceGroup", - "mySapMonitor", - armhanaonazure.Tags{ - Tags: map[string]*string{}, - }, - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_models_serde.go b/sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_models_serde.go deleted file mode 100644 index 0de85902d5f2..000000000000 --- a/sdk/resourcemanager/hanaonazure/armhanaonazure/zz_generated_models_serde.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. - -package armhanaonazure - -import ( - "encoding/json" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type SapMonitor. -func (s SapMonitor) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", s.ID) - populate(objectMap, "location", s.Location) - populate(objectMap, "name", s.Name) - populate(objectMap, "properties", s.Properties) - populate(objectMap, "tags", s.Tags) - populate(objectMap, "type", s.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type Tags. -func (t Tags) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "tags", t.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type TrackedResource. -func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) - populate(objectMap, "name", t.Name) - populate(objectMap, "tags", t.Tags) - populate(objectMap, "type", t.Type) - return json.Marshal(objectMap) -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -}