diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/CHANGELOG.md b/sdk/resourcemanager/loadtestservice/armloadtestservice/CHANGELOG.md index e049950db602..ef7442a9b129 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/CHANGELOG.md +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/CHANGELOG.md @@ -1,5 +1,36 @@ # Release History +## 1.0.0 (2022-10-13) +### Features Added + +- New function `NewQuotasClient(string, azcore.TokenCredential, *arm.ClientOptions) (*QuotasClient, error)` +- New function `*QuotasClient.CheckAvailability(context.Context, string, string, QuotaBucketRequest, *QuotasClientCheckAvailabilityOptions) (QuotasClientCheckAvailabilityResponse, error)` +- New function `*QuotasClient.NewListPager(string, *QuotasClientListOptions) *runtime.Pager[QuotasClientListResponse]` +- New function `*LoadTestsClient.NewListOutboundNetworkDependenciesEndpointsPager(string, string, *LoadTestsClientListOutboundNetworkDependenciesEndpointsOptions) *runtime.Pager[LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse]` +- New function `*QuotasClient.Get(context.Context, string, string, *QuotasClientGetOptions) (QuotasClientGetResponse, error)` +- New struct `CheckQuotaAvailabilityResponse` +- New struct `CheckQuotaAvailabilityResponseProperties` +- New struct `EndpointDependency` +- New struct `EndpointDetail` +- New struct `LoadTestsClientListOutboundNetworkDependenciesEndpointsOptions` +- New struct `LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse` +- New struct `OutboundEnvironmentEndpoint` +- New struct `OutboundEnvironmentEndpointCollection` +- New struct `QuotaBucketRequest` +- New struct `QuotaBucketRequestProperties` +- New struct `QuotaBucketRequestPropertiesDimensions` +- New struct `QuotaResource` +- New struct `QuotaResourceList` +- New struct `QuotaResourceProperties` +- New struct `QuotasClient` +- New struct `QuotasClientCheckAvailabilityOptions` +- New struct `QuotasClientCheckAvailabilityResponse` +- New struct `QuotasClientGetOptions` +- New struct `QuotasClientGetResponse` +- New struct `QuotasClientListOptions` +- New struct `QuotasClientListResponse` + + ## 0.5.0 (2022-05-18) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/loadtestservice/armloadtestservice` 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/loadtestservice/armloadtestservice/autorest.md b/sdk/resourcemanager/loadtestservice/armloadtestservice/autorest.md index 467f5eab7af9..067489177a91 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/autorest.md +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/loadtestservice/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/loadtestservice/resource-manager/readme.go.md +- https://github.com/Azure/azure-rest-api-specs/blob/c71a66dab813061f1d09982c2748a09317fe0860/specification/loadtestservice/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/c71a66dab813061f1d09982c2748a09317fe0860/specification/loadtestservice/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.5.0 +module-version: 1.0.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_constants.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/constants.go similarity index 97% rename from sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_constants.go rename to sdk/resourcemanager/loadtestservice/armloadtestservice/constants.go index af649e32f312..e1df88a66a2d 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_constants.go +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/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 armloadtestservice const ( moduleName = "armloadtestservice" - moduleVersion = "v0.5.0" + moduleVersion = "v1.0.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. @@ -86,7 +87,7 @@ func PossibleOriginValues() []Origin { } } -// ResourceState - Load Test resources provisioning states. +// ResourceState - Resources provisioning states. type ResourceState string const ( diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/go.mod b/sdk/resourcemanager/loadtestservice/armloadtestservice/go.mod index dd05deab9d1f..17e60301ed10 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/go.mod +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/go.mod @@ -4,12 +4,12 @@ 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/azidentity v1.1.0 ) 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/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/kylelemons/godebug v1.1.0 // indirect diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/go.sum b/sdk/resourcemanager/loadtestservice/armloadtestservice/go.sum index ed5b814680ee..8828b17b1853 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/go.sum +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/go.sum @@ -1,11 +1,11 @@ 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/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.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/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/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= diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_loadtests_client.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/loadtests_client.go similarity index 80% rename from sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_loadtests_client.go rename to sdk/resourcemanager/loadtestservice/armloadtestservice/loadtests_client.go index f1fe8e6f1963..03b06ae441fc 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_loadtests_client.go +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/loadtests_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 armloadtestservice @@ -56,9 +57,9 @@ func NewLoadTestsClient(subscriptionID string, credential azcore.TokenCredential // BeginCreateOrUpdate - Create or update LoadTest resource. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-04-15-preview +// Generated from API version 2022-12-01 // resourceGroupName - The name of the resource group. The name is case insensitive. -// loadTestName - Load Test resource name. +// loadTestName - Load Test name. // loadTestResource - LoadTest resource data // options - LoadTestsClientBeginCreateOrUpdateOptions contains the optional parameters for the LoadTestsClient.BeginCreateOrUpdate // method. @@ -78,7 +79,7 @@ func (client *LoadTestsClient) BeginCreateOrUpdate(ctx context.Context, resource // CreateOrUpdate - Create or update LoadTest resource. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-04-15-preview +// Generated from API version 2022-12-01 func (client *LoadTestsClient) createOrUpdate(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResource LoadTestResource, options *LoadTestsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, loadTestName, loadTestResource, options) if err != nil { @@ -114,7 +115,7 @@ func (client *LoadTestsClient) createOrUpdateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-04-15-preview") + reqQP.Set("api-version", "2022-12-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, loadTestResource) @@ -122,9 +123,9 @@ func (client *LoadTestsClient) createOrUpdateCreateRequest(ctx context.Context, // BeginDelete - Delete a LoadTest resource. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-04-15-preview +// Generated from API version 2022-12-01 // resourceGroupName - The name of the resource group. The name is case insensitive. -// loadTestName - Load Test resource name. +// loadTestName - Load Test name. // options - LoadTestsClientBeginDeleteOptions contains the optional parameters for the LoadTestsClient.BeginDelete method. func (client *LoadTestsClient) BeginDelete(ctx context.Context, resourceGroupName string, loadTestName string, options *LoadTestsClientBeginDeleteOptions) (*runtime.Poller[LoadTestsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { @@ -142,7 +143,7 @@ func (client *LoadTestsClient) BeginDelete(ctx context.Context, resourceGroupNam // Delete - Delete a LoadTest resource. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-04-15-preview +// Generated from API version 2022-12-01 func (client *LoadTestsClient) deleteOperation(ctx context.Context, resourceGroupName string, loadTestName string, options *LoadTestsClientBeginDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, loadTestName, options) if err != nil { @@ -178,7 +179,7 @@ func (client *LoadTestsClient) deleteCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-04-15-preview") + reqQP.Set("api-version", "2022-12-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -186,9 +187,9 @@ func (client *LoadTestsClient) deleteCreateRequest(ctx context.Context, resource // Get - Get a LoadTest resource. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-04-15-preview +// Generated from API version 2022-12-01 // resourceGroupName - The name of the resource group. The name is case insensitive. -// loadTestName - Load Test resource name. +// loadTestName - Load Test name. // options - LoadTestsClientGetOptions contains the optional parameters for the LoadTestsClient.Get method. func (client *LoadTestsClient) Get(ctx context.Context, resourceGroupName string, loadTestName string, options *LoadTestsClientGetOptions) (LoadTestsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, loadTestName, options) @@ -225,7 +226,7 @@ func (client *LoadTestsClient) getCreateRequest(ctx context.Context, resourceGro return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-04-15-preview") + reqQP.Set("api-version", "2022-12-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -241,8 +242,7 @@ func (client *LoadTestsClient) getHandleResponse(resp *http.Response) (LoadTests } // NewListByResourceGroupPager - Lists loadtest resources in a resource group. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-04-15-preview +// Generated from API version 2022-12-01 // resourceGroupName - The name of the resource group. The name is case insensitive. // options - LoadTestsClientListByResourceGroupOptions contains the optional parameters for the LoadTestsClient.ListByResourceGroup // method. @@ -290,7 +290,7 @@ func (client *LoadTestsClient) listByResourceGroupCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-04-15-preview") + reqQP.Set("api-version", "2022-12-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -306,8 +306,7 @@ func (client *LoadTestsClient) listByResourceGroupHandleResponse(resp *http.Resp } // NewListBySubscriptionPager - Lists loadtests resources in a subscription. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-04-15-preview +// Generated from API version 2022-12-01 // options - LoadTestsClientListBySubscriptionOptions contains the optional parameters for the LoadTestsClient.ListBySubscription // method. func (client *LoadTestsClient) NewListBySubscriptionPager(options *LoadTestsClientListBySubscriptionOptions) *runtime.Pager[LoadTestsClientListBySubscriptionResponse] { @@ -350,7 +349,7 @@ func (client *LoadTestsClient) listBySubscriptionCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-04-15-preview") + reqQP.Set("api-version", "2022-12-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -365,11 +364,80 @@ func (client *LoadTestsClient) listBySubscriptionHandleResponse(resp *http.Respo return result, nil } +// NewListOutboundNetworkDependenciesEndpointsPager - Lists the endpoints that agents may call as part of load testing. +// Generated from API version 2022-12-01 +// resourceGroupName - The name of the resource group. The name is case insensitive. +// loadTestName - Load Test name. +// options - LoadTestsClientListOutboundNetworkDependenciesEndpointsOptions contains the optional parameters for the LoadTestsClient.ListOutboundNetworkDependenciesEndpoints +// method. +func (client *LoadTestsClient) NewListOutboundNetworkDependenciesEndpointsPager(resourceGroupName string, loadTestName string, options *LoadTestsClientListOutboundNetworkDependenciesEndpointsOptions) *runtime.Pager[LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse] { + return runtime.NewPager(runtime.PagingHandler[LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse]{ + More: func(page LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse) (LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listOutboundNetworkDependenciesEndpointsCreateRequest(ctx, resourceGroupName, loadTestName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse{}, runtime.NewResponseError(resp) + } + return client.listOutboundNetworkDependenciesEndpointsHandleResponse(resp) + }, + }) +} + +// listOutboundNetworkDependenciesEndpointsCreateRequest creates the ListOutboundNetworkDependenciesEndpoints request. +func (client *LoadTestsClient) listOutboundNetworkDependenciesEndpointsCreateRequest(ctx context.Context, resourceGroupName string, loadTestName string, options *LoadTestsClientListOutboundNetworkDependenciesEndpointsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests/{loadTestName}/outboundNetworkDependenciesEndpoints" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if loadTestName == "" { + return nil, errors.New("parameter loadTestName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{loadTestName}", url.PathEscape(loadTestName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listOutboundNetworkDependenciesEndpointsHandleResponse handles the ListOutboundNetworkDependenciesEndpoints response. +func (client *LoadTestsClient) listOutboundNetworkDependenciesEndpointsHandleResponse(resp *http.Response) (LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse, error) { + result := LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OutboundEnvironmentEndpointCollection); err != nil { + return LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse{}, err + } + return result, nil +} + // BeginUpdate - Update a loadtest resource. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-04-15-preview +// Generated from API version 2022-12-01 // resourceGroupName - The name of the resource group. The name is case insensitive. -// loadTestName - Load Test resource name. +// loadTestName - Load Test name. // loadTestResourcePatchRequestBody - LoadTest resource update data // options - LoadTestsClientBeginUpdateOptions contains the optional parameters for the LoadTestsClient.BeginUpdate method. func (client *LoadTestsClient) BeginUpdate(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResourcePatchRequestBody LoadTestResourcePatchRequestBody, options *LoadTestsClientBeginUpdateOptions) (*runtime.Poller[LoadTestsClientUpdateResponse], error) { @@ -388,7 +456,7 @@ func (client *LoadTestsClient) BeginUpdate(ctx context.Context, resourceGroupNam // Update - Update a loadtest resource. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-04-15-preview +// Generated from API version 2022-12-01 func (client *LoadTestsClient) update(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResourcePatchRequestBody LoadTestResourcePatchRequestBody, options *LoadTestsClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, loadTestName, loadTestResourcePatchRequestBody, options) if err != nil { @@ -424,7 +492,7 @@ func (client *LoadTestsClient) updateCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-04-15-preview") + reqQP.Set("api-version", "2022-12-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, runtime.MarshalAsJSON(req, loadTestResourcePatchRequestBody) diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/ze_generated_example_loadtests_client_test.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/loadtests_client_example_test.go similarity index 56% rename from sdk/resourcemanager/loadtestservice/armloadtestservice/ze_generated_example_loadtests_client_test.go rename to sdk/resourcemanager/loadtestservice/armloadtestservice/loadtests_client_example_test.go index eb525ff67d6f..9bd86e91d80c 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/ze_generated_example_loadtests_client_test.go +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/loadtests_client_example_test.go @@ -17,7 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/loadtestservice/armloadtestservice" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2022-04-15-preview/examples/LoadTests_ListBySubscription.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListBySubscription.json func ExampleLoadTestsClient_NewListBySubscriptionPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -41,7 +41,7 @@ func ExampleLoadTestsClient_NewListBySubscriptionPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2022-04-15-preview/examples/LoadTests_ListByResourceGroup.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListByResourceGroup.json func ExampleLoadTestsClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -52,8 +52,7 @@ func ExampleLoadTestsClient_NewListByResourceGroupPager() { if err != nil { log.Fatalf("failed to create client: %v", err) } - pager := client.NewListByResourceGroupPager("dummyrg", - nil) + pager := client.NewListByResourceGroupPager("dummyrg", nil) for pager.More() { nextResult, err := pager.NextPage(ctx) if err != nil { @@ -66,7 +65,7 @@ func ExampleLoadTestsClient_NewListByResourceGroupPager() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2022-04-15-preview/examples/LoadTests_Get.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Get.json func ExampleLoadTestsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -77,10 +76,7 @@ func ExampleLoadTestsClient_Get() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := client.Get(ctx, - "dummyrg", - "myLoadTest", - nil) + res, err := client.Get(ctx, "dummyrg", "myLoadTest", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -88,7 +84,7 @@ func ExampleLoadTestsClient_Get() { _ = res } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2022-04-15-preview/examples/LoadTests_CreateOrUpdate.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_CreateOrUpdate.json func ExampleLoadTestsClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -99,32 +95,28 @@ func ExampleLoadTestsClient_BeginCreateOrUpdate() { if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginCreateOrUpdate(ctx, - "dummyrg", - "myLoadTest", - armloadtestservice.LoadTestResource{ - Location: to.Ptr("westus"), - Tags: map[string]*string{ - "Team": to.Ptr("Dev Exp"), - }, - Identity: &armloadtestservice.ManagedServiceIdentity{ - Type: to.Ptr(armloadtestservice.ManagedServiceIdentityTypeSystemAssignedUserAssigned), - UserAssignedIdentities: map[string]*armloadtestservice.UserAssignedIdentity{ - "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {}, - }, + poller, err := client.BeginCreateOrUpdate(ctx, "dummyrg", "myLoadTest", armloadtestservice.LoadTestResource{ + Location: to.Ptr("westus"), + Tags: map[string]*string{ + "Team": to.Ptr("Dev Exp"), + }, + Identity: &armloadtestservice.ManagedServiceIdentity{ + Type: to.Ptr(armloadtestservice.ManagedServiceIdentityTypeSystemAssignedUserAssigned), + UserAssignedIdentities: map[string]*armloadtestservice.UserAssignedIdentity{ + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {}, }, - Properties: &armloadtestservice.LoadTestProperties{ - Description: to.Ptr("This is new load test resource"), - Encryption: &armloadtestservice.EncryptionProperties{ - Identity: &armloadtestservice.EncryptionPropertiesIdentity{ - Type: to.Ptr(armloadtestservice.TypeUserAssigned), - ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1"), - }, - KeyURL: to.Ptr("https://dummy.vault.azure.net/keys/dummykey1"), + }, + Properties: &armloadtestservice.LoadTestProperties{ + Description: to.Ptr("This is new load test resource"), + Encryption: &armloadtestservice.EncryptionProperties{ + Identity: &armloadtestservice.EncryptionPropertiesIdentity{ + Type: to.Ptr(armloadtestservice.TypeUserAssigned), + ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1"), }, + KeyURL: to.Ptr("https://dummy.vault.azure.net/keys/dummykey1"), }, }, - nil) + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -136,7 +128,7 @@ func ExampleLoadTestsClient_BeginCreateOrUpdate() { _ = res } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2022-04-15-preview/examples/LoadTests_Update.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Update.json func ExampleLoadTestsClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -147,31 +139,27 @@ func ExampleLoadTestsClient_BeginUpdate() { if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginUpdate(ctx, - "dummyrg", - "myLoadTest", - armloadtestservice.LoadTestResourcePatchRequestBody{ - Identity: &armloadtestservice.ManagedServiceIdentity{ - Type: to.Ptr(armloadtestservice.ManagedServiceIdentityTypeSystemAssignedUserAssigned), - UserAssignedIdentities: map[string]*armloadtestservice.UserAssignedIdentity{ - "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {}, - }, + poller, err := client.BeginUpdate(ctx, "dummyrg", "myLoadTest", armloadtestservice.LoadTestResourcePatchRequestBody{ + Identity: &armloadtestservice.ManagedServiceIdentity{ + Type: to.Ptr(armloadtestservice.ManagedServiceIdentityTypeSystemAssignedUserAssigned), + UserAssignedIdentities: map[string]*armloadtestservice.UserAssignedIdentity{ + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {}, }, - Properties: &armloadtestservice.LoadTestResourcePatchRequestBodyProperties{ - Description: to.Ptr("This is new load test resource"), - Encryption: &armloadtestservice.EncryptionProperties{ - Identity: &armloadtestservice.EncryptionPropertiesIdentity{ - Type: to.Ptr(armloadtestservice.TypeSystemAssigned), - }, - KeyURL: to.Ptr("https://dummy.vault.azure.net/keys/dummykey1"), + }, + Properties: &armloadtestservice.LoadTestResourcePatchRequestBodyProperties{ + Description: to.Ptr("This is new load test resource"), + Encryption: &armloadtestservice.EncryptionProperties{ + Identity: &armloadtestservice.EncryptionPropertiesIdentity{ + Type: to.Ptr(armloadtestservice.TypeSystemAssigned), }, - }, - Tags: map[string]interface{}{ - "Division": "LT", - "Team": "Dev Exp", + KeyURL: to.Ptr("https://dummy.vault.azure.net/keys/dummykey1"), }, }, - nil) + Tags: map[string]interface{}{ + "Division": "LT", + "Team": "Dev Exp", + }, + }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -183,7 +171,7 @@ func ExampleLoadTestsClient_BeginUpdate() { _ = res } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2022-04-15-preview/examples/LoadTests_Delete.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Delete.json func ExampleLoadTestsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -194,10 +182,7 @@ func ExampleLoadTestsClient_BeginDelete() { if err != nil { log.Fatalf("failed to create client: %v", err) } - poller, err := client.BeginDelete(ctx, - "dummyrg", - "myLoadTest", - nil) + poller, err := client.BeginDelete(ctx, "dummyrg", "myLoadTest", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -206,3 +191,27 @@ func ExampleLoadTestsClient_BeginDelete() { log.Fatalf("failed to pull the result: %v", err) } } + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListOutboundNetworkDependenciesEndpoints.json +func ExampleLoadTestsClient_NewListOutboundNetworkDependenciesEndpointsPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armloadtestservice.NewLoadTestsClient("subid", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListOutboundNetworkDependenciesEndpointsPager("default-azureloadtest-japaneast", "sampleloadtest", 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/loadtestservice/armloadtestservice/zz_generated_models.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/models.go similarity index 64% rename from sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_models.go rename to sdk/resourcemanager/loadtestservice/armloadtestservice/models.go index 335bd41c1d18..2fa78f96ec11 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_models.go +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/models.go @@ -5,11 +5,39 @@ // 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 armloadtestservice import "time" +// CheckQuotaAvailabilityResponse - Check quota availability response object. +type CheckQuotaAvailabilityResponse struct { + // Check quota availability response properties. + Properties *CheckQuotaAvailabilityResponseProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// CheckQuotaAvailabilityResponseProperties - Check quota availability response properties. +type CheckQuotaAvailabilityResponseProperties struct { + // Message indicating additional details to add to quota support request. + AvailabilityStatus *string `json:"availabilityStatus,omitempty"` + + // True/False indicating whether the quota request be granted based on availability. + IsAvailable *bool `json:"isAvailable,omitempty"` +} + // EncryptionProperties - Key and identity details for Customer Managed Key encryption of load test resource type EncryptionProperties struct { // All identity configuration for Customer-managed key settings defining which identity should be used to auth to Key Vault. @@ -31,6 +59,24 @@ type EncryptionPropertiesIdentity struct { Type *Type `json:"type,omitempty"` } +// EndpointDependency - A domain name and connection details used to access a dependency. +type EndpointDependency struct { + // READ-ONLY; Human-readable supplemental information about the dependency and when it is applicable. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The domain name of the dependency. Domain names may be fully qualified or may contain a * wildcard. + DomainName *string `json:"domainName,omitempty" azure:"ro"` + + // READ-ONLY; The list of connection details for this endpoint. + EndpointDetails []*EndpointDetail `json:"endpointDetails,omitempty" azure:"ro"` +} + +// EndpointDetail - Details about the connection between the Batch service and the endpoint. +type EndpointDetail struct { + // READ-ONLY; The port an endpoint is connected to. + Port *int32 `json:"port,omitempty" azure:"ro"` +} + // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. @@ -172,6 +218,12 @@ type LoadTestsClientListBySubscriptionOptions struct { // placeholder for future optional parameters } +// LoadTestsClientListOutboundNetworkDependenciesEndpointsOptions contains the optional parameters for the LoadTestsClient.ListOutboundNetworkDependenciesEndpoints +// method. +type LoadTestsClientListOutboundNetworkDependenciesEndpointsOptions struct { + // placeholder for future optional parameters +} + // ManagedServiceIdentity - Managed service identity (system assigned and/or user assigned identities) type ManagedServiceIdentity struct { // REQUIRED; Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). @@ -246,6 +298,121 @@ type OperationsClientListOptions struct { // placeholder for future optional parameters } +// OutboundEnvironmentEndpoint - A collection of related endpoints from the same service for which the Batch service requires +// outbound access. +type OutboundEnvironmentEndpoint struct { + // READ-ONLY; The type of service that Azure Load Testing connects to. + Category *string `json:"category,omitempty" azure:"ro"` + + // READ-ONLY; The endpoints for this service to which the Batch service makes outbound calls. + Endpoints []*EndpointDependency `json:"endpoints,omitempty" azure:"ro"` +} + +// OutboundEnvironmentEndpointCollection - Values returned by the List operation. +type OutboundEnvironmentEndpointCollection struct { + // The continuation token. + NextLink *string `json:"nextLink,omitempty"` + + // READ-ONLY; The collection of outbound network dependency endpoints returned by the listing operation. + Value []*OutboundEnvironmentEndpoint `json:"value,omitempty" azure:"ro"` +} + +// QuotaBucketRequest - Request object of new quota for a quota bucket. +type QuotaBucketRequest struct { + // New quota request request properties. + Properties *QuotaBucketRequestProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// QuotaBucketRequestProperties - New quota request request properties. +type QuotaBucketRequestProperties struct { + // Current quota limit of the quota bucket. + CurrentQuota *int32 `json:"currentQuota,omitempty"` + + // Current quota usage of the quota bucket. + CurrentUsage *int32 `json:"currentUsage,omitempty"` + + // Dimensions for new quota request. + Dimensions *QuotaBucketRequestPropertiesDimensions `json:"dimensions,omitempty"` + + // New quota limit of the quota bucket. + NewQuota *int32 `json:"newQuota,omitempty"` +} + +// QuotaBucketRequestPropertiesDimensions - Dimensions for new quota request. +type QuotaBucketRequestPropertiesDimensions struct { + // Location dimension for new quota request of the quota bucket. + Location *string `json:"location,omitempty"` + + // Subscription Id dimension for new quota request of the quota bucket. + SubscriptionID *string `json:"subscriptionId,omitempty"` +} + +// QuotaResource - Quota bucket details object. +type QuotaResource struct { + // Quota bucket resource properties. + Properties *QuotaResourceProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// QuotaResourceList - List of quota bucket objects. It contains a URL link to get the next set of results. +type QuotaResourceList struct { + // READ-ONLY; URL to get the next set of quota bucket objects results (if there are any). + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of quota bucket objects provided by the loadtestservice. + Value []*QuotaResource `json:"value,omitempty" azure:"ro"` +} + +// QuotaResourceProperties - Quota bucket resource properties. +type QuotaResourceProperties struct { + // Current quota limit of the quota bucket. + Limit *int32 `json:"limit,omitempty"` + + // Current quota usage of the quota bucket. + Usage *int32 `json:"usage,omitempty"` + + // READ-ONLY; Resource provisioning state. + ProvisioningState *ResourceState `json:"provisioningState,omitempty" azure:"ro"` +} + +// QuotasClientCheckAvailabilityOptions contains the optional parameters for the QuotasClient.CheckAvailability method. +type QuotasClientCheckAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// QuotasClientGetOptions contains the optional parameters for the QuotasClient.Get method. +type QuotasClientGetOptions struct { + // placeholder for future optional parameters +} + +// QuotasClientListOptions contains the optional parameters for the QuotasClient.List method. +type QuotasClientListOptions struct { + // placeholder for future optional parameters +} + // Resource - Common fields that are returned in the response for all Azure Resource Manager resources type Resource struct { // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/models_serde.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/models_serde.go new file mode 100644 index 000000000000..71f2a902669d --- /dev/null +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/models_serde.go @@ -0,0 +1,1127 @@ +//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 armloadtestservice + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type CheckQuotaAvailabilityResponse. +func (c CheckQuotaAvailabilityResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckQuotaAvailabilityResponse. +func (c *CheckQuotaAvailabilityResponse) 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 "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + 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 CheckQuotaAvailabilityResponseProperties. +func (c CheckQuotaAvailabilityResponseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "availabilityStatus", c.AvailabilityStatus) + populate(objectMap, "isAvailable", c.IsAvailable) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckQuotaAvailabilityResponseProperties. +func (c *CheckQuotaAvailabilityResponseProperties) 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 "availabilityStatus": + err = unpopulate(val, "AvailabilityStatus", &c.AvailabilityStatus) + delete(rawMsg, key) + case "isAvailable": + err = unpopulate(val, "IsAvailable", &c.IsAvailable) + 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 EncryptionProperties. +func (e EncryptionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "identity", e.Identity) + populate(objectMap, "keyUrl", e.KeyURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EncryptionProperties. +func (e *EncryptionProperties) 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 "identity": + err = unpopulate(val, "Identity", &e.Identity) + delete(rawMsg, key) + case "keyUrl": + err = unpopulate(val, "KeyURL", &e.KeyURL) + 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 EncryptionPropertiesIdentity. +func (e EncryptionPropertiesIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "resourceId", e.ResourceID) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EncryptionPropertiesIdentity. +func (e *EncryptionPropertiesIdentity) 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 "resourceId": + err = unpopulate(val, "ResourceID", &e.ResourceID) + 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 EndpointDependency. +func (e EndpointDependency) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", e.Description) + populate(objectMap, "domainName", e.DomainName) + populate(objectMap, "endpointDetails", e.EndpointDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EndpointDependency. +func (e *EndpointDependency) 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 "domainName": + err = unpopulate(val, "DomainName", &e.DomainName) + delete(rawMsg, key) + case "endpointDetails": + err = unpopulate(val, "EndpointDetails", &e.EndpointDetails) + 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 EndpointDetail. +func (e EndpointDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "port", e.Port) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EndpointDetail. +func (e *EndpointDetail) 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 "port": + err = unpopulate(val, "Port", &e.Port) + 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 ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + 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]interface{}) + 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]interface{}) + 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 LoadTestProperties. +func (l LoadTestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "dataPlaneURI", l.DataPlaneURI) + populate(objectMap, "description", l.Description) + populate(objectMap, "encryption", l.Encryption) + populate(objectMap, "provisioningState", l.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LoadTestProperties. +func (l *LoadTestProperties) 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 "dataPlaneURI": + err = unpopulate(val, "DataPlaneURI", &l.DataPlaneURI) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &l.Description) + delete(rawMsg, key) + case "encryption": + err = unpopulate(val, "Encryption", &l.Encryption) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &l.ProvisioningState) + 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 LoadTestResource. +func (l LoadTestResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", l.ID) + populate(objectMap, "identity", l.Identity) + populate(objectMap, "location", l.Location) + populate(objectMap, "name", l.Name) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "systemData", l.SystemData) + populate(objectMap, "tags", l.Tags) + populate(objectMap, "type", l.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LoadTestResource. +func (l *LoadTestResource) 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 "identity": + err = unpopulate(val, "Identity", &l.Identity) + 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 "systemData": + err = unpopulate(val, "SystemData", &l.SystemData) + 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 LoadTestResourcePageList. +func (l LoadTestResourcePageList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LoadTestResourcePageList. +func (l *LoadTestResourcePageList) 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 LoadTestResourcePatchRequestBody. +func (l LoadTestResourcePatchRequestBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "identity", l.Identity) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "tags", &l.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LoadTestResourcePatchRequestBody. +func (l *LoadTestResourcePatchRequestBody) 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 "identity": + err = unpopulate(val, "Identity", &l.Identity) + 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) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LoadTestResourcePatchRequestBodyProperties. +func (l LoadTestResourcePatchRequestBodyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", l.Description) + populate(objectMap, "encryption", l.Encryption) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LoadTestResourcePatchRequestBodyProperties. +func (l *LoadTestResourcePatchRequestBodyProperties) 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 "description": + err = unpopulate(val, "Description", &l.Description) + delete(rawMsg, key) + case "encryption": + err = unpopulate(val, "Encryption", &l.Encryption) + 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 ManagedServiceIdentity. +func (m ManagedServiceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", m.PrincipalID) + populate(objectMap, "tenantId", m.TenantID) + populate(objectMap, "type", m.Type) + populate(objectMap, "userAssignedIdentities", m.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedServiceIdentity. +func (m *ManagedServiceIdentity) 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 "principalId": + err = unpopulate(val, "PrincipalID", &m.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &m.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &m.UserAssignedIdentities) + 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]interface{}) + 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]interface{}) + 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]interface{}) + 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 OutboundEnvironmentEndpoint. +func (o OutboundEnvironmentEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "category", o.Category) + populate(objectMap, "endpoints", o.Endpoints) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OutboundEnvironmentEndpoint. +func (o *OutboundEnvironmentEndpoint) 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 "category": + err = unpopulate(val, "Category", &o.Category) + delete(rawMsg, key) + case "endpoints": + err = unpopulate(val, "Endpoints", &o.Endpoints) + 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 OutboundEnvironmentEndpointCollection. +func (o OutboundEnvironmentEndpointCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OutboundEnvironmentEndpointCollection. +func (o *OutboundEnvironmentEndpointCollection) 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 QuotaBucketRequest. +func (q QuotaBucketRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", q.ID) + populate(objectMap, "name", q.Name) + populate(objectMap, "properties", q.Properties) + populate(objectMap, "systemData", q.SystemData) + populate(objectMap, "type", q.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QuotaBucketRequest. +func (q *QuotaBucketRequest) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &q.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &q.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &q.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &q.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &q.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QuotaBucketRequestProperties. +func (q QuotaBucketRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "currentQuota", q.CurrentQuota) + populate(objectMap, "currentUsage", q.CurrentUsage) + populate(objectMap, "dimensions", q.Dimensions) + populate(objectMap, "newQuota", q.NewQuota) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QuotaBucketRequestProperties. +func (q *QuotaBucketRequestProperties) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "currentQuota": + err = unpopulate(val, "CurrentQuota", &q.CurrentQuota) + delete(rawMsg, key) + case "currentUsage": + err = unpopulate(val, "CurrentUsage", &q.CurrentUsage) + delete(rawMsg, key) + case "dimensions": + err = unpopulate(val, "Dimensions", &q.Dimensions) + delete(rawMsg, key) + case "newQuota": + err = unpopulate(val, "NewQuota", &q.NewQuota) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QuotaBucketRequestPropertiesDimensions. +func (q QuotaBucketRequestPropertiesDimensions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "location", q.Location) + populate(objectMap, "subscriptionId", q.SubscriptionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QuotaBucketRequestPropertiesDimensions. +func (q *QuotaBucketRequestPropertiesDimensions) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "location": + err = unpopulate(val, "Location", &q.Location) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &q.SubscriptionID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QuotaResource. +func (q QuotaResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", q.ID) + populate(objectMap, "name", q.Name) + populate(objectMap, "properties", q.Properties) + populate(objectMap, "systemData", q.SystemData) + populate(objectMap, "type", q.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QuotaResource. +func (q *QuotaResource) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &q.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &q.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &q.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &q.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &q.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QuotaResourceList. +func (q QuotaResourceList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", q.NextLink) + populate(objectMap, "value", q.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QuotaResourceList. +func (q *QuotaResourceList) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &q.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &q.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QuotaResourceProperties. +func (q QuotaResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "limit", q.Limit) + populate(objectMap, "provisioningState", q.ProvisioningState) + populate(objectMap, "usage", q.Usage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QuotaResourceProperties. +func (q *QuotaResourceProperties) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "limit": + err = unpopulate(val, "Limit", &q.Limit) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &q.ProvisioningState) + delete(rawMsg, key) + case "usage": + err = unpopulate(val, "Usage", &q.Usage) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, 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, "name", r.Name) + populate(objectMap, "systemData", r.SystemData) + 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 "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + 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]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 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, "systemData", t.SystemData) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResource. +func (t *TrackedResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentity. +func (u UserAssignedIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "clientId", u.ClientID) + populate(objectMap, "principalId", u.PrincipalID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentity. +func (u *UserAssignedIdentity) 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 "clientId": + err = unpopulate(val, "ClientID", &u.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &u.PrincipalID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, 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/loadtestservice/armloadtestservice/zz_generated_operations_client.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/operations_client.go similarity index 95% rename from sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_operations_client.go rename to sdk/resourcemanager/loadtestservice/armloadtestservice/operations_client.go index 8738022e7793..37a14191f866 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_operations_client.go +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/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 armloadtestservice @@ -49,8 +50,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO } // NewListPager - Lists all the available API operations for Load Test Resource. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-04-15-preview +// Generated from API version 2022-12-01 // options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ @@ -88,7 +88,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-04-15-preview") + reqQP.Set("api-version", "2022-12-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/operations_client_example_test.go similarity index 92% rename from sdk/resourcemanager/loadtestservice/armloadtestservice/ze_generated_example_operations_client_test.go rename to sdk/resourcemanager/loadtestservice/armloadtestservice/operations_client_example_test.go index 67472b384069..ce40af095c47 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/ze_generated_example_operations_client_test.go +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/operations_client_example_test.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/loadtestservice/armloadtestservice" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2022-04-15-preview/examples/Operations_List.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Operations_List.json func ExampleOperationsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/quotas_client.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/quotas_client.go new file mode 100644 index 000000000000..6cfd029a5a22 --- /dev/null +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/quotas_client.go @@ -0,0 +1,233 @@ +//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 armloadtestservice + +import ( + "context" + "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" + "net/url" + "strings" +) + +// QuotasClient contains the methods for the Quotas group. +// Don't use this type directly, use NewQuotasClient() instead. +type QuotasClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewQuotasClient creates a new instance of QuotasClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewQuotasClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*QuotasClient, 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) + if err != nil { + return nil, err + } + client := &QuotasClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// CheckAvailability - Check Quota Availability on quota bucket per region per subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-12-01 +// location - The name of Azure region. +// quotaBucketName - Quota Bucket name. +// quotaBucketRequest - Quota Bucket Request data +// options - QuotasClientCheckAvailabilityOptions contains the optional parameters for the QuotasClient.CheckAvailability +// method. +func (client *QuotasClient) CheckAvailability(ctx context.Context, location string, quotaBucketName string, quotaBucketRequest QuotaBucketRequest, options *QuotasClientCheckAvailabilityOptions) (QuotasClientCheckAvailabilityResponse, error) { + req, err := client.checkAvailabilityCreateRequest(ctx, location, quotaBucketName, quotaBucketRequest, options) + if err != nil { + return QuotasClientCheckAvailabilityResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return QuotasClientCheckAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return QuotasClientCheckAvailabilityResponse{}, runtime.NewResponseError(resp) + } + return client.checkAvailabilityHandleResponse(resp) +} + +// checkAvailabilityCreateRequest creates the CheckAvailability request. +func (client *QuotasClient) checkAvailabilityCreateRequest(ctx context.Context, location string, quotaBucketName string, quotaBucketRequest QuotaBucketRequest, options *QuotasClientCheckAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/locations/{location}/quotas/{quotaBucketName}/checkAvailability" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + if quotaBucketName == "" { + return nil, errors.New("parameter quotaBucketName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{quotaBucketName}", url.PathEscape(quotaBucketName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, quotaBucketRequest) +} + +// checkAvailabilityHandleResponse handles the CheckAvailability response. +func (client *QuotasClient) checkAvailabilityHandleResponse(resp *http.Response) (QuotasClientCheckAvailabilityResponse, error) { + result := QuotasClientCheckAvailabilityResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckQuotaAvailabilityResponse); err != nil { + return QuotasClientCheckAvailabilityResponse{}, err + } + return result, nil +} + +// Get - Get the available quota for a quota bucket per region per subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-12-01 +// location - The name of Azure region. +// quotaBucketName - Quota Bucket name. +// options - QuotasClientGetOptions contains the optional parameters for the QuotasClient.Get method. +func (client *QuotasClient) Get(ctx context.Context, location string, quotaBucketName string, options *QuotasClientGetOptions) (QuotasClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, location, quotaBucketName, options) + if err != nil { + return QuotasClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return QuotasClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return QuotasClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *QuotasClient) getCreateRequest(ctx context.Context, location string, quotaBucketName string, options *QuotasClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/locations/{location}/quotas/{quotaBucketName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + if quotaBucketName == "" { + return nil, errors.New("parameter quotaBucketName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{quotaBucketName}", url.PathEscape(quotaBucketName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *QuotasClient) getHandleResponse(resp *http.Response) (QuotasClientGetResponse, error) { + result := QuotasClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.QuotaResource); err != nil { + return QuotasClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Lists all the available quota per region per subscription. +// Generated from API version 2022-12-01 +// location - The name of Azure region. +// options - QuotasClientListOptions contains the optional parameters for the QuotasClient.List method. +func (client *QuotasClient) NewListPager(location string, options *QuotasClientListOptions) *runtime.Pager[QuotasClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[QuotasClientListResponse]{ + More: func(page QuotasClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *QuotasClientListResponse) (QuotasClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, location, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return QuotasClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return QuotasClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return QuotasClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *QuotasClient) listCreateRequest(ctx context.Context, location string, options *QuotasClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/locations/{location}/quotas" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-12-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *QuotasClient) listHandleResponse(resp *http.Response) (QuotasClientListResponse, error) { + result := QuotasClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.QuotaResourceList); err != nil { + return QuotasClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/quotas_client_example_test.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/quotas_client_example_test.go new file mode 100644 index 000000000000..7e2e1d259b7e --- /dev/null +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/quotas_client_example_test.go @@ -0,0 +1,90 @@ +//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 armloadtestservice_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/loadtestservice/armloadtestservice" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_List.json +func ExampleQuotasClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armloadtestservice.NewQuotasClient("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListPager("westus", 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/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_Get.json +func ExampleQuotasClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armloadtestservice.NewQuotasClient("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, "westus", "testQuotaBucket", 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/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_CheckAvailability.json +func ExampleQuotasClient_CheckAvailability() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armloadtestservice.NewQuotasClient("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.CheckAvailability(ctx, "westus", "testQuotaBucket", armloadtestservice.QuotaBucketRequest{ + Properties: &armloadtestservice.QuotaBucketRequestProperties{ + CurrentQuota: to.Ptr[int32](40), + CurrentUsage: to.Ptr[int32](20), + Dimensions: &armloadtestservice.QuotaBucketRequestPropertiesDimensions{ + Location: to.Ptr("westus"), + SubscriptionID: to.Ptr("testsubscriptionId"), + }, + NewQuota: to.Ptr[int32](50), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_response_types.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/response_types.go similarity index 67% rename from sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_response_types.go rename to sdk/resourcemanager/loadtestservice/armloadtestservice/response_types.go index b75e28844774..ea41243ee027 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_response_types.go +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/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 armloadtestservice @@ -33,6 +34,11 @@ type LoadTestsClientListBySubscriptionResponse struct { LoadTestResourcePageList } +// LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse contains the response from method LoadTestsClient.ListOutboundNetworkDependenciesEndpoints. +type LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse struct { + OutboundEnvironmentEndpointCollection +} + // LoadTestsClientUpdateResponse contains the response from method LoadTestsClient.Update. type LoadTestsClientUpdateResponse struct { LoadTestResource @@ -42,3 +48,18 @@ type LoadTestsClientUpdateResponse struct { type OperationsClientListResponse struct { OperationListResult } + +// QuotasClientCheckAvailabilityResponse contains the response from method QuotasClient.CheckAvailability. +type QuotasClientCheckAvailabilityResponse struct { + CheckQuotaAvailabilityResponse +} + +// QuotasClientGetResponse contains the response from method QuotasClient.Get. +type QuotasClientGetResponse struct { + QuotaResource +} + +// QuotasClientListResponse contains the response from method QuotasClient.List. +type QuotasClientListResponse struct { + QuotaResourceList +} diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_time_rfc3339.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/time_rfc3339.go similarity index 99% rename from sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/loadtestservice/armloadtestservice/time_rfc3339.go index 20f989ff9f27..0e0b0ffc0502 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/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 armloadtestservice diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_models_serde.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_models_serde.go deleted file mode 100644 index c5736991ba04..000000000000 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_models_serde.go +++ /dev/null @@ -1,128 +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 armloadtestservice - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type LoadTestResource. -func (l LoadTestResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", l.ID) - populate(objectMap, "identity", l.Identity) - populate(objectMap, "location", l.Location) - populate(objectMap, "name", l.Name) - populate(objectMap, "properties", l.Properties) - populate(objectMap, "systemData", l.SystemData) - populate(objectMap, "tags", l.Tags) - populate(objectMap, "type", l.Type) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type LoadTestResourcePatchRequestBody. -func (l LoadTestResourcePatchRequestBody) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "identity", l.Identity) - populate(objectMap, "properties", l.Properties) - populate(objectMap, "tags", &l.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ManagedServiceIdentity. -func (m ManagedServiceIdentity) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "principalId", m.PrincipalID) - populate(objectMap, "tenantId", m.TenantID) - populate(objectMap, "type", m.Type) - populate(objectMap, "userAssignedIdentities", m.UserAssignedIdentities) - 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 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, "systemData", t.SystemData) - 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 - } -} - -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 -}